Next() public method

public Next ( ) : Token
return Token
Ejemplo n.º 1
0
        public static void Expect(TokenList tl, TokenType type, string value)
        {
            Token t = tl.Next();

            if ((t.Type == type) && (t.Value == value))
            {
                tl.Consume();
            }
            else
            {
                string expectedType = TokenTypeToString(type);
                string expectedValue = value;
                string foundType = TokenTypeToString(t.Type);
                string foundValue = t.Value;
                ExceptionType exceptionType = (type == TokenType.KEYWORD)
                                                ? ExceptionType.UnknownSymbol
                                                : ExceptionType.Syntax;

                throw new EngineException(exceptionType,
                                          string.Format("Expected '{0}' with Value '{1}' found '{2}' with Value '{3}'", expectedType,
                                                        expectedValue, foundType, foundValue), t);
            }
        }
Ejemplo n.º 2
0
        public static string Expect(TokenList tl, TokenType type, bool consume)
        {
            Token t = tl.Next();

            if (t.Type == type)
            {
                if (consume)
                    tl.Consume();

                return t.Value;
            }

            string expectedType = TokenTypeToString(type);
            string foundType = TokenTypeToString(t.Type);

            throw new EngineException(ExceptionType.Syntax, string.Format("Expected '{0}' found '{1}' with Value '{2}'", expectedType, foundType, tl.Next().Value), t);
        }