private void ThrowParseException(LookAheadSet set) { ArrayList list = new ArrayList(); // Read tokens until mismatch while (set.IsNext(this, 1)) { set = set.CreateNextSet(NextToken().Id); } // Find next token descriptions var initials = set.GetInitialTokens(); for (int i = 0; i < initials.Length; i++) { list.Add(GetTokenDescription(initials[i])); } // Create exception var token = NextToken(); throw new ParseException(ParseException.ErrorType.UNEXPECTED_TOKEN, token.ToShortString(), list, token.StartLine, token.StartColumn); }
private void ThrowAmbiguityException(string pattern, string location, LookAheadSet set) { ArrayList list = new ArrayList(); // Find next token descriptions var initials = set.GetInitialTokens(); for (int i = 0; i < initials.Length; i++) { list.Add(GetTokenDescription(initials[i])); } // Create exception throw new ParserCreationException( ParserCreationException.ErrorType.INHERENT_AMBIGUITY, pattern, location, list); }