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()
                );
        }
    }