/** * Throws a parse exception that matches the specified look-ahead * set. This method will take into account any initial matching * tokens in the look-ahead set. * * @param set the look-ahead set to match * * @throws ParseException always thrown by this method */ private void ThrowParseException(LookAheadSet set) { Token token; ArrayList list = new ArrayList(); int[] initials; // Read tokens until mismatch while (set.IsNext(this, 1)) { set = set.CreateNextSet(NextToken().Id); } // Find next token descriptions initials = set.GetInitialTokens(); for (int i = 0; i < initials.Length; i++) { list.Add(GetTokenDescription(initials[i])); } // Create exception token = NextToken(); throw new ParseException(ParseException.ErrorType.UNEXPECTED_TOKEN, token.ToShortString(), list, token.StartLine, token.StartColumn); }
/** * Throws a parser creation exception for an ambiguity. The * specified look-ahead set contains the token conflicts to be * reported. * * @param pattern the production pattern name * @param location the production pattern location, or null * @param set the look-ahead set with conflicts * * @throws ParserCreationException always thrown by this method */ private void ThrowAmbiguityException(string pattern, string location, LookAheadSet set) { ArrayList list = new ArrayList(); int[] initials; // Find next token descriptions 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); }
/** * Throws a parser creation exception for an ambiguity. The * specified look-ahead set contains the token conflicts to be * reported. * * @param pattern the production pattern name * @param location the production pattern location, or null * @param set the look-ahead set with conflicts * * @throws ParserCreationException always thrown by this method */ private void ThrowAmbiguityException(string pattern, string location, LookAheadSet set) { ArrayList list = new ArrayList(); int[] initials; // Find next token descriptions 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); }
/** * Throws a parse exception that matches the specified look-ahead * set. This method will take into account any initial matching * tokens in the look-ahead set. * * @param set the look-ahead set to match * * @throws ParseException always thrown by this method */ private void ThrowParseException(LookAheadSet set) { Token token; ArrayList list = new ArrayList(); int[] initials; // Read tokens until mismatch while (set.IsNext(this, 1)) { set = set.CreateNextSet(NextToken().Id); } // Find next token descriptions initials = set.GetInitialTokens(); for (int i = 0; i < initials.Length; i++) { list.Add(GetTokenDescription(initials[i])); } // Create exception token = NextToken(); throw new ParseException(ParseException.ErrorType.UNEXPECTED_TOKEN, token.ToShortString(), list, token.StartLine, token.StartColumn); }