From e22a2e7beb3337b2096f5bd1cd16fe3877e00d94 Mon Sep 17 00:00:00 2001 From: Richard Carlsson Date: Sat, 21 Apr 2012 00:16:42 +0200 Subject: removed obsolete @spec annotations and fixed some -spec and -type annotations --- lib/syntax_tools/src/erl_syntax.erl | 541 ++---------------------------------- 1 file changed, 23 insertions(+), 518 deletions(-) diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index 67a2b4daa3..a3cc8ba084 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -307,7 +307,7 @@ data/1, is_tree/1]). --export_type([forms/0, syntaxTree/0, syntaxTreeAttributes/0]). +-export_type([forms/0, syntaxTree/0, syntaxTreeAttributes/0, padding/0]). %% ===================================================================== %% IMPLEMENTATION NOTES: @@ -388,11 +388,16 @@ -record(wrapper, {type :: atom(), attr = #attr{} :: #attr{}, - tree :: term()}). + tree :: erl_parse()}). %% ===================================================================== --type syntaxTree() :: #tree{} | #wrapper{} | tuple(). % XXX: refine +-type syntaxTree() :: #tree{} | #wrapper{} | erl_parse(). + +-type erl_parse() :: erl_parse:abstract_form() | erl_parse:abstract_expr(). +%% The representation built by the Erlang standard library parser +%% `erl_parse'. This is a subset of the `syntaxTree' type. %% ===================================================================== %% @@ -402,8 +407,6 @@ %% ===================================================================== -%% @spec type(Node::syntaxTree()) -> atom() -%% %% @doc Returns the type tag of Node. If Node %% does not represent a syntax tree, evaluation fails with reason %% badarg. Node types currently defined by this module are: @@ -604,8 +607,6 @@ type(Node) -> %% ===================================================================== -%% @spec is_leaf(Node::syntaxTree()) -> boolean() -%% %% @doc Returns true if Node is a leaf node, %% otherwise false. The currently recognised leaf node %% types are: @@ -664,8 +665,6 @@ is_leaf(Node) -> %% ===================================================================== -%% @spec is_form(Node::syntaxTree()) -> boolean() -%% %% @doc Returns true if Node is a syntax tree %% representing a so-called "source code form", otherwise %% false. Forms are the Erlang source code units which, @@ -713,8 +712,6 @@ is_form(Node) -> %% ===================================================================== -%% @spec get_pos(Node::syntaxTree()) -> term() -%% %% @doc Returns the position information associated with %% Node. This is usually a nonnegative integer (indicating %% the source code line number), but may be any term. By default, all @@ -748,8 +745,6 @@ get_pos(Node) -> %% ===================================================================== -%% @spec set_pos(Node::syntaxTree(), Pos::term()) -> syntaxTree() -%% %% @doc Sets the position information of Node to %% Pos. %% @@ -772,9 +767,6 @@ set_pos(Node, Pos) -> %% ===================================================================== -%% @spec copy_pos(Source::syntaxTree(), Target::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Copies the position information from Source to %% Target. %% @@ -809,8 +801,6 @@ set_com(Node, Com) -> %% ===================================================================== -%% @spec get_precomments(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the associated pre-comments of a node. This is a %% possibly empty list of abstract comments, in top-down textual order. %% When the code is formatted, pre-comments are typically displayed @@ -844,9 +834,6 @@ get_precomments_1(#attr{com = #com{pre = Cs}}) -> Cs. %% ===================================================================== -%% @spec set_precomments(Node::syntaxTree(), -%% Comments::[syntaxTree()]) -> syntaxTree() -%% %% @doc Sets the pre-comments of Node to %% Comments. Comments should be a possibly %% empty list of abstract comments, in top-down textual order. @@ -878,9 +865,6 @@ set_precomments_1(#attr{com = Com} = Attr, Cs) -> %% ===================================================================== -%% @spec add_precomments(Comments::[syntaxTree()], -%% Node::syntaxTree()) -> syntaxTree() -%% %% @doc Appends Comments to the pre-comments of %% Node. %% @@ -913,8 +897,6 @@ add_precomments_1(Cs, #attr{com = Com} = Attr) -> %% ===================================================================== -%% @spec get_postcomments(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the associated post-comments of a node. This is a %% possibly empty list of abstract comments, in top-down textual order. %% When the code is formatted, post-comments are typically displayed to @@ -948,9 +930,6 @@ get_postcomments_1(#attr{com = #com{post = Cs}}) -> Cs. %% ===================================================================== -%% @spec set_postcomments(Node::syntaxTree(), -%% Comments::[syntaxTree()]) -> syntaxTree() -%% %% @doc Sets the post-comments of Node to %% Comments. Comments should be a possibly %% empty list of abstract comments, in top-down textual order @@ -982,9 +961,6 @@ set_postcomments_1(#attr{com = Com} = Attr, Cs) -> %% ===================================================================== -%% @spec add_postcomments(Comments::[syntaxTree()], -%% Node::syntaxTree()) -> syntaxTree() -%% %% @doc Appends Comments to the post-comments of %% Node. %% @@ -1017,8 +993,6 @@ add_postcomments_1(Cs, #attr{com = Com} = Attr) -> %% ===================================================================== -%% @spec has_comments(Node::syntaxTree()) -> boolean() -%% %% @doc Yields false if the node has no associated %% comments, and true otherwise. %% @@ -1048,8 +1022,6 @@ has_comments(_) -> false. %% ===================================================================== -%% @spec remove_comments(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Clears the associated comments of Node. %% %%

Note: This is equivalent to @@ -1073,9 +1045,6 @@ remove_comments(Node) -> %% ===================================================================== -%% @spec copy_comments(Source::syntaxTree(), Target::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Copies the pre- and postcomments from Source to %% Target. %% @@ -1097,9 +1066,6 @@ copy_comments(Source, Target) -> %% ===================================================================== -%% @spec join_comments(Source::syntaxTree(), Target::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Appends the comments of Source to the current %% comments of Target. %% @@ -1123,8 +1089,6 @@ join_comments(Source, Target) -> %% ===================================================================== -%% @spec get_ann(syntaxTree()) -> [term()] -%% %% @doc Returns the list of user annotations associated with a syntax %% tree node. For a newly created node, this is the empty list. The %% annotations may be any terms. @@ -1140,9 +1104,6 @@ get_ann(_) -> []. %% ===================================================================== -%% @spec set_ann(Node::syntaxTree(), Annotations::[term()]) -> -%% syntaxTree() -%% %% @doc Sets the list of user annotations of Node to %% Annotations. %% @@ -1166,8 +1127,6 @@ set_ann(Node, As) -> %% ===================================================================== -%% @spec add_ann(Annotation::term(), Node::syntaxTree()) -> syntaxTree() -%% %% @doc Appends the term Annotation to the list of user %% annotations of Node. %% @@ -1193,9 +1152,6 @@ add_ann(A, Node) -> %% ===================================================================== -%% @spec copy_ann(Source::syntaxTree(), Target::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Copies the list of user annotations from Source to %% Target. %% @@ -1212,8 +1168,6 @@ copy_ann(Source, Target) -> %% ===================================================================== -%% @spec get_attrs(syntaxTree()) -> syntaxTreeAttributes() -%% %% @doc Returns a representation of the attributes associated with a %% syntax tree node. The attributes are all the extra information that %% can be attached to a node. Currently, this includes position @@ -1245,9 +1199,6 @@ get_attrs(Node) -> #attr{pos = get_pos(Node), %% ===================================================================== -%% @spec set_attrs(Node::syntaxTree(), -%% Attributes::syntaxTreeAttributes()) -> syntaxTree() -%% %% @doc Sets the attributes of Node to %% Attributes. %% @@ -1268,9 +1219,6 @@ set_attrs(Node, Attr) -> %% ===================================================================== -%% @spec copy_attrs(Source::syntaxTree(), Target::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Copies the attributes from Source to %% Target. %% @@ -1287,7 +1235,6 @@ copy_attrs(S, T) -> %% ===================================================================== -%% @spec comment(Strings) -> syntaxTree() %% @equiv comment(none, Strings) -spec comment([string()]) -> syntaxTree(). @@ -1297,9 +1244,6 @@ comment(Strings) -> %% ===================================================================== -%% @spec comment(Padding, Strings::[string()]) -> syntaxTree() -%% Padding = none | integer() -%% %% @doc Creates an abstract comment with the given padding and text. If %% Strings is a (possibly empty) list %% ["Txt1", ..., "TxtN"], the result @@ -1336,8 +1280,6 @@ comment(Pad, Strings) -> %% ===================================================================== -%% @spec comment_text(syntaxTree()) -> [string()] -%% %% @doc Returns the lines of text of the abstract comment. %% %% @see comment/2 @@ -1349,8 +1291,6 @@ comment_text(Node) -> %% ===================================================================== -%% @spec comment_padding(syntaxTree()) -> none | integer() -%% %% @doc Returns the amount of padding before the comment, or %% none. The latter means that a default padding may be %% used. @@ -1364,8 +1304,6 @@ comment_padding(Node) -> %% ===================================================================== -%% @spec form_list(Forms::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract sequence of "source code forms". If %% Forms is [F1, ..., Fn], where each %% Fi is a form (cf. is_form/1, the result @@ -1399,8 +1337,6 @@ form_list(Forms) -> %% ===================================================================== -%% @spec form_list_elements(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of subnodes of a form_list node. %% %% @see form_list/1 @@ -1412,8 +1348,6 @@ form_list_elements(Node) -> %% ===================================================================== -%% @spec flatten_form_list(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Flattens sublists of a form_list node. Returns %% Node with all subtrees of type form_list %% recursively expanded, yielding a single "flat" abstract form @@ -1441,8 +1375,6 @@ flatten_form_list_1([], As) -> %% ===================================================================== -%% @spec text(String::string()) -> syntaxTree() -%% %% @doc Creates an abstract piece of source code text. The result %% represents exactly the sequence of characters in String. %% This is useful in cases when one wants full control of the resulting @@ -1461,8 +1393,6 @@ text(String) -> %% ===================================================================== -%% @spec text_string(syntaxTree()) -> string() -%% %% @doc Returns the character sequence represented by a %% text node. %% @@ -1475,9 +1405,6 @@ text_string(Node) -> %% ===================================================================== -%% @spec variable(Name) -> syntaxTree() -%% Name = atom() | string() -%% %% @doc Creates an abstract variable with the given name. %% Name may be any atom or string that represents a %% lexically valid variable name, but not a single underscore @@ -1515,8 +1442,6 @@ revert_variable(Node) -> %% ===================================================================== -%% @spec variable_name(syntaxTree()) -> atom() -%% %% @doc Returns the name of a variable node as an atom. %% %% @see variable/1 @@ -1533,8 +1458,6 @@ variable_name(Node) -> %% ===================================================================== -%% @spec variable_literal(syntaxTree()) -> string() -%% %% @doc Returns the name of a variable node as a string. %% %% @see variable/1 @@ -1551,8 +1474,6 @@ variable_literal(Node) -> %% ===================================================================== -%% @spec underscore() -> syntaxTree() -%% %% @doc Creates an abstract universal pattern ("_"). The %% lexical representation is a single underscore character. Note that %% this is not a variable, lexically speaking. @@ -1577,8 +1498,6 @@ revert_underscore(Node) -> %% ===================================================================== -%% @spec integer(Value::integer()) -> syntaxTree() -%% %% @doc Creates an abstract integer literal. The lexical representation %% is the canonical decimal numeral of Value. %% @@ -1606,8 +1525,6 @@ revert_integer(Node) -> %% ===================================================================== -%% @spec is_integer(Node::syntaxTree(), Value::integer()) -> boolean() -%% %% @doc Returns true if Node has type %% integer and represents Value, otherwise %% false. @@ -1628,8 +1545,6 @@ is_integer(Node, Value) -> %% ===================================================================== -%% @spec integer_value(syntaxTree()) -> integer() -%% %% @doc Returns the value represented by an integer node. %% %% @see integer/1 @@ -1646,8 +1561,6 @@ integer_value(Node) -> %% ===================================================================== -%% @spec integer_literal(syntaxTree()) -> string() -%% %% @doc Returns the numeral string represented by an %% integer node. %% @@ -1660,8 +1573,6 @@ integer_literal(Node) -> %% ===================================================================== -%% @spec float(Value::float()) -> syntaxTree() -%% %% @doc Creates an abstract floating-point literal. The lexical %% representation is the decimal floating-point numeral of %% Value. @@ -1699,8 +1610,6 @@ revert_float(Node) -> %% ===================================================================== -%% @spec float_value(syntaxTree()) -> float() -%% %% @doc Returns the value represented by a float node. Note %% that floating-point values should usually not be compared for %% equality. @@ -1719,8 +1628,6 @@ float_value(Node) -> %% ===================================================================== -%% @spec float_literal(syntaxTree()) -> string() -%% %% @doc Returns the numeral string represented by a float %% node. %% @@ -1733,8 +1640,6 @@ float_literal(Node) -> %% ===================================================================== -%% @spec char(Value::char()) -> syntaxTree() -%% %% @doc Creates an abstract character literal. The result represents %% "$Name", where Name corresponds to %% Value. @@ -1769,8 +1674,6 @@ revert_char(Node) -> %% ===================================================================== -%% @spec is_char(Node::syntaxTree(), Value::char()) -> boolean() -%% %% @doc Returns true if Node has type %% char and represents Value, otherwise %% false. @@ -1791,8 +1694,6 @@ is_char(Node, Value) -> %% ===================================================================== -%% @spec char_value(syntaxTree()) -> char() -%% %% @doc Returns the value represented by a char node. %% %% @see char/1 @@ -1809,8 +1710,6 @@ char_value(Node) -> %% ===================================================================== -%% @spec char_literal(syntaxTree()) -> string() -%% %% @doc Returns the literal string represented by a char %% node. This includes the leading "$" character. %% @@ -1823,8 +1722,6 @@ char_literal(Node) -> %% ===================================================================== -%% @spec string(Value::string()) -> syntaxTree() -%% %% @doc Creates an abstract string literal. The result represents %% "Text" (including the surrounding %% double-quotes), where Text corresponds to the sequence @@ -1859,8 +1756,6 @@ revert_string(Node) -> %% ===================================================================== -%% @spec is_string(Node::syntaxTree(), Value::string()) -> boolean() -%% %% @doc Returns true if Node has type %% string and represents Value, otherwise %% false. @@ -1881,8 +1776,6 @@ is_string(Node, Value) -> %% ===================================================================== -%% @spec string_value(syntaxTree()) -> string() -%% %% @doc Returns the value represented by a string node. %% %% @see string/1 @@ -1899,8 +1792,6 @@ string_value(Node) -> %% ===================================================================== -%% @spec string_literal(syntaxTree()) -> string() -%% %% @doc Returns the literal string represented by a string %% node. This includes surrounding double-quote characters. %% @@ -1913,9 +1804,6 @@ string_literal(Node) -> %% ===================================================================== -%% @spec atom(Name) -> syntaxTree() -%% Name = atom() | string() -%% %% @doc Creates an abstract atom literal. The print name of the atom is %% the character sequence represented by Name. %% @@ -1946,8 +1834,6 @@ revert_atom(Node) -> %% ===================================================================== -%% @spec is_atom(Node::syntaxTree(), Value::atom()) -> boolean() -%% %% @doc Returns true if Node has type %% atom and represents Value, otherwise %% false. @@ -1968,8 +1854,6 @@ is_atom(Node, Value) -> %% ===================================================================== -%% @spec atom_value(syntaxTree()) -> atom() -%% %% @doc Returns the value represented by an atom node. %% %% @see atom/1 @@ -1986,8 +1870,6 @@ atom_value(Node) -> %% ===================================================================== -%% @spec atom_name(syntaxTree()) -> string() -%% %% @doc Returns the printname of an atom node. %% %% @see atom/1 @@ -1999,8 +1881,6 @@ atom_name(Node) -> %% ===================================================================== -%% @spec atom_literal(syntaxTree()) -> string() -%% %% @doc Returns the literal string represented by an atom %% node. This includes surrounding single-quote characters if necessary. %% @@ -2019,8 +1899,6 @@ atom_literal(Node) -> %% ===================================================================== -%% @spec tuple(Elements::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract tuple. If Elements is %% [X1, ..., Xn], the result represents %% "{X1, ..., Xn}". @@ -2053,8 +1931,6 @@ revert_tuple(Node) -> %% ===================================================================== -%% @spec tuple_elements(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of element subtrees of a tuple %% node. %% @@ -2072,8 +1948,6 @@ tuple_elements(Node) -> %% ===================================================================== -%% @spec tuple_size(syntaxTree()) -> integer() -%% %% @doc Returns the number of elements of a tuple node. %% %%

Note: this is equivalent to @@ -2090,7 +1964,6 @@ tuple_size(Node) -> %% ===================================================================== -%% @spec list(List) -> syntaxTree() %% @equiv list(List, none) -spec list([syntaxTree()]) -> syntaxTree(). @@ -2100,10 +1973,6 @@ list(List) -> %% ===================================================================== -%% @spec list(List, Tail) -> syntaxTree() -%% List = [syntaxTree()] -%% Tail = none | syntaxTree() -%% %% @doc Constructs an abstract list skeleton. The result has type %% list or nil. If List is a %% nonempty list [E1, ..., En], the result has type @@ -2185,8 +2054,6 @@ revert_list(Node) -> S, P). %% ===================================================================== -%% @spec nil() -> syntaxTree() -%% %% @doc Creates an abstract empty list. The result represents %% "[]". The empty list is traditionally called "nil". %% @@ -2211,8 +2078,6 @@ revert_nil(Node) -> %% ===================================================================== -%% @spec list_prefix(Node::syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the prefix element subtrees of a list node. %% If Node represents "[E1, ..., %% En]" or "[E1, ..., En | @@ -2233,8 +2098,6 @@ list_prefix(Node) -> %% ===================================================================== -%% @spec list_suffix(Node::syntaxTree()) -> none | syntaxTree() -%% %% @doc Returns the suffix subtree of a list node, if one %% exists. If Node represents "[E1, ..., %% En | Tail]", the returned value is @@ -2271,8 +2134,6 @@ list_suffix(Node) -> %% ===================================================================== -%% @spec cons(Head::syntaxTree(), Tail::syntaxTree()) -> syntaxTree() -%% %% @doc "Optimising" list skeleton cons operation. Creates an abstract %% list skeleton whose first element is Head and whose tail %% corresponds to Tail. This is similar to @@ -2306,8 +2167,6 @@ cons(Head, Tail) -> %% ===================================================================== -%% @spec list_head(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Returns the head element subtree of a list node. If %% Node represents "[Head ...]", the %% result will represent "Head". @@ -2323,8 +2182,6 @@ list_head(Node) -> %% ===================================================================== -%% @spec list_tail(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Returns the tail of a list node. If %% Node represents a single-element list %% "[E]", then the result has type @@ -2356,8 +2213,6 @@ list_tail(Node) -> %% ===================================================================== -%% @spec is_list_skeleton(syntaxTree()) -> boolean() -%% %% @doc Returns true if Node has type %% list or nil, otherwise false. %% @@ -2375,8 +2230,6 @@ is_list_skeleton(Node) -> %% ===================================================================== -%% @spec is_proper_list(Node::syntaxTree()) -> boolean() -%% %% @doc Returns true if Node represents a %% proper list, and false otherwise. A proper list is a %% list skeleton either on the form "[]" or @@ -2415,8 +2268,6 @@ is_proper_list(Node) -> %% ===================================================================== -%% @spec list_elements(Node::syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of element subtrees of a list skeleton. %% Node must represent a proper list. E.g., if %% Node represents "[X1, X2 | @@ -2448,8 +2299,6 @@ list_elements(Node, As) -> %% ===================================================================== -%% @spec list_length(Node::syntaxTree()) -> integer() -%% %% @doc Returns the number of element subtrees of a list skeleton. %% Node must represent a proper list. E.g., if %% Node represents "[X1 | [X2, X3 | [X4, X5, @@ -2485,8 +2334,6 @@ list_length(Node, A) -> %% ===================================================================== -%% @spec normalize_list(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Expands an abstract list skeleton to its most explicit form. If %% Node represents "[E1, ..., En | %% Tail]", the result represents "[E1 | @@ -2526,8 +2373,6 @@ normalize_list_1(Es, Tail) -> %% ===================================================================== -%% @spec compact_list(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Yields the most compact form for an abstract list skeleton. The %% result either represents "[E1, ..., En | %% Tail]", where Tail is not a list @@ -2573,8 +2418,6 @@ compact_list(Node) -> %% ===================================================================== -%% @spec binary(Fields::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract binary-object template. If %% Fields is [F1, ..., Fn], the result %% represents "<<F1, ..., @@ -2609,8 +2452,6 @@ revert_binary(Node) -> %% ===================================================================== -%% @spec binary_fields(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of field subtrees of a binary %% node. %% @@ -2629,7 +2470,6 @@ binary_fields(Node) -> %% ===================================================================== -%% @spec binary_field(Body) -> syntaxTree() %% @equiv binary_field(Body, []) -spec binary_field(syntaxTree()) -> syntaxTree(). @@ -2639,10 +2479,6 @@ binary_field(Body) -> %% ===================================================================== -%% @spec binary_field(Body::syntaxTree(), Size, -%% Types::[syntaxTree()]) -> syntaxTree() -%% Size = none | syntaxTree() -%% %% @doc Creates an abstract binary template field. %% If Size is none, this is equivalent to %% "binary_field(Body, Types)", otherwise it is @@ -2665,9 +2501,6 @@ binary_field(Body, Size, Types) -> %% ===================================================================== -%% @spec binary_field(Body::syntaxTree(), Types::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract binary template field. If %% Types is the empty list, the result simply represents %% "Body", otherwise, if Types is @@ -2725,8 +2558,6 @@ revert_binary_field(Node) -> %% ===================================================================== -%% @spec binary_field_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a binary_field. %% %% @see binary_field/2 @@ -2747,8 +2578,6 @@ binary_field_body(Node) -> %% ===================================================================== -%% @spec binary_field_types(Node::syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of type-specifier subtrees of a %% binary_field node. If Node represents %% ".../T1, ..., Tn", the result is @@ -2772,8 +2601,6 @@ binary_field_types(Node) -> %% ===================================================================== -%% @spec binary_field_size(Node::syntaxTree()) -> none | syntaxTree() -%% %% @doc Returns the size specifier subtree of a %% binary_field node, if any. If Node %% represents "Body:Size" or @@ -2808,9 +2635,6 @@ binary_field_size(Node) -> %% ===================================================================== -%% @spec size_qualifier(Body::syntaxTree(), Size::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract size qualifier. The result represents %% "Body:Size". %% @@ -2832,8 +2656,6 @@ size_qualifier(Body, Size) -> %% ===================================================================== -%% @spec size_qualifier_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a size_qualifier %% node. %% @@ -2846,8 +2668,6 @@ size_qualifier_body(Node) -> %% ===================================================================== -%% @spec size_qualifier_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument subtree (the size) of a %% size_qualifier node. %% @@ -2860,8 +2680,6 @@ size_qualifier_argument(Node) -> %% ===================================================================== -%% @spec error_marker(Error::term()) -> syntaxTree() -%% %% @doc Creates an abstract error marker. The result represents an %% occurrence of an error in the source code, with an associated Erlang %% I/O ErrorInfo structure given by Error (see module @@ -2900,8 +2718,6 @@ revert_error_marker(Node) -> %% ===================================================================== -%% @spec error_marker_info(syntaxTree()) -> term() -%% %% @doc Returns the ErrorInfo structure of an error_marker %% node. %% @@ -2919,8 +2735,6 @@ error_marker_info(Node) -> %% ===================================================================== -%% @spec warning_marker(Error::term()) -> syntaxTree() -%% %% @doc Creates an abstract warning marker. The result represents an %% occurrence of a possible problem in the source code, with an %% associated Erlang I/O ErrorInfo structure given by Error @@ -2959,8 +2773,6 @@ revert_warning_marker(Node) -> %% ===================================================================== -%% @spec warning_marker_info(syntaxTree()) -> term() -%% %% @doc Returns the ErrorInfo structure of a warning_marker %% node. %% @@ -2978,8 +2790,6 @@ warning_marker_info(Node) -> %% ===================================================================== -%% @spec eof_marker() -> syntaxTree() -%% %% @doc Creates an abstract end-of-file marker. This represents the %% end of input when reading a sequence of source code forms. An %% end-of-file marker is itself regarded as a source code form @@ -3011,7 +2821,6 @@ revert_eof_marker(Node) -> %% ===================================================================== -%% @spec attribute(Name) -> syntaxTree() %% @equiv attribute(Name, none) -spec attribute(syntaxTree()) -> syntaxTree(). @@ -3021,9 +2830,6 @@ attribute(Name) -> %% ===================================================================== -%% @spec attribute(Name::syntaxTree(), Arguments) -> syntaxTree() -%% Arguments = none | [syntaxTree()] -%% %% @doc Creates an abstract program attribute. If %% Arguments is [A1, ..., An], the result %% represents "-Name(A1, ..., @@ -3231,8 +3037,6 @@ revert_module_name(A) -> %% ===================================================================== -%% @spec attribute_name(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the name subtree of an attribute node. %% %% @see attribute/1 @@ -3249,9 +3053,6 @@ attribute_name(Node) -> %% ===================================================================== -%% @spec attribute_arguments(Node::syntaxTree()) -> -%% none | [syntaxTree()] -%% %% @doc Returns the list of argument subtrees of an %% attribute node, if any. If Node %% represents "-Name.", the result is @@ -3324,9 +3125,6 @@ attribute_arguments(Node) -> %% ===================================================================== -%% @spec arity_qualifier(Body::syntaxTree(), Arity::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract arity qualifier. The result represents %% "Body/Arity". %% @@ -3348,8 +3146,6 @@ arity_qualifier(Body, Arity) -> %% ===================================================================== -%% @spec arity_qualifier_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of an arity_qualifier %% node. %% @@ -3362,8 +3158,6 @@ arity_qualifier_body(Node) -> %% ===================================================================== -%% @spec arity_qualifier_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument (the arity) subtree of an %% arity_qualifier node. %% @@ -3376,9 +3170,6 @@ arity_qualifier_argument(Node) -> %% ===================================================================== -%% @spec module_qualifier(Module::syntaxTree(), Body::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract module qualifier. The result represents %% "Module:Body". %% @@ -3412,8 +3203,6 @@ revert_module_qualifier(Node) -> %% ===================================================================== -%% @spec module_qualifier_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument (the module) subtree of a %% module_qualifier node. %% @@ -3431,8 +3220,6 @@ module_qualifier_argument(Node) -> %% ===================================================================== -%% @spec module_qualifier_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a module_qualifier %% node. %% @@ -3450,8 +3237,6 @@ module_qualifier_body(Node) -> %% ===================================================================== -%% @spec qualified_name(Segments::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract qualified name. The result represents %% "S1.S2. ... .Sn", if %% Segments is [S1, S2, ..., Sn]. @@ -3482,8 +3267,6 @@ revert_qualified_name(Node) -> %% ===================================================================== -%% @spec qualified_name_segments(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of name segments of a %% qualified_name node. %% @@ -3501,9 +3284,6 @@ qualified_name_segments(Node) -> %% ===================================================================== -%% @spec function(Name::syntaxTree(), Clauses::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract function definition. If Clauses %% is [C1, ..., Cn], the result represents %% "Name C1; ...; Name @@ -3521,13 +3301,12 @@ qualified_name_segments(Node) -> %% @see is_form/1 %% @see rule/2 --record(function, {name, clauses}). -%% XXX: This one is problematic because there is a tuple with the same -%% tag and size that comes from 'erl_parse' -%% -record(function, {name :: syntaxTree(), clauses :: [syntaxTree()]}). +%% Don't use the name 'function' for this record, to avoid confusion with +%% the tuples on the form {function,Name,Arity} used by erl_parse. +-record(func, {name :: syntaxTree(), clauses :: [syntaxTree()]}). %% type(Node) = function -%% data(Node) = #function{name :: Name, clauses :: Clauses} +%% data(Node) = #func{name :: Name, clauses :: Clauses} %% %% Name = syntaxTree() %% Clauses = [syntaxTree()] @@ -3554,7 +3333,7 @@ qualified_name_segments(Node) -> -spec function(syntaxTree(), [syntaxTree()]) -> syntaxTree(). function(Name, Clauses) -> - tree(function, #function{name = Name, clauses = Clauses}). + tree(function, #func{name = Name, clauses = Clauses}). revert_function(Node) -> Name = function_name(Node), @@ -3570,8 +3349,6 @@ revert_function(Node) -> %% ===================================================================== -%% @spec function_name(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the name subtree of a function node. %% %% @see function/2 @@ -3583,13 +3360,11 @@ function_name(Node) -> {function, Pos, Name, _, _} -> set_pos(atom(Name), Pos); Node1 -> - (data(Node1))#function.name + (data(Node1))#func.name end. %% ===================================================================== -%% @spec function_clauses(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of clause subtrees of a function %% node. %% @@ -3602,13 +3377,11 @@ function_clauses(Node) -> {function, _, _, _, Clauses} -> Clauses; Node1 -> - (data(Node1))#function.clauses + (data(Node1))#func.clauses end. %% ===================================================================== -%% @spec function_arity(Node::syntaxTree()) -> integer() -%% %% @doc Returns the arity of a function node. The result %% is the number of parameter patterns in the first clause of the %% function; subsequent clauses are ignored. @@ -3632,7 +3405,6 @@ function_arity(Node) -> %% ===================================================================== -%% @spec clause(Guard, Body) -> syntaxTree() %% @equiv clause([], Guard, Body) -type guard() :: 'none' | syntaxTree() | [syntaxTree()] | [[syntaxTree()]]. @@ -3644,11 +3416,6 @@ clause(Guard, Body) -> %% ===================================================================== -%% @spec clause(Patterns::[syntaxTree()], Guard, -%% Body::[syntaxTree()]) -> syntaxTree() -%% Guard = none | syntaxTree() -%% | [syntaxTree()] | [[syntaxTree()]] -%% %% @doc Creates an abstract clause. If Patterns is %% [P1, ..., Pn] and Body is [B1, ..., %% Bm], then if Guard is none, the @@ -3787,8 +3554,6 @@ unfold_try_clause({clause, Pos, [{tuple, _, [C, V, _]}], %% ===================================================================== -%% @spec clause_patterns(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of pattern subtrees of a clause %% node. %% @@ -3806,8 +3571,6 @@ clause_patterns(Node) -> %% ===================================================================== -%% @spec clause_guard(Node::syntaxTree()) -> none | syntaxTree() -%% %% @doc Returns the guard subtree of a clause node, if %% any. If Node represents "(P1, ..., %% Pn) when Guard -> B1, ..., @@ -3834,8 +3597,6 @@ clause_guard(Node) -> %% ===================================================================== -%% @spec clause_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Return the list of body subtrees of a clause %% node. %% @@ -3853,8 +3614,6 @@ clause_body(Node) -> %% ===================================================================== -%% @spec disjunction(List::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract disjunction. If List is %% [E1, ..., En], the result represents %% "E1; ...; En". @@ -3872,8 +3631,6 @@ disjunction(Tests) -> %% ===================================================================== -%% @spec disjunction_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of body subtrees of a %% disjunction node. %% @@ -3886,8 +3643,6 @@ disjunction_body(Node) -> %% ===================================================================== -%% @spec conjunction(List::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract conjunction. If List is %% [E1, ..., En], the result represents %% "E1, ..., En". @@ -3905,8 +3660,6 @@ conjunction(Tests) -> %% ===================================================================== -%% @spec conjunction_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of body subtrees of a %% conjunction node. %% @@ -3919,8 +3672,6 @@ conjunction_body(Node) -> %% ===================================================================== -%% @spec catch_expr(Expr::syntaxTree()) -> syntaxTree() -%% %% @doc Creates an abstract catch-expression. The result represents %% "catch Expr". %% @@ -3947,8 +3698,6 @@ revert_catch_expr(Node) -> %% ===================================================================== -%% @spec catch_expr_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a catch_expr node. %% %% @see catch_expr/1 @@ -3965,9 +3714,6 @@ catch_expr_body(Node) -> %% ===================================================================== -%% @spec match_expr(Pattern::syntaxTree(), Body::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract match-expression. The result represents %% "Pattern = Body". %% @@ -4000,8 +3746,6 @@ revert_match_expr(Node) -> %% ===================================================================== -%% @spec match_expr_pattern(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the pattern subtree of a match_expr node. %% %% @see match_expr/2 @@ -4018,8 +3762,6 @@ match_expr_pattern(Node) -> %% ===================================================================== -%% @spec match_expr_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a match_expr node. %% %% @see match_expr/2 @@ -4036,9 +3778,6 @@ match_expr_body(Node) -> %% ===================================================================== -%% @spec operator(Name) -> syntaxTree() -%% Name = atom() | string() -%% %% @doc Creates an abstract operator. The name of the operator is the %% character sequence represented by Name. This is %% analogous to the print name of an atom, but an operator is never @@ -4062,8 +3801,6 @@ operator(Name) -> %% ===================================================================== -%% @spec operator_name(syntaxTree()) -> atom() -%% %% @doc Returns the name of an operator node. Note that %% the name is returned as an atom. %% @@ -4076,8 +3813,6 @@ operator_name(Node) -> %% ===================================================================== -%% @spec operator_literal(syntaxTree()) -> string() -%% %% @doc Returns the literal string represented by an %% operator node. This is simply the operator name as a %% string. @@ -4091,9 +3826,6 @@ operator_literal(Node) -> %% ===================================================================== -%% @spec infix_expr(Left::syntaxTree(), Operator::syntaxTree(), -%% Right::syntaxTree()) -> syntaxTree() -%% %% @doc Creates an abstract infix operator expression. The result %% represents "Left Operator %% Right". @@ -4142,8 +3874,6 @@ revert_infix_expr(Node) -> %% ===================================================================== -%% @spec infix_expr_left(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the left argument subtree of an %% infix_expr node. %% @@ -4161,8 +3891,6 @@ infix_expr_left(Node) -> %% ===================================================================== -%% @spec infix_expr_operator(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the operator subtree of an infix_expr %% node. %% @@ -4180,8 +3908,6 @@ infix_expr_operator(Node) -> %% ===================================================================== -%% @spec infix_expr_right(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the right argument subtree of an %% infix_expr node. %% @@ -4199,9 +3925,6 @@ infix_expr_right(Node) -> %% ===================================================================== -%% @spec prefix_expr(Operator::syntaxTree(), Argument::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract prefix operator expression. The result %% represents "Operator Argument". %% @@ -4245,8 +3968,6 @@ revert_prefix_expr(Node) -> %% ===================================================================== -%% @spec prefix_expr_operator(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the operator subtree of a prefix_expr %% node. %% @@ -4264,8 +3985,6 @@ prefix_expr_operator(Node) -> %% ===================================================================== -%% @spec prefix_expr_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument subtree of a prefix_expr %% node. %% @@ -4283,7 +4002,6 @@ prefix_expr_argument(Node) -> %% ===================================================================== -%% @spec record_field(Name) -> syntaxTree() %% @equiv record_field(Name, none) -spec record_field(syntaxTree()) -> syntaxTree(). @@ -4293,9 +4011,6 @@ record_field(Name) -> %% ===================================================================== -%% @spec record_field(Name::syntaxTree(), Value) -> syntaxTree() -%% Value = none | syntaxTree() -%% %% @doc Creates an abstract record field specification. If %% Value is none, the result represents %% simply "Name", otherwise it represents @@ -4319,8 +4034,6 @@ record_field(Name, Value) -> %% ===================================================================== -%% @spec record_field_name(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the name subtree of a record_field node. %% %% @see record_field/2 @@ -4332,8 +4045,6 @@ record_field_name(Node) -> %% ===================================================================== -%% @spec record_field_value(syntaxTree()) -> none | syntaxTree() -%% %% @doc Returns the value subtree of a record_field node, %% if any. If Node represents %% "Name", none is @@ -4350,9 +4061,6 @@ record_field_value(Node) -> %% ===================================================================== -%% @spec record_index_expr(Type::syntaxTree(), Field::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract record field index expression. The result %% represents "#Type.Field". %% @@ -4397,8 +4105,6 @@ revert_record_index_expr(Node) -> %% ===================================================================== -%% @spec record_index_expr_type(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the type subtree of a record_index_expr %% node. %% @@ -4416,8 +4122,6 @@ record_index_expr_type(Node) -> %% ===================================================================== -%% @spec record_index_expr_field(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the field subtree of a record_index_expr %% node. %% @@ -4435,7 +4139,6 @@ record_index_expr_field(Node) -> %% ===================================================================== -%% @spec record_access(Argument, Field) -> syntaxTree() %% @equiv record_access(Argument, none, Field) -spec record_access(syntaxTree(), syntaxTree()) -> syntaxTree(). @@ -4445,10 +4148,6 @@ record_access(Argument, Field) -> %% ===================================================================== -%% @spec record_access(Argument::syntaxTree(), Type, -%% Field::syntaxTree()) -> syntaxTree() -%% Type = none | syntaxTree() -%% %% @doc Creates an abstract record field access expression. If %% Type is not none, the result represents %% "Argument#Type.Field". @@ -4510,8 +4209,6 @@ revert_record_access(Node) -> %% ===================================================================== -%% @spec record_access_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument subtree of a record_access %% node. %% @@ -4531,8 +4228,6 @@ record_access_argument(Node) -> %% ===================================================================== -%% @spec record_access_type(syntaxTree()) -> none | syntaxTree() -%% %% @doc Returns the type subtree of a record_access node, %% if any. If Node represents %% "Argument.Field", none @@ -4556,8 +4251,6 @@ record_access_type(Node) -> %% ===================================================================== -%% @spec record_access_field(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the field subtree of a record_access %% node. %% @@ -4577,7 +4270,6 @@ record_access_field(Node) -> %% ===================================================================== -%% @spec record_expr(Type, Fields) -> syntaxTree() %% @equiv record_expr(none, Type, Fields) -spec record_expr(syntaxTree(), [syntaxTree()]) -> syntaxTree(). @@ -4587,10 +4279,6 @@ record_expr(Type, Fields) -> %% ===================================================================== -%% @spec record_expr(Argument, Type::syntaxTree(), -%% Fields::[syntaxTree()]) -> syntaxTree() -%% Argument = none | syntaxTree() -%% %% @doc Creates an abstract record expression. If Fields is %% [F1, ..., Fn], then if Argument is %% none, the result represents @@ -4659,8 +4347,6 @@ revert_record_expr(Node) -> %% ===================================================================== -%% @spec record_expr_argument(syntaxTree()) -> none | syntaxTree() -%% %% @doc Returns the argument subtree of a record_expr node, %% if any. If Node represents %% "#Type{...}", none is returned. @@ -4684,8 +4370,6 @@ record_expr_argument(Node) -> %% ===================================================================== -%% @spec record_expr_type(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the type subtree of a record_expr node. %% %% @see record_expr/3 @@ -4704,8 +4388,6 @@ record_expr_type(Node) -> %% ===================================================================== -%% @spec record_expr_fields(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of field subtrees of a %% record_expr node. %% @@ -4725,10 +4407,6 @@ record_expr_fields(Node) -> %% ===================================================================== -%% @spec application(Module, Function::syntaxTree(), -%% Arguments::[syntaxTree()]) -> syntaxTree() -%% Module = none | syntaxTree() -%% %% @doc Creates an abstract function application expression. If %% Module is none, this is call is equivalent %% to application(Function, Arguments), otherwise it is @@ -4750,9 +4428,6 @@ application(Module, Name, Arguments) -> %% ===================================================================== -%% @spec application(Operator::syntaxTree(), -%% Arguments::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract function application expression. If %% Arguments is [A1, ..., An], the result %% represents "Operator(A1, ..., @@ -4792,8 +4467,6 @@ revert_application(Node) -> %% ===================================================================== -%% @spec application_operator(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the operator subtree of an application %% node. %% @@ -4816,8 +4489,6 @@ application_operator(Node) -> %% ===================================================================== -%% @spec application_arguments(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of argument subtrees of an %% application node. %% @@ -4835,9 +4506,6 @@ application_arguments(Node) -> %% ===================================================================== -%% @spec list_comp(Template::syntaxTree(), Body::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract list comprehension. If Body is %% [E1, ..., En], the result represents %% "[Template || E1, ..., En]". @@ -4874,8 +4542,6 @@ revert_list_comp(Node) -> %% ===================================================================== -%% @spec list_comp_template(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the template subtree of a list_comp node. %% %% @see list_comp/2 @@ -4892,8 +4558,6 @@ list_comp_template(Node) -> %% ===================================================================== -%% @spec list_comp_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of body subtrees of a list_comp %% node. %% @@ -4910,9 +4574,6 @@ list_comp_body(Node) -> end. %% ===================================================================== -%% @spec binary_comp(Template::syntaxTree(), Body::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract binary comprehension. If Body is %% [E1, ..., En], the result represents %% "<<Template || E1, ..., En>>". @@ -4949,8 +4610,6 @@ revert_binary_comp(Node) -> %% ===================================================================== -%% @spec binary_comp_template(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the template subtree of a binary_comp node. %% %% @see binary_comp/2 @@ -4967,8 +4626,6 @@ binary_comp_template(Node) -> %% ===================================================================== -%% @spec binary_comp_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of body subtrees of a binary_comp %% node. %% @@ -4986,8 +4643,6 @@ binary_comp_body(Node) -> %% ===================================================================== -%% @spec query_expr(Body::syntaxTree()) -> syntaxTree() -%% %% @doc Creates an abstract Mnemosyne query expression. The result %% represents "query Body end". %% @@ -5016,8 +4671,6 @@ revert_query_expr(Node) -> %% ===================================================================== -%% @spec query_expr_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a query_expr node. %% %% @see query_expr/1 @@ -5034,9 +4687,6 @@ query_expr_body(Node) -> %% ===================================================================== -%% @spec rule(Name::syntaxTree(), Clauses::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract Mnemosyne rule. If Clauses is %% [C1, ..., Cn], the results represents %% "Name C1; ...; Name @@ -5095,8 +4745,6 @@ revert_rule(Node) -> %% ===================================================================== -%% @spec rule_name(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the name subtree of a rule node. %% %% @see rule/2 @@ -5112,8 +4760,6 @@ rule_name(Node) -> end. %% ===================================================================== -%% @spec rule_clauses(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of clause subtrees of a rule node. %% %% @see rule/2 @@ -5129,8 +4775,6 @@ rule_clauses(Node) -> end. %% ===================================================================== -%% @spec rule_arity(Node::syntaxTree()) -> integer() -%% %% @doc Returns the arity of a rule node. The result is the %% number of parameter patterns in the first clause of the rule; %% subsequent clauses are ignored. @@ -5154,9 +4798,6 @@ rule_arity(Node) -> %% ===================================================================== -%% @spec generator(Pattern::syntaxTree(), Body::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract generator. The result represents %% "Pattern <- Body". %% @@ -5191,8 +4832,6 @@ revert_generator(Node) -> %% ===================================================================== -%% @spec generator_pattern(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the pattern subtree of a generator node. %% %% @see generator/2 @@ -5209,8 +4848,6 @@ generator_pattern(Node) -> %% ===================================================================== -%% @spec generator_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a generator node. %% %% @see generator/2 @@ -5227,9 +4864,6 @@ generator_body(Node) -> %% ===================================================================== -%% @spec binary_generator(Pattern::syntaxTree(), Body::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract binary_generator. The result represents %% "Pattern <- Body". %% @@ -5264,8 +4898,6 @@ revert_binary_generator(Node) -> %% ===================================================================== -%% @spec binary_generator_pattern(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the pattern subtree of a generator node. %% %% @see binary_generator/2 @@ -5282,8 +4914,6 @@ binary_generator_pattern(Node) -> %% ===================================================================== -%% @spec binary_generator_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a generator node. %% %% @see binary_generator/2 @@ -5300,8 +4930,6 @@ binary_generator_body(Node) -> %% ===================================================================== -%% @spec block_expr(Body::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract block expression. If Body is %% [B1, ..., Bn], the result represents "begin %% B1, ..., Bn end". @@ -5319,7 +4947,7 @@ binary_generator_body(Node) -> %% %% Body = [erl_parse()] \ [] --spec block_expr(Body::[syntaxTree()]) -> syntaxTree(). +-spec block_expr([syntaxTree()]) -> syntaxTree(). block_expr(Body) -> tree(block_expr, Body). @@ -5331,8 +4959,6 @@ revert_block_expr(Node) -> %% ===================================================================== -%% @spec block_expr_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of body subtrees of a block_expr %% node. %% @@ -5350,8 +4976,6 @@ block_expr_body(Node) -> %% ===================================================================== -%% @spec if_expr(Clauses::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract if-expression. If Clauses is %% [C1, ..., Cn], the result represents "if %% C1; ...; Cn end". More exactly, if each @@ -5390,8 +5014,6 @@ revert_if_expr(Node) -> %% ===================================================================== -%% @spec if_expr_clauses(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of clause subtrees of an if_expr %% node. %% @@ -5409,9 +5031,6 @@ if_expr_clauses(Node) -> %% ===================================================================== -%% @spec case_expr(Argument::syntaxTree(), Clauses::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract case-expression. If Clauses is %% [C1, ..., Cn], the result represents "case %% Argument of C1; ...; Cn end". More @@ -5459,8 +5078,6 @@ revert_case_expr(Node) -> %% ===================================================================== -%% @spec case_expr_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument subtree of a case_expr node. %% %% @see case_expr/2 @@ -5477,8 +5094,6 @@ case_expr_argument(Node) -> %% ===================================================================== -%% @spec case_expr_clauses(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of clause subtrees of a case_expr %% node. %% @@ -5496,8 +5111,6 @@ case_expr_clauses(Node) -> %% ===================================================================== -%% @spec cond_expr(Clauses::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract cond-expression. If Clauses is %% [C1, ..., Cn], the result represents "cond %% C1; ...; Cn end". More exactly, if each @@ -5536,8 +5149,6 @@ revert_cond_expr(Node) -> %% ===================================================================== -%% @spec cond_expr_clauses(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of clause subtrees of a cond_expr %% node. %% @@ -5555,7 +5166,6 @@ cond_expr_clauses(Node) -> %% ===================================================================== -%% @spec receive_expr(Clauses) -> syntaxTree() %% @equiv receive_expr(Clauses, none, []) -spec receive_expr([syntaxTree()]) -> syntaxTree(). @@ -5565,10 +5175,6 @@ receive_expr(Clauses) -> %% ===================================================================== -%% @spec receive_expr(Clauses::[syntaxTree()], Timeout, -%% Action::[syntaxTree()]) -> syntaxTree() -%% Timeout = none | syntaxTree() -%% %% @doc Creates an abstract receive-expression. If Timeout %% is none, the result represents "receive %% C1; ...; Cn end" (the Action @@ -5647,9 +5253,6 @@ revert_receive_expr(Node) -> %% ===================================================================== -%% @spec receive_expr_clauses(syntaxTree()) -> [syntaxTree()] -%% type(Node) = receive_expr -%% %% @doc Returns the list of clause subtrees of a %% receive_expr node. %% @@ -5669,9 +5272,6 @@ receive_expr_clauses(Node) -> %% ===================================================================== -%% @spec receive_expr_timeout(Node::syntaxTree()) -> Timeout -%% Timeout = none | syntaxTree() -%% %% @doc Returns the timeout subtree of a receive_expr node, %% if any. If Node represents "receive C1; %% ...; Cn end", none is returned. @@ -5695,8 +5295,6 @@ receive_expr_timeout(Node) -> %% ===================================================================== -%% @spec receive_expr_action(Node::syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of action body subtrees of a %% receive_expr node. If Node represents %% "receive C1; ...; Cn end", this is the @@ -5718,8 +5316,6 @@ receive_expr_action(Node) -> %% ===================================================================== -%% @spec try_expr(Body::syntaxTree(), Handlers::[syntaxTree()]) -> -%% syntaxTree() %% @equiv try_expr(Body, [], Handlers) -spec try_expr([syntaxTree()], [syntaxTree()]) -> syntaxTree(). @@ -5729,8 +5325,6 @@ try_expr(Body, Handlers) -> %% ===================================================================== -%% @spec try_expr(Body::syntaxTree(), Clauses::[syntaxTree()], -%% Handlers::[syntaxTree()]) -> syntaxTree() %% @equiv try_expr(Body, Clauses, Handlers, []) -spec try_expr([syntaxTree()], [syntaxTree()], [syntaxTree()]) -> syntaxTree(). @@ -5740,8 +5334,6 @@ try_expr(Body, Clauses, Handlers) -> %% ===================================================================== -%% @spec try_after_expr(Body::syntaxTree(), After::[syntaxTree()]) -> -%% syntaxTree() %% @equiv try_expr(Body, [], [], After) -spec try_after_expr([syntaxTree()], [syntaxTree()]) -> syntaxTree(). @@ -5751,10 +5343,6 @@ try_after_expr(Body, After) -> %% ===================================================================== -%% @spec try_expr(Body::[syntaxTree()], Clauses::[syntaxTree()], -%% Handlers::[syntaxTree()], After::[syntaxTree()]) -> -%% syntaxTree() -%% %% @doc Creates an abstract try-expression. If Body is %% [B1, ..., Bn], Clauses is [C1, ..., %% Cj], Handlers is [H1, ..., Hk], and @@ -5832,8 +5420,6 @@ revert_try_expr(Node) -> %% ===================================================================== -%% @spec try_expr_body(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of body subtrees of a try_expr %% node. %% @@ -5851,8 +5437,6 @@ try_expr_body(Node) -> %% ===================================================================== -%% @spec try_expr_clauses(Node::syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of case-clause subtrees of a %% try_expr node. If Node represents %% "try Body catch H1; ...; Hn @@ -5872,8 +5456,6 @@ try_expr_clauses(Node) -> %% ===================================================================== -%% @spec try_expr_handlers(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of handler-clause subtrees of a %% try_expr node. %% @@ -5891,8 +5473,6 @@ try_expr_handlers(Node) -> %% ===================================================================== -%% @spec try_expr_after(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of "after" subtrees of a try_expr %% node. %% @@ -5910,9 +5490,6 @@ try_expr_after(Node) -> %% ===================================================================== -%% @spec class_qualifier(Class::syntaxTree(), Body::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract class qualifier. The result represents %% "Class:Body". %% @@ -5935,8 +5512,6 @@ class_qualifier(Class, Body) -> %% ===================================================================== -%% @spec class_qualifier_argument(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the argument (the class) subtree of a %% class_qualifier node. %% @@ -5949,8 +5524,6 @@ class_qualifier_argument(Node) -> %% ===================================================================== -%% @spec class_qualifier_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a class_qualifier node. %% %% @see class_qualifier/2 @@ -5962,9 +5535,6 @@ class_qualifier_body(Node) -> %% ===================================================================== -%% @spec implicit_fun(Name::syntaxTree(), Arity::syntaxTree()) -> -%% syntaxTree() -%% %% @doc Creates an abstract "implicit fun" expression. If %% Arity is none, this is equivalent to %% implicit_fun(Name), otherwise it is equivalent to @@ -5984,9 +5554,6 @@ implicit_fun(Name, Arity) -> %% ===================================================================== -%% @spec implicit_fun(Module::syntaxTree(), Name::syntaxTree(), -%% Arity::syntaxTree()) -> syntaxTree() -%% %% @doc Creates an abstract module-qualified "implicit fun" expression. %% If Module is none, this is equivalent to %% implicit_fun(Name, Arity), otherwise it is equivalent to @@ -6008,8 +5575,6 @@ implicit_fun(Module, Name, Arity) -> %% ===================================================================== -%% @spec implicit_fun(Name::syntaxTree()) -> syntaxTree() -%% %% @doc Creates an abstract "implicit fun" expression. The result %% represents "fun Name". Name should %% represent either F/A or @@ -6070,8 +5635,6 @@ revert_implicit_fun(Node) -> %% ===================================================================== -%% @spec implicit_fun_name(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Returns the name subtree of an implicit_fun node. %% %%

Note: if Node represents "fun @@ -6108,8 +5671,6 @@ implicit_fun_name(Node) -> %% ===================================================================== -%% @spec fun_expr(Clauses::[syntaxTree()]) -> syntaxTree() -%% %% @doc Creates an abstract fun-expression. If Clauses is %% [C1, ..., Cn], the result represents "fun %% C1; ...; Cn end". More exactly, if each @@ -6150,8 +5711,6 @@ revert_fun_expr(Node) -> %% ===================================================================== -%% @spec fun_expr_clauses(syntaxTree()) -> [syntaxTree()] -%% %% @doc Returns the list of clause subtrees of a fun_expr %% node. %% @@ -6169,8 +5728,6 @@ fun_expr_clauses(Node) -> %% ===================================================================== -%% @spec fun_expr_arity(syntaxTree()) -> integer() -%% %% @doc Returns the arity of a fun_expr node. The result is %% the number of parameter patterns in the first clause of the %% fun-expression; subsequent clauses are ignored. @@ -6192,8 +5749,6 @@ fun_expr_arity(Node) -> %% ===================================================================== -%% @spec parentheses(Body::syntaxTree()) -> syntaxTree() -%% %% @doc Creates an abstract parenthesised expression. The result %% represents "(Body)", independently of the %% context. @@ -6213,8 +5768,6 @@ revert_parentheses(Node) -> %% ===================================================================== -%% @spec parentheses_body(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the body subtree of a parentheses node. %% %% @see parentheses/1 @@ -6226,7 +5779,6 @@ parentheses_body(Node) -> %% ===================================================================== -%% @spec macro(Name) -> syntaxTree() %% @equiv macro(Name, none) -spec macro(syntaxTree()) -> syntaxTree(). @@ -6236,9 +5788,6 @@ macro(Name) -> %% ===================================================================== -%% @spec macro(Name::syntaxTree(), Arguments) -> syntaxTree() -%% Arguments = none | [syntaxTree()] -%% %% @doc Creates an abstract macro application. If Arguments %% is none, the result represents %% "?Name", otherwise, if Arguments @@ -6276,8 +5825,6 @@ macro(Name, Arguments) -> %% ===================================================================== -%% @spec macro_name(syntaxTree()) -> syntaxTree() -%% %% @doc Returns the name subtree of a macro node. %% %% @see macro/2 @@ -6289,8 +5836,6 @@ macro_name(Node) -> %% ===================================================================== -%% @spec macro_arguments(Node::syntaxTree()) -> none | [syntaxTree()] -%% %% @doc Returns the list of argument subtrees of a macro %% node, if any. If Node represents %% "?Name", none is returned. @@ -6307,8 +5852,6 @@ macro_arguments(Node) -> %% ===================================================================== -%% @spec abstract(Term::term()) -> syntaxTree() -%% %% @doc Returns the syntax tree corresponding to an Erlang term. %% Term must be a literal term, i.e., one that can be %% represented as a source code literal. Thus, it may not contain a @@ -6365,8 +5908,6 @@ abstract_tail(H, T) -> %% ===================================================================== -%% @spec concrete(Node::syntaxTree()) -> term() -%% %% @doc Returns the Erlang term represented by a syntax tree. Evaluation %% fails with reason badarg if Node does not %% represent a literal term. @@ -6431,8 +5972,6 @@ concrete_list([]) -> %% ===================================================================== -%% @spec is_literal(Node::syntaxTree()) -> boolean() -%% %% @doc Returns true if Node represents a %% literal term, otherwise false. This function returns %% true if and only if the value of @@ -6467,8 +6006,6 @@ is_literal(T) -> %% ===================================================================== -%% @spec revert(Tree::syntaxTree()) -> syntaxTree() -%% %% @doc Returns an erl_parse-compatible representation of a %% syntax tree, if possible. If Tree represents a %% well-formed Erlang program or expression, the conversion should work @@ -6617,10 +6154,6 @@ revert_root(Node) -> %% ===================================================================== -%% @spec revert_forms(Forms) -> [erl_parse()] -%% -%% Forms = syntaxTree() | [syntaxTree()] -%% %% @doc Reverts a sequence of Erlang source code forms. The sequence can %% be given either as a form_list syntax tree (possibly %% nested), or as a list of "program form" syntax trees. If successful, @@ -6635,10 +6168,10 @@ revert_root(Node) -> -type forms() :: syntaxTree() | [syntaxTree()]. -%% -spec revert_forms(forms()) -> [erl_parse()]. +-spec revert_forms(forms()) -> [erl_parse()]. -revert_forms(L) when is_list(L) -> - revert_forms(form_list(L)); +revert_forms(Forms) when is_list(Forms) -> + revert_forms(form_list(Forms)); revert_forms(T) -> case type(T) of form_list -> @@ -6675,8 +6208,6 @@ revert_forms_1([]) -> %% ===================================================================== -%% @spec subtrees(Node::syntaxTree()) -> [[syntaxTree()]] -%% %% @doc Returns the grouped list of all subtrees of a syntax tree. If %% Node is a leaf node (cf. is_leaf/1), this %% is the empty list, otherwise the result is always a nonempty list, @@ -6898,9 +6429,6 @@ subtrees(T) -> %% ===================================================================== -%% @spec update_tree(Node::syntaxTree(), Groups::[[syntaxTree()]]) -> -%% syntaxTree() -%% %% @doc Creates a syntax tree with the same type and attributes as the %% given tree. This is equivalent to copy_attrs(Node, %% make_tree(type(Node), Groups)). @@ -6916,9 +6444,6 @@ update_tree(Node, Groups) -> %% ===================================================================== -%% @spec make_tree(Type::atom(), Groups::[[syntaxTree()]]) -> -%% syntaxTree() -%% %% @doc Creates a syntax tree with the given type and subtrees. %% Type must be a node type name (cf. type/1) %% that does not denote a leaf node type (cf. is_leaf/1). @@ -6997,8 +6522,6 @@ make_tree(tuple, [E]) -> tuple(E). %% ===================================================================== -%% @spec meta(Tree::syntaxTree()) -> syntaxTree() -%% %% @doc Creates a meta-representation of a syntax tree. The result %% represents an Erlang expression "MetaTree" %% which, if evaluated, will yield a new syntax tree representing the @@ -7163,17 +6686,14 @@ meta_call(F, As) -> %% ===================================================================== -%% @spec tree(Type) -> syntaxTree() %% @equiv tree(Type, []) --spec tree(atom()) -> syntaxTree(). +-spec tree(atom()) -> #tree{}. tree(Type) -> tree(Type, []). %% ===================================================================== -%% @spec tree(Type::atom(), Data::term()) -> syntaxTree() -%% %% @doc For special purposes only. Creates an abstract syntax %% tree node with type tag Type and associated data %% Data. @@ -7202,15 +6722,13 @@ tree(Type) -> %% @see data/1 %% @see type/1 --spec tree(atom(), term()) -> syntaxTree(). +-spec tree(atom(), term()) -> #tree{}. tree(Type, Data) -> #tree{type = Type, data = Data}. %% ===================================================================== -%% @spec is_tree(Tree::syntaxTree()) -> boolean() -%% %% @doc For special purposes only. Returns true if %% Tree is an abstract syntax tree and false %% otherwise. @@ -7229,8 +6747,6 @@ is_tree(_) -> %% ===================================================================== -%% @spec data(Tree::syntaxTree()) -> term() -%% %% @doc For special purposes only. Returns the associated data %% of a syntax tree node. Evaluation fails with reason %% badarg if is_tree(Node) does not yield @@ -7250,13 +6766,6 @@ data(T) -> erlang:error({badarg, T}). %% ===================================================================== -%% @spec wrap(Node::erl_parse()) -> syntaxTree() -%% -%% @type erl_parse() = erl_parse:parse_tree(). The "parse tree" -%% representation built by the Erlang standard library parser -%% erl_parse. This is a subset of the -%% syntaxTree type. -%% %% @doc Creates a wrapper structure around an erl_parse %% "parse tree". %% @@ -7269,7 +6778,7 @@ data(T) -> erlang:error({badarg, T}). %% trees. Attaching a wrapper onto another wrapper structure is an %% error.

-%%-spec wrap(erl_parse:parse_tree()) -> syntaxTree(). +-spec wrap(erl_parse()) -> #wrapper{}. wrap(Node) -> %% We assume that Node is an old-school `erl_parse' tree. @@ -7278,22 +6787,18 @@ wrap(Node) -> %% ===================================================================== -%% @spec unwrap(Node::syntaxTree()) -> syntaxTree() -%% %% @doc Removes any wrapper structure, if present. If Node %% is a wrapper structure, this function returns the wrapped %% erl_parse tree; otherwise it returns Node %% itself. --spec unwrap(syntaxTree()) -> syntaxTree(). +-spec unwrap(syntaxTree()) -> #tree{} | erl_parse(). unwrap(#wrapper{tree = Node}) -> Node; unwrap(Node) -> Node. % This could also be a new-form node. %% ===================================================================== -%% @spec is_wrapper(Term::term()) -> boolean() -%% %% @doc Returns true if the argument is a wrapper %% structure, otherwise false. -- cgit v1.2.3