Antlr4.Runtime.Atn.LexerATNSimulator.GetReachableConfigSet C# (CSharp) Method

GetReachableConfigSet() protected method

protected GetReachableConfigSet ( ICharStream input, ATNConfigSet closure, ATNConfigSet reach, int t ) : void
input ICharStream
closure ATNConfigSet
reach ATNConfigSet
t int
return void
        protected void GetReachableConfigSet(ICharStream input, ATNConfigSet closure, ATNConfigSet reach, int t)
        {
            // this is used to skip processing for configs which have a lower priority
            // than a config that already reached an accept state for the same rule
            int skipAlt = ATN.INVALID_ALT_NUMBER;
            foreach (ATNConfig c in closure.configs)
            {
                bool currentAltReachedAcceptState = c.alt == skipAlt;
                if (currentAltReachedAcceptState && ((LexerATNConfig)c).hasPassedThroughNonGreedyDecision())
                {
                    continue;
                }

                if (debug)
                {
                    Console.WriteLine("testing " + GetTokenName(t) + " at " + c.ToString(recog, true));
                }

                int n = c.state.NumberOfTransitions;
                for (int ti = 0; ti < n; ti++)
                {               // for each transition
                    Transition trans = c.state.Transition(ti);
                    ATNState target = GetReachableTarget(trans, t);
                    if (target != null)
                    {
                        LexerActionExecutor lexerActionExecutor = ((LexerATNConfig)c).getLexerActionExecutor();
                        if (lexerActionExecutor != null)
                        {
                            lexerActionExecutor = lexerActionExecutor.FixOffsetBeforeMatch(input.Index - startIndex);
                        }

                        bool treatEofAsEpsilon = t == IntStreamConstants.EOF;
                        if (Closure(input, new LexerATNConfig((LexerATNConfig)c, target, lexerActionExecutor), reach, currentAltReachedAcceptState, true, treatEofAsEpsilon))
                        {
                            // any remaining configs for this alt have a lower priority than
                            // the one that just reached an accept state.
                            skipAlt = c.alt;
                            break;
                        }
                    }
                }
            }
        }