/** * 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); }
/// <summary> /// 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. /// </summary> /// <param name="set">The look-ahead set to match</param> /// <exception cref="ParseException">Always thrown by this method</exception> private void ThrowParseException(LookAheadSet set) { Token token; IList <string> list = new List <string>(); int[] initials; // Read tokens until mismatch while (set.IsNext(this, 1)) { set = set.CreateNextSet(this.NextToken().Id); } // Find next token descriptions initials = set.InitialTokens; for (int i = 0; i < initials.Length; i++) { list.Add(this.GetTokenDescription(initials[i])); } // Create exception token = this.NextToken(); throw new ParseException( ParseException.ErrorType.UnexpectedToken, token.ToShortString(), list, token.StartLine, token.StartColumn); }
/** * 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); }