diff options
author | Hans Bolinder <[email protected]> | 2014-04-28 12:05:38 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2014-04-28 12:05:38 +0200 |
commit | 683a293321b42ff6159637b2e0171c397db9a872 (patch) | |
tree | b7414677fed503f2db33adbc47b1cb44a8e6f23b /lib/syntax_tools/src | |
parent | 3be1dc100140139b2542cd327cf4f8453d43aca1 (diff) | |
parent | eafe7f889a4ff60d9e3155518bda095740efe143 (diff) | |
download | otp-683a293321b42ff6159637b2e0171c397db9a872.tar.gz otp-683a293321b42ff6159637b2e0171c397db9a872.tar.bz2 otp-683a293321b42ff6159637b2e0171c397db9a872.zip |
Merge branch 'hb/optional_callbacks/OTP-11861'
* hb/optional_callbacks/OTP-11861:
[edoc] Handle optional behaviour callbacks
[syntax_tools] Let erl_syntax:concrete() accept the F/A syntax
Introduce the attribute -optional_callbacks in the context of behaviours
Diffstat (limited to 'lib/syntax_tools/src')
-rw-r--r-- | lib/syntax_tools/src/erl_syntax.erl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index c9996c954e..2576d227df 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -3320,6 +3320,11 @@ attribute_arguments(Node) -> [set_pos( list(unfold_function_names(Data, Pos)), Pos)]; + optional_callbacks -> + D = try list(unfold_function_names(Data, Pos)) + catch _:_ -> abstract(Data) + end, + [set_pos(D, Pos)]; import -> {Module, Imports} = Data, [set_pos(atom(Module), Pos), @@ -6129,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 @@ -6170,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. |