@@ -666,7 +666,7 @@ where
666
666
self . parse_fn ( )
667
667
}
668
668
}
669
- fn handle_operation (
669
+ fn handle_operation_left (
670
670
& mut self ,
671
671
once : bool ,
672
672
next : fn ( & mut Self ) -> Checkpoint ,
@@ -684,17 +684,36 @@ where
684
684
}
685
685
checkpoint
686
686
}
687
+ fn handle_operation_right (
688
+ & mut self ,
689
+ once : bool ,
690
+ next : fn ( & mut Self ) -> Checkpoint ,
691
+ ops : & [ SyntaxKind ] ,
692
+ ) -> Checkpoint {
693
+ let checkpoint = next ( self ) ;
694
+ if self . peek ( ) . map ( |t| ops. contains ( & t) ) . unwrap_or ( false ) {
695
+ self . start_node_at ( checkpoint, NODE_BIN_OP ) ;
696
+ self . bump ( ) ;
697
+ if once {
698
+ next ( self ) ;
699
+ } else {
700
+ self . handle_operation_right ( once, next, ops) ;
701
+ }
702
+ self . finish_node ( ) ;
703
+ }
704
+ checkpoint
705
+ }
687
706
fn parse_isset ( & mut self ) -> Checkpoint {
688
- self . handle_operation ( false , Self :: parse_negate, & [ TOKEN_QUESTION ] )
707
+ self . handle_operation_left ( false , Self :: parse_negate, & [ TOKEN_QUESTION ] )
689
708
}
690
709
fn parse_concat ( & mut self ) -> Checkpoint {
691
- self . handle_operation ( false , Self :: parse_isset, & [ TOKEN_CONCAT ] )
710
+ self . handle_operation_right ( false , Self :: parse_isset, & [ TOKEN_CONCAT ] )
692
711
}
693
712
fn parse_mul ( & mut self ) -> Checkpoint {
694
- self . handle_operation ( false , Self :: parse_concat, & [ TOKEN_MUL , TOKEN_DIV ] )
713
+ self . handle_operation_left ( false , Self :: parse_concat, & [ TOKEN_MUL , TOKEN_DIV ] )
695
714
}
696
715
fn parse_add ( & mut self ) -> Checkpoint {
697
- self . handle_operation ( false , Self :: parse_mul, & [ TOKEN_ADD , TOKEN_SUB ] )
716
+ self . handle_operation_left ( false , Self :: parse_mul, & [ TOKEN_ADD , TOKEN_SUB ] )
698
717
}
699
718
fn parse_invert ( & mut self ) -> Checkpoint {
700
719
if self . peek ( ) == Some ( TOKEN_INVERT ) {
@@ -709,26 +728,26 @@ where
709
728
}
710
729
}
711
730
fn parse_merge ( & mut self ) -> Checkpoint {
712
- self . handle_operation ( false , Self :: parse_invert, & [ TOKEN_UPDATE ] )
731
+ self . handle_operation_right ( false , Self :: parse_invert, & [ TOKEN_UPDATE ] )
713
732
}
714
733
fn parse_compare ( & mut self ) -> Checkpoint {
715
- self . handle_operation (
734
+ self . handle_operation_left (
716
735
true ,
717
736
Self :: parse_merge,
718
737
& [ TOKEN_LESS , TOKEN_LESS_OR_EQ , TOKEN_MORE , TOKEN_MORE_OR_EQ ] ,
719
738
)
720
739
}
721
740
fn parse_equal ( & mut self ) -> Checkpoint {
722
- self . handle_operation ( true , Self :: parse_compare, & [ TOKEN_EQUAL , TOKEN_NOT_EQUAL ] )
741
+ self . handle_operation_left ( true , Self :: parse_compare, & [ TOKEN_EQUAL , TOKEN_NOT_EQUAL ] )
723
742
}
724
743
fn parse_and ( & mut self ) -> Checkpoint {
725
- self . handle_operation ( false , Self :: parse_equal, & [ TOKEN_AND ] )
744
+ self . handle_operation_left ( false , Self :: parse_equal, & [ TOKEN_AND ] )
726
745
}
727
746
fn parse_or ( & mut self ) -> Checkpoint {
728
- self . handle_operation ( false , Self :: parse_and, & [ TOKEN_OR ] )
747
+ self . handle_operation_left ( false , Self :: parse_and, & [ TOKEN_OR ] )
729
748
}
730
749
fn parse_implication ( & mut self ) -> Checkpoint {
731
- self . handle_operation ( false , Self :: parse_or, & [ TOKEN_IMPLICATION ] )
750
+ self . handle_operation_right ( false , Self :: parse_or, & [ TOKEN_IMPLICATION ] )
732
751
}
733
752
#[ inline( always) ]
734
753
fn parse_math ( & mut self ) -> Checkpoint {
0 commit comments