private void Eat(TokenType tokenType) { if (currentToken.TokenType == tokenType) { currentToken = lexer.GetNextToken(); } else { Error(); } }
/// <summary> /// Checks that the next token is of the correct type. Advance the lexer if /// it is, and throws an exception if it isn't. /// </summary> /// <param name="_type"></param> private void _Eat(TokenType _type) { if (_CurrentToken.Type == _type) { _CurrentToken = _Lexer.GetNextToken(); return; } else { throw new Exception("Unexpected token. Expected: \"" + _type.ToString() + "\" Got: \"" + _CurrentToken.Type + "\""); } }
public Parser(Lexer lexer) { this.lexer = lexer; currentToken = lexer.GetNextToken(); }
public Interpreter(Lexer lexer) { this.lexer = lexer; currentToken = lexer.GetNextToken(); }
public Parser(Lexer lex) { _Lexer = lex; _CurrentToken = lex.GetNextToken(); }