@@ -23,10 +23,10 @@ Nonterminals
23
23
.
24
24
25
25
Terminals
26
- identifier kw_identifier kw_identifier_string bracket_identifier
26
+ identifier kw_identifier kw_identifier_safe kw_identifier_unsafe bracket_identifier
27
27
paren_identifier do_identifier block_identifier
28
28
fn 'end' aliases
29
- number signed_number atom atom_string bin_string list_string sigil
29
+ number signed_number atom atom_safe atom_unsafe bin_string list_string sigil
30
30
dot_call_op op_identifier
31
31
comp_op at_op unary_op and_op or_op arrow_op match_op in_op in_match_op type_op
32
32
dual_op add_op mult_op exp_op two_op pipe_op stab_op when_op assoc_op
@@ -208,7 +208,8 @@ access_expr -> max_expr : '$1'.
208
208
209
209
% % Aliases and properly formed calls. Used by map_expr.
210
210
max_expr -> atom : ? exprs ('$1' ).
211
- max_expr -> atom_string : build_atom_string ('$1' ).
211
+ max_expr -> atom_safe : build_quoted_atom ('$1' , true ).
212
+ max_expr -> atom_unsafe : build_quoted_atom ('$1' , false ).
212
213
max_expr -> parens_call call_args_parens : build_identifier ('$1' , '$2' ).
213
214
max_expr -> parens_call call_args_parens call_args_parens : build_nested_parens ('$1' , '$2' , '$3' ).
214
215
max_expr -> dot_alias : '$1' .
@@ -428,8 +429,10 @@ call_args_parens -> open_paren call_args_parens_base ',' kw close_paren : revers
428
429
429
430
kw_eol -> kw_identifier : ? exprs ('$1' ).
430
431
kw_eol -> kw_identifier eol : ? exprs ('$1' ).
431
- kw_eol -> kw_identifier_string : build_atom_string ('$1' ).
432
- kw_eol -> kw_identifier_string eol : build_atom_string ('$1' ).
432
+ kw_eol -> kw_identifier_safe : build_quoted_atom ('$1' , true ).
433
+ kw_eol -> kw_identifier_safe eol : build_quoted_atom ('$1' , true ).
434
+ kw_eol -> kw_identifier_unsafe : build_quoted_atom ('$1' , false ).
435
+ kw_eol -> kw_identifier_unsafe eol : build_quoted_atom ('$1' , false ).
433
436
434
437
kw_base -> kw_eol container_expr : [{'$1' , '$2' }].
435
438
kw_base -> kw_base ',' kw_eol container_expr : [{'$3' , '$4' }|'$1' ].
@@ -513,7 +516,6 @@ Erlang code.
513
516
-define (line (Node ), element (2 , Node )).
514
517
-define (exprs (Node ), element (3 , Node )).
515
518
-define (rearrange_uop (Op ), (Op == 'not' orelse Op == '!' )).
516
- -define (is_atom_string (Atom ), (Atom == atom_string orelse Atom == kw_identifier_string )).
517
519
518
520
% % The following directive is needed for (significantly) faster
519
521
% % compilation of the generated .erl file by the HiPE compiler
@@ -633,9 +635,9 @@ build_list_string({list_string, Line, Args}) ->
633
635
Meta = meta (Line ),
634
636
{{'.' , Meta , ['Elixir.String' , to_char_list ]}, Meta , [{'<<>>' , Meta , string_parts (Args )}]}.
635
637
636
- build_atom_string ({ Atom , _Line , Safe , [H ]}) when ? is_atom_string ( Atom ) andalso is_binary (H ) ->
638
+ build_quoted_atom ({ _ , _Line , [H ]}, Safe ) when is_binary (H ) ->
637
639
Op = binary_to_atom_op (Safe ), erlang :Op (H , utf8 );
638
- build_atom_string ({ Atom , Line , Safe , Args }) when ? is_atom_string ( Atom ) ->
640
+ build_quoted_atom ({ _ , Line , Args }, Safe ) ->
639
641
Meta = meta (Line ),
640
642
{{'.' , Meta , [erlang , binary_to_atom_op (Safe )]}, Meta , [{'<<>>' , Meta , string_parts (Args )}, utf8 ]}.
641
643
0 commit comments