public function expect($type, $value = null, $message = null)
    {
        $token = $this->tokens[$this->current];

        if (!$token->test($type, $value)) {
            throw new SyntaxErrorException(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s) on line %s', $message ? "$message. " : "", $token, $token->getValue(), Token::getName($type), $value ? sprintf(' with value "%s"', $value) : '', $token->getLine()));
        }

        return $token;
    }