/**
  * Attempts to match the given token with the current lookahead token.
  *
  * If they match, updates the lookahead token; otherwise raises a syntax
  * error.
  *
  * @param int token type
  * @return void
  * @throws QueryException If the tokens dont match.
  */
 public function match($token)
 {
     // short-circuit on first condition, usually types match
     if ($this->_lexer->lookahead['type'] !== $token && $token !== Lexer::T_IDENTIFIER && $this->_lexer->lookahead['type'] <= Lexer::T_IDENTIFIER) {
         $this->syntaxError($this->_lexer->getLiteral($token));
     }
     $this->_lexer->moveNext();
 }
Beispiel #2
0
 /**
  * Attempts to match the given token with the current lookahead token.
  *
  * If they match, updates the lookahead token; otherwise raises a syntax
  * error.
  *
  * @param int $token The token type.
  *
  * @return void
  *
  * @throws QueryException If the tokens don't match.
  */
 public function match($token)
 {
     $lookaheadType = $this->lexer->lookahead['type'];
     // Short-circuit on first condition, usually types match
     if ($lookaheadType !== $token) {
         // If parameter is not identifier (1-99) must be exact match
         if ($token < Lexer::T_IDENTIFIER) {
             $this->syntaxError($this->lexer->getLiteral($token));
         }
         // If parameter is keyword (200+) must be exact match
         if ($token > Lexer::T_IDENTIFIER) {
             $this->syntaxError($this->lexer->getLiteral($token));
         }
         // If parameter is T_IDENTIFIER, then matches T_IDENTIFIER (100) and keywords (200+)
         if ($token === Lexer::T_IDENTIFIER && $lookaheadType < Lexer::T_IDENTIFIER) {
             $this->syntaxError($this->lexer->getLiteral($token));
         }
     }
     $this->lexer->moveNext();
 }