@@ -1088,34 +1088,33 @@ def expect_optional_token(lexer: Lexer, kind: TokenKind) -> Optional[Token]:
1088
1088
return None
1089
1089
1090
1090
1091
- def expect_keyword (lexer : Lexer , value : str ) -> Token :
1091
+ def expect_keyword (lexer : Lexer , value : str ) -> None :
1092
1092
"""Expect the next token to be a given keyword.
1093
1093
1094
- If the next token is a given keyword, return that token after advancing the lexer.
1094
+ If the next token is a given keyword, advance the lexer.
1095
1095
Otherwise, do not change the parser state and throw an error.
1096
1096
"""
1097
1097
token = lexer .token
1098
1098
if token .kind == TokenKind .NAME and token .value == value :
1099
1099
lexer .advance ()
1100
- return token
1101
-
1102
- raise GraphQLSyntaxError (
1103
- lexer .source , token .start , f"Expected { value !r} , found { token .desc } "
1104
- )
1100
+ else :
1101
+ raise GraphQLSyntaxError (
1102
+ lexer .source , token .start , f"Expected { value !r} , found { token .desc } "
1103
+ )
1105
1104
1106
1105
1107
- def expect_optional_keyword (lexer : Lexer , value : str ) -> Optional [ Token ] :
1106
+ def expect_optional_keyword (lexer : Lexer , value : str ) -> bool :
1108
1107
"""Expect the next token optionally to be a given keyword.
1109
1108
1110
- If the next token is a given keyword, return that token after advancing the lexer.
1111
- Otherwise, do not change the parser state and return None .
1109
+ If the next token is a given keyword, return True after advancing the lexer.
1110
+ Otherwise, do not change the parser state and return False .
1112
1111
"""
1113
1112
token = lexer .token
1114
1113
if token .kind == TokenKind .NAME and token .value == value :
1115
1114
lexer .advance ()
1116
- return token
1115
+ return True
1117
1116
1118
- return None
1117
+ return False
1119
1118
1120
1119
1121
1120
def unexpected (lexer : Lexer , at_token : Token = None ) -> GraphQLError :
0 commit comments