예제 #1
0
 /// <summary>
 /// Check for recursion, and add the rule to the list of rules that have been used
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="tokens"></param>
 /// <returns>True when the rule with the same tokens list is found in the list</returns>
 internal bool HasRecursion(PPRule rule, IList <XSharpToken> tokens)
 {
     // check to see if this is already there
     if (_list.Count == _maxDepth)
     {
         _pp.addParseError(new ParseErrorData(tokens[0], ErrorCode.ERR_PreProcessorRecursiveRule, rule.Name));
         return(true);
     }
     foreach (var item in _list)
     {
         if (item.isDuplicate(rule, tokens))
         {
             _pp.addParseError(new ParseErrorData(tokens[0], ErrorCode.ERR_PreProcessorRecursiveRule, rule.Name));
             return(true);
         }
     }
     _list.Add(new PPUsedRule(rule, tokens));
     return(false);
 }