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

GetRuleMemoization() public method

* Given a rule number and a start token index number, return * MEMO_RULE_UNKNOWN if the rule has not parsed input starting from * start index. If this rule has parsed input starting from the * start index before, then return where the rule stopped parsing. * It returns the index of the last token matched by the rule. *
* For now we use a hashtable and just the slow Object-based one. * Later, we can make a special one for ints and also one that * tosses out data after we commit past input position i. *
public GetRuleMemoization ( int ruleIndex, int ruleStartIndex ) : int
ruleIndex int
ruleStartIndex int
return int
        public virtual int GetRuleMemoization( int ruleIndex, int ruleStartIndex )
        {
            if ( state.ruleMemo[ruleIndex] == null )
            {
                state.ruleMemo[ruleIndex] = new Dictionary<int, int>();
            }

            int stopIndex;
            if ( !state.ruleMemo[ruleIndex].TryGetValue( ruleStartIndex, out stopIndex ) )
                return MemoRuleUnknown;

            return stopIndex;
        }