public string Should_parse(string query) { var input = new AntlrInputStream(query); var lexer = new QlLexer(input); var commonTokenStream = new CommonTokenStream(lexer); var parser = new QlParser(commonTokenStream); parser.AddErrorListener(new QlErrorListener()); parser.BuildParseTree = true; IParseTree tree = parser.parse(); var lis = new QlVisitor(); return(lis.Visit(tree).ToString()); }
public IRecordSet Execute(string query, QlParameter[] parameters) { var input = new AntlrInputStream(query); var lexer = new QlLexer(input); var commonTokenStream = new CommonTokenStream(lexer); var parser = new QlParser(commonTokenStream); parser.AddErrorListener(new QlErrorListener()); parser.BuildParseTree = true; IParseTree tree = parser.parse(); var lis = new QlVisitor(); var expr = lis.Visit(tree); var evalVis = new ExpressionEvaluatorVisitor(_journal, _tx, parameters); var res = evalVis.Visit(expr); IRecordSet records = new RecordSet(res.Build().Rowids, _tx, _journal.Metadata); if (res.Columns != null) { records = records.Map(res.Columns); } return(records); }