public IntervalSet Compute()

in Microsoft.Azure.Cosmos/src/Query/Core/Parser/LASets.cs [46:150]


        public IntervalSet Compute(Parser parser, CommonTokenStream token_stream, int line, int col)
        {
            this.input = new List<IToken>();
            this.parser = parser;
            this.tokenStream = token_stream;
            this.stopStates = new HashSet<ATNState>();
            foreach (ATNState s in parser.Atn.ruleToStopState.Select(t => parser.Atn.states[t.stateNumber]))
            {
                this.stopStates.Add(s);
            }
            this.startStates = new HashSet<ATNState>();
            foreach (ATNState s in parser.Atn.ruleToStartState.Select(t => parser.Atn.states[t.stateNumber]))
            {
                this.startStates.Add(s);
            }
            int currentIndex = this.tokenStream.Index;
            this.tokenStream.Seek(0);
            int offset = 1;
            while (true)
            {
                IToken token = this.tokenStream.LT(offset++);
                this.input.Add(token);
                this.cursor = token.TokenIndex;
                if (token.Type == TokenConstants.EOF)
                {
                    break;
                }
                if (token.Line >= line && token.Column >= col)
                {
                    break;
                }
            }
            this.tokenStream.Seek(currentIndex);

            List<List<Edge>> all_parses = this.EnterState(new Edge()
            {
                index = 0,
                indexAtTransition = 0,
                to = this.parser.Atn.states[0],
                type = TransitionType.EPSILON
            });
            // Remove last token on input.
            this.input.RemoveAt(this.input.Count - 1);
            // Eliminate all paths that don't consume all input.
            List<List<Edge>> temp = new List<List<Edge>>();
            if (all_parses != null)
            {
                foreach (List<Edge> p in all_parses)
                {
                    //System.Console.Error.WriteLine(PrintSingle(p));
                    if (this.Validate(p, this.input))
                    {
                        temp.Add(p);
                    }
                }
            }
            all_parses = temp;
            if (all_parses != null && this.logClosure)
            {
                foreach (List<Edge> p in all_parses)
                {
                    System.Console.Error.WriteLine("Path " + this.PrintSingle(p));
                }
            }
            IntervalSet result = new IntervalSet();
            if (all_parses != null)
            {
                foreach (List<Edge> p in all_parses)
                {
                    HashSet<ATNState> set = this.ComputeSingle(p);
                    if (this.logClosure)
                    {
                        System.Console.Error.WriteLine("All states for path "
                                                       + string.Join(" ", set.ToList()));
                    }

                    foreach (ATNState s in set)
                    {
                        foreach (Transition t in s.TransitionsArray)
                        {
                            switch (t.TransitionType)
                            {
                                case TransitionType.RULE:
                                    break;

                                case TransitionType.PREDICATE:
                                    break;

                                case TransitionType.WILDCARD:
                                    break;

                                default:
                                    if (!t.IsEpsilon)
                                    {
                                        result.AddAll(t.Label);
                                    }

                                    break;
                            }
                        }
                    }
                }
            }
            return result;
        }