/** * 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 of Token. * @return bool True if tokens match; false otherwise. */ private function match($token) { if (!$this->lexer->isNextToken($token)) { $this->syntaxError($this->lexer->getLiteral($token)); } return $this->lexer->moveNext(); }
/** * Matches the next token and advances. * * @param integer $token The next token to match. * * @return array|null TRUE if the next token matches, FALSE if not. * * @throws Exception * @throws SyntaxException If a syntax error is found. */ private function match($token) { if (!$this->lexer->isNextToken($token)) { throw SyntaxException::expectedToken($this->lexer->getLiteral($token), null, $this->lexer); } return $this->lexer->moveNext(); }