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

EvaluatePredicate() protected method

protected EvaluatePredicate ( ICharStream input, int ruleIndex, int predIndex, bool speculative ) : bool
input ICharStream
ruleIndex int
predIndex int
speculative bool
return bool
        protected bool EvaluatePredicate(ICharStream input, int ruleIndex, int predIndex, bool speculative)
        {
            // assume true if no recognizer was provided
            if (recog == null)
            {
                return true;
            }

            if (!speculative)
            {
                return recog.Sempred(null, ruleIndex, predIndex);
            }

            int savedCharPositionInLine = charPositionInLine;
            int savedLine = thisLine;
            int index = input.Index;
            int marker = input.Mark();
            try
            {
                Consume(input);
                return recog.Sempred(null, ruleIndex, predIndex);
            }
            finally
            {
                charPositionInLine = savedCharPositionInLine;
                thisLine = savedLine;
                input.Seek(index);
                input.Release(marker);
            }
        }