diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-10-01 14:56:00 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-10-01 14:56:00 +0200 |
commit | a12de57759fd10317faa8f1c3aa1f3768dea881f (patch) | |
tree | b722bd4c5af0e87f9d7a9b8b3ae2fcc1a2bd62a3 /lib/stdlib/src/erl_parse.yrl | |
parent | 56dcaabbde116e140d5bbb66ed37ca96c0c00b5b (diff) | |
parent | a17f8376290b783f9ea87f0ac4f24289e9e942ba (diff) | |
download | otp-a12de57759fd10317faa8f1c3aa1f3768dea881f.tar.gz otp-a12de57759fd10317faa8f1c3aa1f3768dea881f.tar.bz2 otp-a12de57759fd10317faa8f1c3aa1f3768dea881f.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/stdlib/src/erl_parse.yrl')
-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 a626d98ee4..767b620871 100644 --- a/lib/stdlib/src/erl_parse.yrl +++ b/lib/stdlib/src/erl_parse.yrl @@ -765,6 +765,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. @@ -772,6 +775,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) -> @@ -966,7 +973,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 @@ -991,6 +1000,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) -> |