aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2014-04-22 14:37:00 +0200
committerHans Bolinder <[email protected]>2014-04-28 11:56:42 +0200
commit15c6bea32b05ea1eca612c7637fc3df133937059 (patch)
tree7be144447841a0e6d9db12233dda3f6c5d489d8f
parent146260727638e8a477aeda7828364ce45dc506a0 (diff)
downloadotp-15c6bea32b05ea1eca612c7637fc3df133937059.tar.gz
otp-15c6bea32b05ea1eca612c7637fc3df133937059.tar.bz2
otp-15c6bea32b05ea1eca612c7637fc3df133937059.zip
[syntax_tools] Let erl_syntax:concrete() accept the F/A syntax
Note: `arity_qualifier` nodes are recognized. This is to follow The Erlang Parser when it comes to wild attributes: both {F, A} and F/A are recognized, which makes it possible to turn wild attributes into recognized attributes without at the same time making it impossible to compile files using the new syntax with the old version of the Erlang Compiler.
-rw-r--r--lib/syntax_tools/src/erl_syntax.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl
index f7819c2662..2576d227df 100644
--- a/lib/syntax_tools/src/erl_syntax.erl
+++ b/lib/syntax_tools/src/erl_syntax.erl
@@ -6134,6 +6134,13 @@ abstract_tail(H, T) ->
%% {@link char/1} function to explicitly create an abstract
%% character.)
%%
+%% Note: `arity_qualifier' nodes are recognized. This is to follow The
+%% Erlang Parser when it comes to wild attributes: both {F, A} and F/A
+%% are recognized, which makes it possible to turn wild attributes
+%% into recognized attributes without at the same time making it
+%% impossible to compile files using the new syntax with the old
+%% version of the Erlang Compiler.
+%%
%% @see abstract/1
%% @see is_literal/1
%% @see char/1
@@ -6175,6 +6182,20 @@ concrete(Node) ->
{value, concrete(F), []}
end, [], true),
B;
+ arity_qualifier ->
+ A = erl_syntax:arity_qualifier_argument(Node),
+ case erl_syntax:type(A) of
+ integer ->
+ F = erl_syntax:arity_qualifier_body(Node),
+ case erl_syntax:type(F) of
+ atom ->
+ {F, A};
+ _ ->
+ erlang:error({badarg, Node})
+ end;
+ _ ->
+ erlang:error({badarg, Node})
+ end;
_ ->
erlang:error({badarg, Node})
end.