diff options
author | Andrey Tsirulev <[email protected]> | 2014-08-03 01:58:09 +0400 |
---|---|---|
committer | Andrey Tsirulev <[email protected]> | 2014-08-04 20:35:32 +0400 |
commit | 4703b64dc87465e0d505b9997ca5e91f5cb12002 (patch) | |
tree | bf646911b97fbb097e0599f97b627cf64a5507b7 /lib/stdlib | |
parent | 1b9383a8dbc03473860dfaacc7a02fbc8b1b1185 (diff) | |
download | otp-4703b64dc87465e0d505b9997ca5e91f5cb12002.tar.gz otp-4703b64dc87465e0d505b9997ca5e91f5cb12002.tar.bz2 otp-4703b64dc87465e0d505b9997ca5e91f5cb12002.zip |
Allow Name/Arity syntax in maps inside attributes
Currently Name/Arity syntax is supported in list and tuple terms. This change makes it possible to use this syntax in map terms for consistency and convenience.
Example:
-custom(#{test1 => init/2, test2 => [val/1, val/2]}).
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/erl_parse.yrl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl index e1ae3b7aea..039cc88b9c 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,14 @@ attribute_farity(Other) -> Other. attribute_farity_list(Args) -> [attribute_farity(A) || A <- Args]. +attribute_farity_map(Args) -> + [attribute_farity_map_field(A) || A <- Args]. + +attribute_farity_map_field({map_field_assoc,L,K,V}) -> + {map_field_assoc,L,attribute_farity(K),attribute_farity(V)}; +attribute_farity_map_field({map_field_exact,L,K,V}) -> + {map_field_exact,L,attribute_farity(K),attribute_farity(V)}. + -spec error_bad_decl(integer(), attributes()) -> no_return(). error_bad_decl(L, S) -> |