@@ -326,7 +326,7 @@ def _parse_create(self) -> Optional[Operation]:
326326 if not self .token .is_colon ():
327327 raise ValueError ("Expected ':' for relationship type" )
328328 self .set_next_token ()
329- if not self .token .is_identifier ():
329+ if not self .token .is_identifier_or_keyword ():
330330 raise ValueError ("Expected relationship type identifier" )
331331 rel_type = self .token .value or ""
332332 self .set_next_token ()
@@ -450,17 +450,17 @@ def _parse_node(self) -> Optional[Node]:
450450 self .set_next_token ()
451451 self ._skip_whitespace_and_comments ()
452452 identifier : Optional [str ] = None
453- if self .token .is_identifier ():
453+ if self .token .is_identifier_or_keyword ():
454454 identifier = self .token .value
455455 self .set_next_token ()
456456 self ._skip_whitespace_and_comments ()
457457 label : Optional [str ] = None
458458 peek = self .peek ()
459- if not self .token .is_colon () and peek is not None and peek .is_identifier ():
459+ if not self .token .is_colon () and peek is not None and peek .is_identifier_or_keyword ():
460460 raise ValueError ("Expected ':' for node label" )
461- if self .token .is_colon () and (peek is None or not peek .is_identifier ()):
461+ if self .token .is_colon () and (peek is None or not peek .is_identifier_or_keyword ()):
462462 raise ValueError ("Expected node label identifier" )
463- if self .token .is_colon () and peek is not None and peek .is_identifier ():
463+ if self .token .is_colon () and peek is not None and peek .is_identifier_or_keyword ():
464464 self .set_next_token ()
465465 label = cast (str , self .token .value ) # Guaranteed by is_identifier check
466466 self .set_next_token ()
@@ -495,13 +495,13 @@ def _parse_relationship(self) -> Optional[Relationship]:
495495 return None
496496 self .set_next_token ()
497497 variable : Optional [str ] = None
498- if self .token .is_identifier ():
498+ if self .token .is_identifier_or_keyword ():
499499 variable = self .token .value
500500 self .set_next_token ()
501501 if not self .token .is_colon ():
502502 raise ValueError ("Expected ':' for relationship type" )
503503 self .set_next_token ()
504- if not self .token .is_identifier ():
504+ if not self .token .is_identifier_or_keyword ():
505505 raise ValueError ("Expected relationship type identifier" )
506506 rel_type : str = self .token .value or ""
507507 self .set_next_token ()
@@ -633,14 +633,14 @@ def _parse_expressions(
633633 def _parse_operand (self , expression : Expression ) -> bool :
634634 """Parse a single operand (without operators). Returns True if an operand was parsed."""
635635 self ._skip_whitespace_and_comments ()
636- if self .token .is_identifier () and (self .peek () is None or not self .peek ().is_left_parenthesis ()):
636+ if self .token .is_identifier_or_keyword () and (self .peek () is None or not self .peek ().is_left_parenthesis ()):
637637 identifier = self .token .value or ""
638638 reference = Reference (identifier , self ._variables .get (identifier ))
639639 self .set_next_token ()
640640 lookup = self ._parse_lookup (reference )
641641 expression .add_node (lookup )
642642 return True
643- elif self .token .is_identifier () and self .peek () is not None and self .peek ().is_left_parenthesis ():
643+ elif self .token .is_identifier_or_keyword () and self .peek () is not None and self .peek ().is_left_parenthesis ():
644644 func = self ._parse_predicate_function () or self ._parse_function ()
645645 if func is not None :
646646 lookup = self ._parse_lookup (func )
@@ -650,7 +650,7 @@ def _parse_operand(self, expression: Expression) -> bool:
650650 self .token .is_left_parenthesis ()
651651 and self .peek () is not None
652652 and (
653- self .peek ().is_identifier ()
653+ self .peek ().is_identifier_or_keyword ()
654654 or self .peek ().is_colon ()
655655 or self .peek ().is_right_parenthesis ()
656656 )
@@ -734,7 +734,7 @@ def _parse_lookup(self, node: ASTNode) -> ASTNode:
734734 while True :
735735 if self .token .is_dot ():
736736 self .set_next_token ()
737- if not self .token .is_identifier () and not self . token . is_keyword ():
737+ if not self .token .is_identifier_or_keyword ():
738738 raise ValueError ("Expected identifier" )
739739 lookup = Lookup ()
740740 lookup .index = Identifier (self .token .value or "" )
@@ -847,7 +847,7 @@ def _parse_alias(self) -> Optional[Alias]:
847847 self ._expect_previous_token_to_be_whitespace_or_comment ()
848848 self .set_next_token ()
849849 self ._expect_and_skip_whitespace_and_comments ()
850- if not self .token .is_identifier ():
850+ if not self .token .is_identifier_or_keyword ():
851851 raise ValueError ("Expected identifier" )
852852 alias = Alias (self .token .value or "" )
853853 self .set_next_token ()
0 commit comments