@@ -2,10 +2,9 @@ Nonterminals
2
2
grammar expr_list
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
- match_op tail_op colon_colon_op
6
- comp_op_eol at_op_eol unary_op_eol and_op_eol or_op_eol
7
- add_op_eol mult_op_eol exp_op_eol two_op_eol
8
- arrow_op_eol range_op_eol than_op_eol default_op_eol
5
+ comp_op_eol at_op_eol unary_op_eol and_op_eol or_op_eol tail_op_eol
6
+ add_op_eol mult_op_eol exp_op_eol two_op_eol type_op_eol stab_op_eol
7
+ arrow_op_eol range_op_eol than_op_eol default_op_eol match_op_eol
9
8
when_op_eol in_op_eol inc_op_eol
10
9
open_paren close_paren empty_paren
11
10
open_bracket close_bracket
@@ -14,7 +13,7 @@ Nonterminals
14
13
base_comma_expr comma_expr optional_comma_expr matched_comma_expr
15
14
call_args call_args_parens parens_call
16
15
call_args_no_parens call_args_no_parens_strict call_args_parens_not_one
17
- stab stab_eol stab_op stab_expr stab_maybe_expr
16
+ stab stab_eol stab_expr stab_maybe_expr
18
17
kw_eol kw_expr kw_comma kw_base
19
18
matched_kw_expr matched_kw_comma matched_kw_base
20
19
dot_op dot_ref dot_identifier dot_op_identifier dot_do_identifier
@@ -29,26 +28,24 @@ Terminals
29
28
fn 'end' aliases
30
29
number signed_number atom bin_string list_string sigil
31
30
dot_call_op op_identifier
32
- comp_op at_op unary_op and_op or_op arrow_op
33
- range_op in_op inc_op when_op than_op default_op
34
- dual_op add_op mult_op exp_op two_op
35
- '=' '::' '|' '->'
36
- 'true' 'false' 'nil' 'do' eol ',' '.' '&'
31
+ comp_op at_op unary_op and_op or_op arrow_op match_op
32
+ range_op in_op inc_op when_op than_op default_op tail_op
33
+ dual_op add_op mult_op exp_op two_op type_op stab_op
34
+ 'true' 'false' 'nil' 'do' eol ',' '.' '&' '...'
37
35
'(' ')' '[' ']' '{' '}' '<<' '>>'
38
- '...'
39
36
.
40
37
41
38
Rootsymbol grammar .
42
39
43
40
Left 5 do .
44
- Right 10 stab_op .
41
+ Right 10 stab_op_eol . % % ->
45
42
Left 20 ',' .
46
- Right 30 colon_colon_op .
43
+ Right 30 type_op_eol . % % ::
47
44
Right 40 when_op_eol . % % when
48
- Right 50 default_op_eol . % % //
49
- Left 60 tail_op .
50
- Left 70 inc_op_eol . % % inlist, inbits
51
- Right 80 match_op .
45
+ Left 50 inc_op_eol . % % inlist, inbits
46
+ Right 60 default_op_eol . % % //
47
+ Left 70 tail_op_eol . % % |
48
+ Right 80 match_op_eol . % % =
52
49
Left 130 or_op_eol . % % ||, |||, or, xor
53
50
Left 140 and_op_eol . % % &&, &&&, and
54
51
Left 150 comp_op_eol . % % <, >, <=, >=, ==, !=, =~, ===, !==
@@ -98,39 +95,39 @@ unmatched_expr -> unary_op_eol expr : build_unary_op('$1', '$2').
98
95
unmatched_expr -> at_op_eol expr : build_unary_op ('$1' , '$2' ).
99
96
unmatched_expr -> block_expr : '$1' .
100
97
101
- op_expr -> match_op expr : { '$1' , '$2' }.
98
+ op_expr -> match_op_eol expr : { '$1' , '$2' }.
102
99
op_expr -> add_op_eol expr : { '$1' , '$2' }.
103
100
op_expr -> mult_op_eol expr : { '$1' , '$2' }.
104
101
op_expr -> exp_op_eol expr : { '$1' , '$2' }.
105
102
op_expr -> two_op_eol expr : { '$1' , '$2' }.
106
103
op_expr -> and_op_eol expr : { '$1' , '$2' }.
107
104
op_expr -> or_op_eol expr : { '$1' , '$2' }.
108
- op_expr -> tail_op expr : { '$1' , '$2' }.
105
+ op_expr -> tail_op_eol expr : { '$1' , '$2' }.
109
106
op_expr -> than_op_eol expr : { '$1' , '$2' }.
110
107
op_expr -> in_op_eol expr : { '$1' , '$2' }.
111
108
op_expr -> inc_op_eol expr : { '$1' , '$2' }.
112
109
op_expr -> when_op_eol expr : { '$1' , '$2' }.
113
110
op_expr -> range_op_eol expr : { '$1' , '$2' }.
114
111
op_expr -> default_op_eol expr : { '$1' , '$2' }.
115
- op_expr -> colon_colon_op expr : { '$1' , '$2' }.
112
+ op_expr -> type_op_eol expr : { '$1' , '$2' }.
116
113
op_expr -> comp_op_eol expr : { '$1' , '$2' }.
117
114
op_expr -> arrow_op_eol expr : { '$1' , '$2' }.
118
115
119
- matched_op_expr -> match_op matched_expr : { '$1' , '$2' }.
116
+ matched_op_expr -> match_op_eol matched_expr : { '$1' , '$2' }.
120
117
matched_op_expr -> add_op_eol matched_expr : { '$1' , '$2' }.
121
118
matched_op_expr -> mult_op_eol matched_expr : { '$1' , '$2' }.
122
119
matched_op_expr -> exp_op_eol matched_expr : { '$1' , '$2' }.
123
120
matched_op_expr -> two_op_eol matched_expr : { '$1' , '$2' }.
124
121
matched_op_expr -> and_op_eol matched_expr : { '$1' , '$2' }.
125
122
matched_op_expr -> or_op_eol matched_expr : { '$1' , '$2' }.
126
- matched_op_expr -> tail_op matched_expr : { '$1' , '$2' }.
123
+ matched_op_expr -> tail_op_eol matched_expr : { '$1' , '$2' }.
127
124
matched_op_expr -> than_op_eol matched_expr : { '$1' , '$2' }.
128
125
matched_op_expr -> in_op_eol matched_expr : { '$1' , '$2' }.
129
126
matched_op_expr -> inc_op_eol matched_expr : { '$1' , '$2' }.
130
127
matched_op_expr -> when_op_eol matched_expr : { '$1' , '$2' }.
131
128
matched_op_expr -> range_op_eol matched_expr : { '$1' , '$2' }.
132
129
matched_op_expr -> default_op_eol matched_expr : { '$1' , '$2' }.
133
- matched_op_expr -> colon_colon_op matched_expr : { '$1' , '$2' }.
130
+ matched_op_expr -> type_op_eol matched_expr : { '$1' , '$2' }.
134
131
matched_op_expr -> comp_op_eol matched_expr : { '$1' , '$2' }.
135
132
matched_op_expr -> arrow_op_eol matched_expr : { '$1' , '$2' }.
136
133
@@ -173,15 +170,15 @@ base_expr -> signed_number : { element(4, '$1'), [{line,?line('$1')}], ?exprs('$
173
170
base_expr -> atom : build_atom ('$1' ).
174
171
base_expr -> list : '$1' .
175
172
base_expr -> tuple : '$1' .
176
- base_expr -> 'true' : ? op ('$1' ).
177
- base_expr -> 'false' : ? op ('$1' ).
178
- base_expr -> 'nil' : ? op ('$1' ).
173
+ base_expr -> 'true' : ? id ('$1' ).
174
+ base_expr -> 'false' : ? id ('$1' ).
175
+ base_expr -> 'nil' : ? id ('$1' ).
179
176
base_expr -> aliases : { '__aliases__' , [{line ,? line ('$1' )}], ? exprs ('$1' ) }.
180
177
base_expr -> bin_string : build_bin_string ('$1' ).
181
178
base_expr -> list_string : build_list_string ('$1' ).
182
179
base_expr -> bit_string : '$1' .
183
180
base_expr -> '&' : { '&' , [{line ,? line ('$1' )}], ? exprs ('$1' ) }.
184
- base_expr -> '...' : { ? op ('$1' ), [{line ,? line ('$1' )}], [] }.
181
+ base_expr -> '...' : { ? id ('$1' ), [{line ,? line ('$1' )}], [] }.
185
182
base_expr -> sigil : build_sigil ('$1' ).
186
183
187
184
% % Blocks
@@ -210,12 +207,12 @@ stab_eol -> stab : '$1'.
210
207
stab_eol -> stab eol : '$1' .
211
208
212
209
stab_expr -> expr : '$1' .
213
- stab_expr -> stab_op stab_maybe_expr : build_op ('$1' , [], '$2' ).
214
- stab_expr -> call_args_no_parens stab_op stab_maybe_expr :
210
+ stab_expr -> stab_op_eol stab_maybe_expr : build_op ('$1' , [], '$2' ).
211
+ stab_expr -> call_args_no_parens stab_op_eol stab_maybe_expr :
215
212
build_op ('$2' , unwrap_when (unwrap_splice ('$1' )), '$3' ).
216
- stab_expr -> call_args_parens_not_one stab_op stab_maybe_expr :
213
+ stab_expr -> call_args_parens_not_one stab_op_eol stab_maybe_expr :
217
214
build_op ('$2' , unwrap_splice ('$1' ), '$3' ).
218
- stab_expr -> call_args_parens_not_one when_op matched_expr stab_op stab_maybe_expr :
215
+ stab_expr -> call_args_parens_not_one when_op matched_expr stab_op_eol stab_maybe_expr :
219
216
build_op ('$4' , [{ 'when' , [{line ,? line ('$2' )}], unwrap_splice ('$1' ) ++ ['$3' ] }], '$5' ).
220
217
221
218
stab_maybe_expr -> 'expr' : '$1' .
@@ -272,25 +269,25 @@ two_op_eol -> two_op eol : '$1'.
272
269
default_op_eol -> default_op : '$1' .
273
270
default_op_eol -> default_op eol : '$1' .
274
271
275
- colon_colon_op -> '::' : '$1' .
276
- colon_colon_op -> '::' eol : '$1' .
272
+ type_op_eol -> type_op : '$1' .
273
+ type_op_eol -> type_op eol : '$1' .
277
274
278
275
unary_op_eol -> unary_op : '$1' .
279
276
unary_op_eol -> unary_op eol : '$1' .
280
277
unary_op_eol -> dual_op : '$1' .
281
278
unary_op_eol -> dual_op eol : '$1' .
282
279
283
- match_op -> '=' : '$1' .
284
- match_op -> '=' eol : '$1' .
280
+ match_op_eol -> match_op : '$1' .
281
+ match_op_eol -> match_op eol : '$1' .
285
282
286
283
and_op_eol -> and_op : '$1' .
287
284
and_op_eol -> and_op eol : '$1' .
288
285
289
286
or_op_eol -> or_op : '$1' .
290
287
or_op_eol -> or_op eol : '$1' .
291
288
292
- tail_op -> '|' : '$1' .
293
- tail_op -> '|' eol : '$1' .
289
+ tail_op_eol -> tail_op : '$1' .
290
+ tail_op_eol -> tail_op eol : '$1' .
294
291
295
292
than_op_eol -> than_op : '$1' .
296
293
than_op_eol -> than_op eol : '$1' .
@@ -304,8 +301,8 @@ inc_op_eol -> inc_op eol : '$1'.
304
301
when_op_eol -> when_op : '$1' .
305
302
when_op_eol -> when_op eol : '$1' .
306
303
307
- stab_op -> '->' : '$1' .
308
- stab_op -> '->' eol : '$1' .
304
+ stab_op_eol -> stab_op : '$1' .
305
+ stab_op_eol -> stab_op eol : '$1' .
309
306
310
307
range_op_eol -> range_op : '$1' .
311
308
range_op_eol -> range_op eol : '$1' .
@@ -425,7 +422,7 @@ bit_string -> open_bit call_args close_bit : { '<<>>', [{line,?line('$1')}], '$2
425
422
426
423
Erlang code .
427
424
428
- -define (op (Node ), element (1 , Node )).
425
+ -define (id (Node ), element (1 , Node )).
429
426
-define (line (Node ), element (2 , Node )).
430
427
-define (exprs (Node ), element (3 , Node )).
431
428
@@ -438,20 +435,14 @@ Erlang code.
438
435
439
436
% % Operators
440
437
441
- build_op ({ _ , Line , Op }, Left , Right ) ->
442
- build_op ({ Op , Line }, Left , Right );
443
-
444
- build_op ({ BOp , Line }, { UOp , _ , [Left ] }, Right ) when ? rearrange_bop (BOp ), ? rearrange_uop (UOp ) ->
438
+ build_op ({ _Kind , Line , BOp }, { UOp , _ , [Left ] }, Right ) when ? rearrange_bop (BOp ), ? rearrange_uop (UOp ) ->
445
439
{ UOp , [{line ,Line }], [{ BOp , [{line ,Line }], [Left , Right ] }] };
446
440
447
- build_op (Op , Left , Right ) ->
448
- { ? op ( Op ) , [{line ,? line ( Op ) }], [Left , Right ] }.
441
+ build_op ({ _Kind , Line , Op } , Left , Right ) ->
442
+ { Op , [{line ,Line }], [Left , Right ] }.
449
443
450
444
build_unary_op ({ _Kind , Line , Op }, Expr ) ->
451
- { Op , [{line ,Line }], [Expr ] };
452
-
453
- build_unary_op (Op , Expr ) ->
454
- { ? op (Op ), [{line ,? line (Op )}], [Expr ] }.
445
+ { Op , [{line ,Line }], [Expr ] }.
455
446
456
447
build_tuple (_Marker , [Left , Right ]) ->
457
448
{ Left , Right };
@@ -517,7 +508,7 @@ build_fn(Op, Stab) ->
517
508
518
509
build_access (Expr , Access ) ->
519
510
Meta = [{line ,? line (Access )}],
520
- { { '.' , Meta , ['Elixir.Kernel' , access ] }, Meta , [ Expr , ? op (Access ) ] }.
511
+ { { '.' , Meta , ['Elixir.Kernel' , access ] }, Meta , [ Expr , ? id (Access ) ] }.
521
512
522
513
% % Interpolation aware
523
514
0 commit comments