aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Tsirulev <[email protected]>2014-08-03 01:58:09 +0400
committerAndrey Tsirulev <[email protected]>2014-08-04 20:35:32 +0400
commit4703b64dc87465e0d505b9997ca5e91f5cb12002 (patch)
treebf646911b97fbb097e0599f97b627cf64a5507b7
parent1b9383a8dbc03473860dfaacc7a02fbc8b1b1185 (diff)
downloadotp-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]}).
-rw-r--r--lib/stdlib/src/erl_parse.yrl11
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) ->