@@ -3,15 +3,15 @@ Nonterminals
3
3
expr paren_expr block_expr fn_expr bracket_expr call_expr bracket_at_expr max_expr
4
4
base_expr matched_expr matched_op_expr unmatched_expr op_expr
5
5
add_op mult_op unary_op two_op pipeline_op bin_concat_op
6
- match_op send_op default_op when_op pipe_op in_op inc_op stab_op range_op
6
+ match_op send_op default_op when_op pipe_op in_op inc_op range_op
7
7
andand_op oror_op and_op or_op comp_expr_op colon_colon_op three_op at_op
8
8
open_paren close_paren empty_paren
9
9
open_bracket close_bracket
10
10
open_curly close_curly
11
11
open_bit close_bit
12
12
base_comma_expr comma_expr optional_comma_expr matched_comma_expr
13
13
call_args call_args_parens call_args_parens_not_one call_args_no_parens parens_call
14
- stab_expr stab_expr_list
14
+ stab stab_op stab_expr stab_maybe_expr
15
15
kw_eol kw_expr kw_comma kw_base
16
16
matched_kw_expr matched_kw_comma matched_kw_base
17
17
dot_op dot_ref dot_identifier dot_op_identifier dot_do_identifier
@@ -38,7 +38,7 @@ Terminals
38
38
Rootsymbol grammar .
39
39
40
40
Left 5 do .
41
- Right 10 '->' .
41
+ Right 10 stab_op .
42
42
Left 20 ',' . % Solve nested call_args conflicts
43
43
Right 30 colon_colon_op .
44
44
Right 40 when_op .
@@ -146,8 +146,7 @@ block_expr -> dot_punctuated_identifier call_args_no_parens do_block : build_ide
146
146
block_expr -> dot_do_identifier do_block : build_identifier ('$1' , '$2' ).
147
147
block_expr -> dot_identifier call_args_no_parens do_block : build_identifier ('$1' , '$2' ++ '$3' ).
148
148
149
- fn_expr -> fn_eol stab_expr_list end_eol : build_fn ('$1' , build_stab (lists :reverse ('$2' ))).
150
- fn_expr -> fn_eol '->' grammar 'end' : build_fn ('$1' , { '->' , [{line ,? line ('$2' )}], [{ [], build_block ('$3' ) }] }).
149
+ fn_expr -> fn_eol stab end_eol : build_fn ('$1' , build_stab (lists :reverse ('$2' ))).
151
150
fn_expr -> call_expr : '$1' .
152
151
153
152
call_expr -> dot_punctuated_identifier call_args_no_parens : build_identifier ('$1' , '$2' ).
@@ -163,7 +162,7 @@ max_expr -> parens_call call_args_parens : build_identifier('$1', '$2').
163
162
max_expr -> parens_call call_args_parens call_args_parens : build_nested_parens ('$1' , '$2' , '$3' ).
164
163
max_expr -> dot_ref : '$1' .
165
164
max_expr -> base_expr : '$1' .
166
- max_expr -> open_paren stab_expr_list close_paren : build_stab (lists :reverse ('$2' )).
165
+ max_expr -> open_paren stab close_paren : build_stab (lists :reverse ('$2' )).
167
166
168
167
bracket_expr -> dot_bracket_identifier bracket_access : build_access (build_identifier ('$1' , nil ), '$2' ).
169
168
bracket_expr -> max_expr bracket_access : build_access ('$1' , '$2' ).
@@ -191,9 +190,9 @@ base_expr -> sigil : build_sigil('$1').
191
190
% % Blocks
192
191
193
192
do_block -> do_eol 'end' : [[{do ,nil }]].
194
- do_block -> do_eol stab_expr_list end_eol : [[{ do , build_stab (lists :reverse ('$2' )) }]].
193
+ do_block -> do_eol stab end_eol : [[{ do , build_stab (lists :reverse ('$2' )) }]].
195
194
do_block -> do_eol block_list 'end' : [[{ do , nil }|'$2' ]].
196
- do_block -> do_eol stab_expr_list eol block_list 'end' : [[{ do , build_stab (lists :reverse ('$2' )) }|'$4' ]].
195
+ do_block -> do_eol stab eol block_list 'end' : [[{ do , build_stab (lists :reverse ('$2' )) }|'$4' ]].
197
196
198
197
fn_eol -> 'fn' : '$1' .
199
198
fn_eol -> 'fn' eol : '$1' .
@@ -207,14 +206,18 @@ end_eol -> eol 'end' : '$2'.
207
206
block_eol -> block_identifier : '$1' .
208
207
block_eol -> block_identifier eol : '$1' .
209
208
210
- stab_expr_list -> stab_expr : ['$1' ].
211
- stab_expr_list -> stab_expr_list eol stab_expr : ['$3' |'$1' ].
209
+ stab -> stab_expr : ['$1' ].
210
+ stab -> stab eol stab_expr : ['$3' |'$1' ].
212
211
213
212
stab_expr -> expr : '$1' .
214
- stab_expr -> call_args_no_parens stab_op expr : build_op ('$2' , '$1' , '$3' ).
215
- stab_expr -> call_args_parens_not_one stab_op expr : build_op ('$2' , '$1' , '$3' ).
213
+ stab_expr -> stab_op stab_maybe_expr : build_op ('$1' , [], '$2' ).
214
+ stab_expr -> call_args_no_parens stab_op stab_maybe_expr : build_op ('$2' , '$1' , '$3' ).
215
+ stab_expr -> call_args_parens_not_one stab_op stab_maybe_expr : build_op ('$2' , '$1' , '$3' ).
216
216
217
- block_item -> block_eol stab_expr_list eol : { ? exprs ('$1' ), build_stab (lists :reverse ('$2' )) }.
217
+ stab_maybe_expr -> 'expr' : '$1' .
218
+ stab_maybe_expr -> '$empty' : nil .
219
+
220
+ block_item -> block_eol stab eol : { ? exprs ('$1' ), build_stab (lists :reverse ('$2' )) }.
218
221
block_item -> block_eol : { ? exprs ('$1' ), nil }.
219
222
220
223
block_list -> block_item : ['$1' ].
0 commit comments