def expect_token(lexer: Lexer, kind: TokenKind) -> Token:
    """Expect the next token to be of the given kind.

    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.
    """
    token = lexer.token
    if token.kind == kind:
        lexer.advance()
        return token

    raise GraphQLSyntaxError(
        lexer.source, token.start, f"Expected {kind.value}, found {token.kind.value}"
    )
Expect the next token to be of the given kind.

    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.