Beispiel #1
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|string token type or value
  * @return bool True, if tokens match; false otherwise.
  */
 public function match($token)
 {
     if (!($this->_lexer->lookahead['type'] === $token)) {
         $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|string token type or value
  * @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 #3
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|string token type or value
  * @return bool True, if tokens match; false otherwise.
  */
 public function match($token)
 {
     if (is_string($token)) {
         $isMatch = $this->_lexer->lookahead['value'] === $token;
     } else {
         $isMatch = $this->_lexer->lookahead['type'] === $token;
     }
     if (!$isMatch) {
         $this->syntaxError($this->_lexer->getLiteral($token));
     }
     $this->_lexer->moveNext();
 }