Esempio n. 1
0
        /// <summary>
        /// Reads and consumes the next token in the queue. If no token was
        /// available for consumption, a parse error will be thrown. A
        /// parse error will also be thrown if the token id didn't match
        /// the specified one.
        /// </summary>
        /// <param name="id">The expected token id</param>
        /// <returns>The token consumed</returns>
        /// <exception cref="ParseException">
        /// If the input stream couldn't be parsed correctly, or if the
        /// token wasn't expected
        /// </exception>
        internal Token NextToken(int id)
        {
            Token          token = this.NextToken();
            IList <string> list;

            if (token.Id == id)
            {
                if (this.errorRecovery > 0)
                {
                    this.errorRecovery--;
                }

                return(token);
            }
            else
            {
                list = new List <string>(1);
                list.Add(this.tokenizer.GetPatternDescription(id));

                throw new ParseException(
                          ParseException.ErrorType.UnexpectedToken,
                          token.ToShortString(),
                          list,
                          token.StartLine,
                          token.StartColumn);
            }
        }
Esempio n. 2
0
        /**
         * Reads and consumes the next token in the queue. If no token was
         * available for consumation, a parse error will be thrown. A
         * parse error will also be thrown if the token id didn't match
         * the specified one.
         *
         * @param id             the expected token id
         *
         * @return the token consumed
         *
         * @throws ParseException if the input stream couldn't be parsed
         *             correctly, or if the token wasn't expected
         */
        internal Token NextToken(int id)
        {
            Token     token = NextToken();
            ArrayList list;

            if (token.Id == id)
            {
                if (errorRecovery > 0)
                {
                    errorRecovery--;
                }
                return(token);
            }
            else
            {
                list = new ArrayList(1);
                list.Add(tokenizer.GetPatternDescription(id));
                throw new ParseException(
                          ParseException.ErrorType.UNEXPECTED_TOKEN,
                          token.ToShortString(),
                          list,
                          token.StartLine,
                          token.StartColumn);
            }
        }