//*
            // * Returns a string representation of this object.
            // *
            // * @param tokenizer the tokenizer containing the tokens
            // *
            // * @return a string representation of this object
            //

            public string ToString(Tokenizer tokenizer)
            {
                StringBuilder buffer = new StringBuilder();
                string        str    = null;
                int           id     = 0;

                if (tokenizer == null)
                {
                    buffer.Append(tokens.ToString());
                }
                else
                {
                    buffer.Append("[");
                    for (int i = 0; i <= tokens.Count - 1; i++)
                    {
                        id  = (int)tokens[i];
                        str = tokenizer.GetPatternDescription(id);
                        if (i > 0)
                        {
                            buffer.Append(" ");
                        }
                        buffer.Append(str);
                    }
                    buffer.Append("]");
                }
                if (repeat)
                {
                    buffer.Append(" *");
                }
                return(buffer.ToString());
            }
Example #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  = default(ArrayList);

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