@@ -2,10 +2,9 @@ Nonterminals
22 grammar expr_list
33 expr paren_expr block_expr fn_expr bracket_expr call_expr bracket_at_expr max_expr
44 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
98 when_op_eol in_op_eol inc_op_eol
109 open_paren close_paren empty_paren
1110 open_bracket close_bracket
@@ -14,7 +13,7 @@ Nonterminals
1413 base_comma_expr comma_expr optional_comma_expr matched_comma_expr
1514 call_args call_args_parens parens_call
1615 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
1817 kw_eol kw_expr kw_comma kw_base
1918 matched_kw_expr matched_kw_comma matched_kw_base
2019 dot_op dot_ref dot_identifier dot_op_identifier dot_do_identifier
@@ -29,26 +28,24 @@ Terminals
2928 fn 'end' aliases
3029 number signed_number atom bin_string list_string sigil
3130 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 ',' '.' '&' '...'
3735 '(' ')' '[' ']' '{' '}' '<<' '>>'
38- '...'
3936 .
4037
4138Rootsymbol grammar .
4239
4340Left 5 do .
44- Right 10 stab_op .
41+ Right 10 stab_op_eol . % % ->
4542Left 20 ',' .
46- Right 30 colon_colon_op .
43+ Right 30 type_op_eol . % % ::
4744Right 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 . % % =
5249Left 130 or_op_eol . % % ||, |||, or, xor
5350Left 140 and_op_eol . % % &&, &&&, and
5451Left 150 comp_op_eol . % % <, >, <=, >=, ==, !=, =~, ===, !==
@@ -98,39 +95,39 @@ unmatched_expr -> unary_op_eol expr : build_unary_op('$1', '$2').
9895unmatched_expr -> at_op_eol expr : build_unary_op ('$1' , '$2' ).
9996unmatched_expr -> block_expr : '$1' .
10097
101- op_expr -> match_op expr : { '$1' , '$2' }.
98+ op_expr -> match_op_eol expr : { '$1' , '$2' }.
10299op_expr -> add_op_eol expr : { '$1' , '$2' }.
103100op_expr -> mult_op_eol expr : { '$1' , '$2' }.
104101op_expr -> exp_op_eol expr : { '$1' , '$2' }.
105102op_expr -> two_op_eol expr : { '$1' , '$2' }.
106103op_expr -> and_op_eol expr : { '$1' , '$2' }.
107104op_expr -> or_op_eol expr : { '$1' , '$2' }.
108- op_expr -> tail_op expr : { '$1' , '$2' }.
105+ op_expr -> tail_op_eol expr : { '$1' , '$2' }.
109106op_expr -> than_op_eol expr : { '$1' , '$2' }.
110107op_expr -> in_op_eol expr : { '$1' , '$2' }.
111108op_expr -> inc_op_eol expr : { '$1' , '$2' }.
112109op_expr -> when_op_eol expr : { '$1' , '$2' }.
113110op_expr -> range_op_eol expr : { '$1' , '$2' }.
114111op_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' }.
116113op_expr -> comp_op_eol expr : { '$1' , '$2' }.
117114op_expr -> arrow_op_eol expr : { '$1' , '$2' }.
118115
119- matched_op_expr -> match_op matched_expr : { '$1' , '$2' }.
116+ matched_op_expr -> match_op_eol matched_expr : { '$1' , '$2' }.
120117matched_op_expr -> add_op_eol matched_expr : { '$1' , '$2' }.
121118matched_op_expr -> mult_op_eol matched_expr : { '$1' , '$2' }.
122119matched_op_expr -> exp_op_eol matched_expr : { '$1' , '$2' }.
123120matched_op_expr -> two_op_eol matched_expr : { '$1' , '$2' }.
124121matched_op_expr -> and_op_eol matched_expr : { '$1' , '$2' }.
125122matched_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' }.
127124matched_op_expr -> than_op_eol matched_expr : { '$1' , '$2' }.
128125matched_op_expr -> in_op_eol matched_expr : { '$1' , '$2' }.
129126matched_op_expr -> inc_op_eol matched_expr : { '$1' , '$2' }.
130127matched_op_expr -> when_op_eol matched_expr : { '$1' , '$2' }.
131128matched_op_expr -> range_op_eol matched_expr : { '$1' , '$2' }.
132129matched_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' }.
134131matched_op_expr -> comp_op_eol matched_expr : { '$1' , '$2' }.
135132matched_op_expr -> arrow_op_eol matched_expr : { '$1' , '$2' }.
136133
@@ -173,15 +170,15 @@ base_expr -> signed_number : { element(4, '$1'), [{line,?line('$1')}], ?exprs('$
173170base_expr -> atom : build_atom ('$1' ).
174171base_expr -> list : '$1' .
175172base_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' ).
179176base_expr -> aliases : { '__aliases__' , [{line ,? line ('$1' )}], ? exprs ('$1' ) }.
180177base_expr -> bin_string : build_bin_string ('$1' ).
181178base_expr -> list_string : build_list_string ('$1' ).
182179base_expr -> bit_string : '$1' .
183180base_expr -> '&' : { '&' , [{line ,? line ('$1' )}], ? exprs ('$1' ) }.
184- base_expr -> '...' : { ? op ('$1' ), [{line ,? line ('$1' )}], [] }.
181+ base_expr -> '...' : { ? id ('$1' ), [{line ,? line ('$1' )}], [] }.
185182base_expr -> sigil : build_sigil ('$1' ).
186183
187184% % Blocks
@@ -210,12 +207,12 @@ stab_eol -> stab : '$1'.
210207stab_eol -> stab eol : '$1' .
211208
212209stab_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 :
215212 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 :
217214 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 :
219216 build_op ('$4' , [{ 'when' , [{line ,? line ('$2' )}], unwrap_splice ('$1' ) ++ ['$3' ] }], '$5' ).
220217
221218stab_maybe_expr -> 'expr' : '$1' .
@@ -272,25 +269,25 @@ two_op_eol -> two_op eol : '$1'.
272269default_op_eol -> default_op : '$1' .
273270default_op_eol -> default_op eol : '$1' .
274271
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' .
277274
278275unary_op_eol -> unary_op : '$1' .
279276unary_op_eol -> unary_op eol : '$1' .
280277unary_op_eol -> dual_op : '$1' .
281278unary_op_eol -> dual_op eol : '$1' .
282279
283- match_op -> '=' : '$1' .
284- match_op -> '=' eol : '$1' .
280+ match_op_eol -> match_op : '$1' .
281+ match_op_eol -> match_op eol : '$1' .
285282
286283and_op_eol -> and_op : '$1' .
287284and_op_eol -> and_op eol : '$1' .
288285
289286or_op_eol -> or_op : '$1' .
290287or_op_eol -> or_op eol : '$1' .
291288
292- tail_op -> '|' : '$1' .
293- tail_op -> '|' eol : '$1' .
289+ tail_op_eol -> tail_op : '$1' .
290+ tail_op_eol -> tail_op eol : '$1' .
294291
295292than_op_eol -> than_op : '$1' .
296293than_op_eol -> than_op eol : '$1' .
@@ -304,8 +301,8 @@ inc_op_eol -> inc_op eol : '$1'.
304301when_op_eol -> when_op : '$1' .
305302when_op_eol -> when_op eol : '$1' .
306303
307- stab_op -> '->' : '$1' .
308- stab_op -> '->' eol : '$1' .
304+ stab_op_eol -> stab_op : '$1' .
305+ stab_op_eol -> stab_op eol : '$1' .
309306
310307range_op_eol -> range_op : '$1' .
311308range_op_eol -> range_op eol : '$1' .
@@ -425,7 +422,7 @@ bit_string -> open_bit call_args close_bit : { '<<>>', [{line,?line('$1')}], '$2
425422
426423Erlang code .
427424
428- -define (op (Node ), element (1 , Node )).
425+ -define (id (Node ), element (1 , Node )).
429426-define (line (Node ), element (2 , Node )).
430427-define (exprs (Node ), element (3 , Node )).
431428
@@ -438,20 +435,14 @@ Erlang code.
438435
439436% % Operators
440437
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 ) ->
445439 { UOp , [{line ,Line }], [{ BOp , [{line ,Line }], [Left , Right ] }] };
446440
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 ] }.
449443
450444build_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 ] }.
455446
456447build_tuple (_Marker , [Left , Right ]) ->
457448 { Left , Right };
@@ -517,7 +508,7 @@ build_fn(Op, Stab) ->
517508
518509build_access (Expr , Access ) ->
519510 Meta = [{line ,? line (Access )}],
520- { { '.' , Meta , ['Elixir.Kernel' , access ] }, Meta , [ Expr , ? op (Access ) ] }.
511+ { { '.' , Meta , ['Elixir.Kernel' , access ] }, Meta , [ Expr , ? id (Access ) ] }.
521512
522513% % Interpolation aware
523514
0 commit comments