Beispiel #1
0
 private void Eat(TokenType tokenType)
 {
     if (currentToken.TokenType == tokenType)
     {
         currentToken = lexer.GetNextToken();
     }
     else
     {
         Error();
     }
 }
Beispiel #2
0
 /// <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 + "\"");
     }
 }
Beispiel #3
0
 public Parser(Lexer lexer)
 {
     this.lexer   = lexer;
     currentToken = lexer.GetNextToken();
 }
 public Interpreter(Lexer lexer)
 {
     this.lexer   = lexer;
     currentToken = lexer.GetNextToken();
 }
Beispiel #5
0
 public Parser(Lexer lex)
 {
     _Lexer        = lex;
     _CurrentToken = lex.GetNextToken();
 }