protected function assertErrorToken(Token $token)
    {
        if (!$token->isError()) {
            return $this;
        }
        switch ($token->getType()) {
            case Token::TYPE_ERROR_INVALID_ESCAPE:
                throw new SyntaxException(
                    "Invalid escape sequence at position #{$this->getNextPosition()}",
                    $this->getNextPosition()
                );

            default:
                throw new UnknownSyntaxException(
                    "Unknown type of error token: {$token->getType()} at position #{$this->getNextPosition()}",
                    $this->getNextPosition()
                );
        }
    }
protected function assertErrorToken(Token $token)
    {
        if (!$token->isError()) {
            return $this;
        }
        switch ($token->getType()) {
            case Token::TYPE_ERROR_INVALID_ESCAPE:
                throw new SyntaxException(
                    "Invalid escape sequence at position #{$this->getNextPosition()}",
                    $this->getNextPosition()
                );

            default:
                throw new UnknownSyntaxException(
                    "Unknown type of error token: {$token->getType()} at position #{$this->getNextPosition()}",
                    $this->getNextPosition()
                );
        }
    }
protected function assertErrorToken ( Token $ token ) { if ( ! $ token -> isError ( ) ) { return $ this ; } switch ( $ token -> getType ( ) ) { case Token :: TYPE_ERROR_INVALID_ESCAPE : throw new SyntaxException ( "Invalid escape sequence at position #{$this->getNextPosition()}" , $ this -> getNextPosition ( ) ) ; default : throw new UnknownSyntaxException ( "Unknown type of error token: {$token->getType()} at position #{$this->getNextPosition()}" , $ this -> getNextPosition ( ) ) ; } }
Checks if token is an error and processes it.

@param Token $token
@return $this
@throws SyntaxException
@throws UnknownSyntaxException
Checks if token is an error and processes it .