diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-10-01 14:55:03 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-10-01 14:55:03 +0200 |
commit | a17f8376290b783f9ea87f0ac4f24289e9e942ba (patch) | |
tree | 74aaf330645f451e9a7d08b657ae6b77c48b7d9f /lib/stdlib/src | |
parent | e2db6bb0e74cd0871fe18f1c23cbb5c5e4cf8d2b (diff) | |
parent | f515622d0ce3a4dd444745f9bee5cb39d5b7f0e8 (diff) | |
download | otp-a17f8376290b783f9ea87f0ac4f24289e9e942ba.tar.gz otp-a17f8376290b783f9ea87f0ac4f24289e9e942ba.tar.bz2 otp-a17f8376290b783f9ea87f0ac4f24289e9e942ba.zip |
Merge branch 'ap/attribute_fun_arity_in_map/OTP-12213' into maint
* ap/attribute_fun_arity_in_map/OTP-12213:
stdlib: Test Map attributes via erl_pp
stdlib: erl_parse abstract Maps
stdlib: Refactor ?line in erl_pp_SUITE:misc_attrs
stdlib: Refactor Maps farity attributes
Allow Name/Arity syntax in maps inside attributes
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/erl_parse.yrl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl index e1ae3b7aea..1d4a2a1fef 100644 --- a/lib/stdlib/src/erl_parse.yrl +++ b/lib/stdlib/src/erl_parse.yrl @@ -753,6 +753,9 @@ attribute_farity({cons,L,H,T}) -> attribute_farity({tuple,L,Args0}) -> Args = attribute_farity_list(Args0), {tuple,L,Args}; +attribute_farity({map,L,Args0}) -> + Args = attribute_farity_map(Args0), + {map,L,Args}; attribute_farity({op,L,'/',{atom,_,_}=Name,{integer,_,_}=Arity}) -> {tuple,L,[Name,Arity]}; attribute_farity(Other) -> Other. @@ -760,6 +763,10 @@ attribute_farity(Other) -> Other. attribute_farity_list(Args) -> [attribute_farity(A) || A <- Args]. +%% It is not meaningful to have farity keys. +attribute_farity_map(Args) -> + [{Op,L,K,attribute_farity(V)} || {Op,L,K,V} <- Args]. + -spec error_bad_decl(integer(), attributes()) -> no_return(). error_bad_decl(L, S) -> @@ -954,7 +961,9 @@ abstract([H|T], L, none=E) -> abstract(List, L, E) when is_list(List) -> abstract_list(List, [], L, E); abstract(Tuple, L, E) when is_tuple(Tuple) -> - {tuple,L,abstract_tuple_list(tuple_to_list(Tuple), L, E)}. + {tuple,L,abstract_tuple_list(tuple_to_list(Tuple), L, E)}; +abstract(Map, L, E) when is_map(Map) -> + {map,L,abstract_map_fields(maps:to_list(Map),L,E)}. abstract_list([H|T], String, L, E) -> case is_integer(H) andalso H >= 0 andalso E(H) of @@ -979,6 +988,9 @@ abstract_tuple_list([H|T], L, E) -> abstract_tuple_list([], _L, _E) -> []. +abstract_map_fields(Fs,L,E) -> + [{map_field_assoc,L,abstract(K,L,E),abstract(V,L,E)}||{K,V}<-Fs]. + abstract_byte(Byte, L) when is_integer(Byte) -> {bin_element, L, {integer, L, Byte}, default, default}; abstract_byte(Bits, L) -> |