public object Run(string script, TSQLEngine engine, CancellationToken cancellationToken) { try { this.lexer = new Lexer(script, true); this.parser = new Parser.Parser(lexer); this.queryTree = parser.ComposeAll(); var prepareQuery = new PrepareQueryVisitor(engine, cancellationToken); this.prepareQueryTraverser = new PrepareQueryTraverseVisitor(prepareQuery, cancellationToken); queryTree.Accept(prepareQueryTraverser); queryTree = prepareQuery.Root; this.requestData = new RequestDataVisitor(engine, cancellationToken); this.requestDataTraverser = new RequestDataTraverseVisitor(requestData, cancellationToken); queryTree.Accept(requestDataTraverser); queryTree = requestData.Root; this.runQuery = new RunQueryVisitor(engine, cancellationToken); this.csharpRewriteTraverser = new RunQueryTraverseVisitor(runQuery, cancellationToken); queryTree.Accept(csharpRewriteTraverser); return(runQuery.Result); } catch (AggregateException ex) { throw ex.InnerException; } }
public override void Build(BuildItems items) { var queryTree = items.RawQueryTree; var prepareQuery = new PrepareQueryVisitor(items.Engine); var prepareQueryTraverser = new PrepareQueryTraverseVisitor(prepareQuery); queryTree.Accept(prepareQueryTraverser); queryTree = prepareQuery.Root; var csharpRewriter = new RunQueryVisitor(items.Engine); var csharpRewriteTraverser = new RunTraverseVisitor(csharpRewriter); queryTree.Accept(csharpRewriteTraverser); items.Result = csharpRewriter.Result; Successor?.Build(items); }