@@ -159,16 +159,6 @@ module.exports = grammar({
159
159
// * stab arguments item in `arg1, left when right ->`
160
160
[ $ . binary_operator , $ . _stab_clause_arguments_without_parentheses ] ,
161
161
162
- // Given `( -> • \n`, the newline could be either:
163
- // * stab clause without a body
164
- // * stab clause with a body
165
- [ $ . _stab_clause_without_body , $ . _stab_clause_with_body ] ,
166
-
167
- // Given `( -> • /`, `/` token could be either:
168
- // * stab clause with a body
169
- // * -> as an operator followed by `/`
170
- [ $ . _stab_clause_with_body , $ . operator_identifier ] ,
171
-
172
162
// Given `((arg1, arg2 • ,`, `arg3` expression can be either:
173
163
// * stab parenthesised arguments item in `((arg1, arg2, arg3) ->)`
174
164
// * stab non-parenthesised arguments item in `((arg1, arg2, arg3 ->))`
@@ -739,20 +729,13 @@ module.exports = grammar({
739
729
) ,
740
730
741
731
stab_clause : ( $ ) =>
742
- choice ( $ . _stab_clause_with_body , $ . _stab_clause_without_body ) ,
743
-
744
- _stab_clause_with_body : ( $ ) =>
745
- seq (
746
- optional ( field ( "left" , $ . _stab_clause_left ) ) ,
747
- field ( "operator" , "->" ) ,
748
- field ( "right" , $ . body )
749
- ) ,
750
-
751
- _stab_clause_without_body : ( $ ) =>
752
- seq (
753
- optional ( field ( "left" , $ . _stab_clause_left ) ) ,
754
- field ( "operator" , "->" ) ,
755
- optional ( $ . _terminator )
732
+ // Right precedence, because we want to consume body if any
733
+ prec . right (
734
+ seq (
735
+ optional ( field ( "left" , $ . _stab_clause_left ) ) ,
736
+ field ( "operator" , "->" ) ,
737
+ optional ( field ( "right" , $ . body ) )
738
+ )
756
739
) ,
757
740
758
741
_stab_clause_left : ( $ ) =>
@@ -834,10 +817,13 @@ module.exports = grammar({
834
817
) ,
835
818
836
819
body : ( $ ) =>
837
- seq (
838
- optional ( $ . _terminator ) ,
839
- sep1 ( $ . _expression , $ . _terminator ) ,
840
- optional ( $ . _terminator )
820
+ choice (
821
+ $ . _terminator ,
822
+ seq (
823
+ optional ( $ . _terminator ) ,
824
+ sep1 ( $ . _expression , $ . _terminator ) ,
825
+ optional ( $ . _terminator )
826
+ )
841
827
) ,
842
828
843
829
anonymous_function : ( $ ) =>
0 commit comments