protected function expect(string $kind): Token
    {
        $token = $this->lexer->getToken();

        if ($kind === $token->getKind()) {
            $this->lexer->advance();
            return $token;
        }

        throw $this->lexer->createSyntaxErrorException(\sprintf('Expected %s, found %s.', $kind, $token));
    }
protected function expect(string $kind): Token
    {
        $token = $this->lexer->getToken();

        if ($kind === $token->getKind()) {
            $this->lexer->advance();
            return $token;
        }

        throw $this->lexer->createSyntaxErrorException(\sprintf('Expected %s, found %s.', $kind, $token));
    }
protected function expect ( string $ kind ) : Token { $ token = $ this -> lexer -> getToken ( ) ; if ( $ kind === $ token -> getKind ( ) ) { $ this -> lexer -> advance ( ) ; return $ token ; } throw $ this -> lexer -> createSyntaxErrorException ( \ sprintf ( 'Expected %s, found %s.' , $ kind , $ token ) ) ; }
If the next token is of the given kind, return that token after advancing
the lexer. Otherwise, do not change the parser state and throw an error.

@param string $kind
@return Token
@throws SyntaxErrorException
If the next token is of the given kind return that token after advancing the lexer . Otherwise do not change the parser state and throw an error .