private KustoCode(string text, string kind, GlobalState globals, Parser <LexicalToken> grammar, SyntaxNode syntax, bool hasSemantics, LexicalToken[] lexerTokens, LocalBindingCache localCache) { this.Text = text; this.Kind = kind; this.Globals = globals; this.Grammar = grammar; this.Syntax = syntax; this.HasSemantics = hasSemantics; this.lexerTokens = lexerTokens; this.localCache = localCache; }
/// <summary> /// Creates a new <see cref="KustoCode"/> form the already parsed lexical tokens. /// </summary> private static KustoCode Create(string text, GlobalState globals, LexicalToken[] tokens, List <int> tokenStarts, bool analyze, CancellationToken cancellationToken) { Parser <LexicalToken> grammar; SyntaxNode syntax; globals = globals ?? GlobalState.Default; var kind = GetKind(text); switch (kind) { case CodeKinds.Command: var commandBlock = CommandGrammar.From(globals).CommandBlock; grammar = commandBlock; syntax = commandBlock.ParseFirst(tokens); break; case CodeKinds.Directive: grammar = DirectiveGrammar.DirectiveBlock; syntax = DirectiveGrammar.DirectiveBlock.ParseFirst(tokens); break; case CodeKinds.Query: default: var queryBlock = QueryGrammar.From(globals).QueryBlock; grammar = queryBlock; syntax = queryBlock.ParseFirst(tokens); break; } var tree = new SyntaxTree(syntax); syntax.InitializeTriviaStarts(); LocalBindingCache localCache = null; TypeSymbol resultType = null; var analyzed = false; if (analyze) { cancellationToken.ThrowIfCancellationRequested(); analyzed = true; localCache = new LocalBindingCache(); if (Binder.TryBind(tree, globals, localCache, null, cancellationToken)) { resultType = DetermineResultType(syntax); } } return(new KustoCode(text, kind, globals, grammar, tree, analyzed, resultType, tokens, tokenStarts, localCache)); }
/// <summary> /// Creates a new <see cref="KustoCode"/> form the already parsed lexical tokens. /// </summary> private static KustoCode Create(string text, GlobalState globals, LexicalToken[] tokens, bool analyze, CancellationToken cancellationToken) { Parser <LexicalToken> grammar; SyntaxNode syntax; var kind = GetKind(text); switch (kind) { case CodeKinds.Command: var commandBlock = CommandGrammar.From(globals).CommandBlock; grammar = commandBlock; syntax = commandBlock.ParseFirst(tokens); break; case CodeKinds.Directive: grammar = DirectiveGrammar.DirectiveBlock; syntax = DirectiveGrammar.DirectiveBlock.ParseFirst(tokens); break; case CodeKinds.Query: default: var queryBlock = QueryGrammar.From(globals).QueryBlock; grammar = queryBlock; syntax = queryBlock.ParseFirst(tokens); break; } var maxDepth = ComputeMaxDepth(syntax); var isAnalyzable = maxDepth <= MaxAnalyzableSyntaxDepth; syntax.InitializeTriviaStarts(); LocalBindingCache localCache = null; TypeSymbol resultType = null; if (analyze && isAnalyzable) { cancellationToken.ThrowIfCancellationRequested(); localCache = new LocalBindingCache(); if (Binder.TryBind(syntax, globals, localCache, null, cancellationToken)) { resultType = DetermineResultType(syntax); } } return(new KustoCode(text, kind, globals, grammar, syntax, analyze && isAnalyzable, resultType, tokens, localCache, maxDepth)); }
private KustoCode( string text, string kind, GlobalState globals, Parser <LexicalToken> grammar, SyntaxTree tree, bool hasSemantics, TypeSymbol resultType, LexicalToken[] lexerTokens, LocalBindingCache localCache) { this.Text = text; this.Kind = kind; this.Globals = globals; this.Grammar = grammar; this.Tree = tree; this.HasSemantics = hasSemantics; this.ResultType = resultType; this.lexerTokens = lexerTokens; this.localCache = localCache; }
/// <summary> /// Creates a new <see cref="KustoCode"/> form the already parsed lexical tokens. /// </summary> private static KustoCode Create(string text, GlobalState globals, LexicalToken[] tokens, bool analyze, CancellationToken cancellationToken) { Parser <LexicalToken> grammar; SyntaxNode syntax; var kind = GetKind(text); switch (kind) { case CodeKinds.Command: var commandBlock = CommandGrammar.From(globals).CommandBlock; grammar = commandBlock; syntax = commandBlock.ParseFirst(tokens); break; case CodeKinds.Directive: grammar = DirectiveGrammar.DirectiveBlock; syntax = DirectiveGrammar.DirectiveBlock.ParseFirst(tokens); break; case CodeKinds.Query: default: var queryBlock = QueryGrammar.From(globals).QueryBlock; grammar = queryBlock; syntax = queryBlock.ParseFirst(tokens); break; } LocalBindingCache localCache = null; if (analyze) { cancellationToken.ThrowIfCancellationRequested(); localCache = new LocalBindingCache(); Binder.Bind(syntax, globals, localCache, null, cancellationToken); } return(new KustoCode(text, kind, globals, grammar, syntax, analyze, tokens, localCache)); }
private KustoCode( string text, string kind, GlobalState globals, Parser <LexicalToken> grammar, SyntaxNode syntax, bool hasSemantics, TypeSymbol resultType, LexicalToken[] lexerTokens, LocalBindingCache localCache, int maxDepth) { this.Text = text; this.Kind = kind; this.Globals = globals; this.Grammar = grammar; this.Syntax = syntax; this.HasSemantics = hasSemantics; this.ResultType = resultType; this.lexerTokens = lexerTokens; this.localCache = localCache; this.MaxDepth = maxDepth; }