Antlr4.Runtime.Atn.ParserATNSimulator.RemoveAllConfigsNotInRuleStopState C# (CSharp) Method

RemoveAllConfigsNotInRuleStopState() protected method

protected RemoveAllConfigsNotInRuleStopState ( ATNConfigSet configSet, bool lookToEndOfRule ) : ATNConfigSet
configSet ATNConfigSet
lookToEndOfRule bool
return ATNConfigSet
        protected ATNConfigSet RemoveAllConfigsNotInRuleStopState(ATNConfigSet configSet, bool lookToEndOfRule)
        {
            if (PredictionMode.AllConfigsInRuleStopStates(configSet.configs))
            {
                return configSet;
            }

            ATNConfigSet result = new ATNConfigSet(configSet.fullCtx);
            foreach (ATNConfig config in configSet.configs)
            {
                if (config.state is RuleStopState)
                {
                    result.Add(config, mergeCache);
                    continue;
                }

                if (lookToEndOfRule && config.state.OnlyHasEpsilonTransitions)
                {
                    IntervalSet nextTokens = atn.NextTokens(config.state);
                    if (nextTokens.Contains(TokenConstants.EPSILON))
                    {
                        ATNState endOfRuleState = atn.ruleToStopState[config.state.ruleIndex];
                        result.Add(new ATNConfig(config, endOfRuleState), mergeCache);
                    }
                }
            }

            return result;
        }