Antlr.Runtime.BaseRecognizer.AlreadyParsedRule C# (CSharp) Method

AlreadyParsedRule() public method

* Has this rule already parsed input at the current index in the * input stream? Return the stop token index or MEMO_RULE_UNKNOWN. * If we attempted but failed to parse properly before, return * MEMO_RULE_FAILED. *
* This method has a side-effect: if we have seen this input for * this rule and successfully parsed before, then seek ahead to * 1 past the stop token matched for this rule last time. *
public AlreadyParsedRule ( IIntStream input, int ruleIndex ) : bool
input IIntStream
ruleIndex int
return bool
        public virtual bool AlreadyParsedRule( IIntStream input, int ruleIndex )
        {
            int stopIndex = GetRuleMemoization( ruleIndex, input.Index );
            if ( stopIndex == MemoRuleUnknown )
            {
                return false;
            }
            if ( stopIndex == MemoRuleFailed )
            {
                //System.out.println("rule "+ruleIndex+" will never succeed");
                state.failed = true;
            }
            else
            {
                //System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed);
                input.Seek( stopIndex + 1 ); // jump to one past stop token
            }
            return true;
        }