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