From ca4633fd683527097451ca1398c90c87bb5c14fc Mon Sep 17 00:00:00 2001
From: Stavros Aronis This module defines an abstract data type for representing Core
-%% Erlang source code as syntax trees. A recommended starting point for the first-time user is the
-%% documentation of the function This module deals with the composition and decomposition of
-%% syntactic entities (as opposed to semantic ones); its
-%% purpose is to hide all direct references to the data structures
-%% used to represent these entities. With few exceptions, the
-%% functions in this module perform no semantic interpretation of
-%% their inputs, and in general, the user is assumed to pass
-%% type-correct arguments - if this is not done, the effects are not
-%% defined. The internal representations of abstract syntax trees are
-%% subject to change without notice, and should not be documented
-%% outside this module. Furthermore, we do not give any guarantees on
-%% how an abstract syntax tree may or may not be represented, with
-%% the following exceptions: no syntax tree is represented by a
-%% single atom, such as Every abstract syntax tree has a type, given by the
-%% function type/1
.NOTES:
-%%
-%% none
, by a list constructor
-%% [X | Y]
, or by the empty list []
. This
-%% can be relied on when writing functions that operate on syntax
-%% trees.type/1
. In addition,
-%% each syntax tree has a list of user annotations (cf. get_ann/1
), which are included
-%% in the Core Erlang syntax.Node
. Current node types
-%% are:
-%%
-%%
-%%
-%% alias
-%% apply
-%% binary
-%% bitstr
-%% call
-%% case
-%% catch
-%%
-%% clause
-%% cons
-%% fun
-%% let
-%% letrec
-%% literal
-%% module
-%%
-%%
-%% primop
-%% receive
-%% seq
-%% try
-%% tuple
-%% values
-%% var
-%%
Note: The name of the primary constructor function for a node
-%% type is always the name of the type itself, prefixed by
-%% "c_
"; recognizer predicates are correspondingly
-%% prefixed by "is_c_
". Furthermore, to simplify
-%% preservation of annotations (cf. get_ann/1
), there are
-%% analogous constructor functions prefixed by "ann_c_
"
-%% and "update_c_
", for setting the annotation list of
-%% the new node to either a specific value or to the annotations of an
-%% existing node, respectively.
true
if Node
is a leaf node,
-%% otherwise false
. The current leaf node types are
-%% literal
and var
.
-%%
-%% Note: all literals (cf. is_literal/1
) are leaf
-%% nodes, even if they represent structured (constant) values such as
-%% {foo, [bar, baz]}
. Also note that variables are leaf
-%% nodes but not literals.
Node
to
-%% Annotations
.
-%%
-%% @see get_ann/1
-%% @see add_ann/2
-%% @see copy_ann/2
-
-set_ann(Node, List) ->
- setelement(2, Node, List).
-
-
-%% @spec add_ann(Annotations::[term()], Node::cerl()) -> cerl()
-%%
-%% @doc Appends Annotations
to the list of user
-%% annotations of Node
.
-%%
-%% Note: this is equivalent to set_ann(Node, Annotations ++
-%% get_ann(Node))
, but potentially more efficient.
Source
-%% to Target
.
-%%
-%% Note: this is equivalent to set_ann(Target,
-%% get_ann(Source))
, but potentially more efficient.
Term
must be a literal term, i.e., one that can be
-%% represented as a source code literal. Thus, it may not contain a
-%% process identifier, port, reference, binary or function value as a
-%% subterm.
-%%
-%% Note: This is a constant time operation.
-%% -%% @see ann_abstract/2 -%% @see concrete/1 -%% @see is_literal/1 -%% @see is_literal_term/1 - -abstract(T) -> - #literal{val = T}. - - -%% @spec ann_abstract(Annotations::[term()], Term::term()) -> cerl() -%% @see abstract/1 - -ann_abstract(As, T) -> - #literal{val = T, ann = As}. - - -%% @spec is_literal_term(Term::term()) -> boolean() -%% -%% @doc Returnstrue
if Term
can be
-%% represented as a literal, otherwise false
. This
-%% function takes time proportional to the size of Term
.
-%%
-%% @see abstract/1
-
-is_literal_term(T) when integer(T) -> true;
-is_literal_term(T) when float(T) -> true;
-is_literal_term(T) when atom(T) -> true;
-is_literal_term([]) -> true;
-is_literal_term([H | T]) ->
- case is_literal_term(H) of
- true ->
- is_literal_term(T);
- false ->
- false
- end;
-is_literal_term(T) when tuple(T) ->
- is_literal_term_list(tuple_to_list(T));
-is_literal_term(_) ->
- false.
-
-is_literal_term_list([T | Ts]) ->
- case is_literal_term(T) of
- true ->
- is_literal_term_list(Ts);
- false ->
- false
- end;
-is_literal_term_list([]) ->
- true.
-
-
-%% @spec concrete(Node::cerl()) -> term()
-%%
-%% @doc Returns the Erlang term represented by a syntax tree. An
-%% exception is thrown if Node
does not represent a
-%% literal term.
-%%
-%% Note: This is a constant time operation.
-%% -%% @see abstract/1 -%% @see is_literal/1 - -%% Because the normal tuple and list constructor operations always -%% return a literal if the arguments are literals, 'concrete' and -%% 'is_literal' never need to traverse the structure. - -concrete(#literal{val = V}) -> - V. - - -%% @spec is_literal(Node::cerl()) -> boolean() -%% -%% @doc Returnstrue
if Node
represents a
-%% literal term, otherwise false
. This function returns
-%% true
if and only if the value of
-%% concrete(Node)
is defined.
-%%
-%% Note: This is a constant time operation.
-%% -%% @see abstract/1 -%% @see concrete/1 -%% @see fold_literal/1 - -is_literal(#literal{}) -> - true; -is_literal(_) -> - false. - - -%% @spec fold_literal(Node::cerl()) -> cerl() -%% -%% @doc Assures that literals have a compact representation. This is -%% occasionally useful ifc_cons_skel/2
,
-%% c_tuple_skel/1
or unfold_literal/1
were
-%% used in the construction of Node
, and you want to revert
-%% to the normal "folded" representation of literals. If
-%% Node
represents a tuple or list constructor, its
-%% elements are rewritten recursively, and the node is reconstructed
-%% using c_cons/2
or c_tuple/1
, respectively;
-%% otherwise, Node
is not changed.
-%%
-%% @see is_literal/1
-%% @see c_cons_skel/2
-%% @see c_tuple_skel/1
-%% @see c_cons/2
-%% @see c_tuple/1
-%% @see unfold_literal/1
-
-fold_literal(Node) ->
- case type(Node) of
- tuple ->
- update_c_tuple(Node, fold_literal_list(tuple_es(Node)));
- cons ->
- update_c_cons(Node, fold_literal(cons_hd(Node)),
- fold_literal(cons_tl(Node)));
- _ ->
- Node
- end.
-
-fold_literal_list([E | Es]) ->
- [fold_literal(E) | fold_literal_list(Es)];
-fold_literal_list([]) ->
- [].
-
-
-%% @spec unfold_literal(Node::cerl()) -> cerl()
-%%
-%% @doc Assures that literals have a fully expanded representation. If
-%% Node
represents a literal tuple or list constructor, its
-%% elements are rewritten recursively, and the node is reconstructed
-%% using c_cons_skel/2
or c_tuple_skel/1
,
-%% respectively; otherwise, Node
is not changed. The {@link
-%% fold_literal/1} can be used to revert to the normal compact
-%% representation.
-%%
-%% @see is_literal/1
-%% @see c_cons_skel/2
-%% @see c_tuple_skel/1
-%% @see c_cons/2
-%% @see c_tuple/1
-%% @see fold_literal/1
-
-unfold_literal(Node) ->
- case type(Node) of
- literal ->
- copy_ann(Node, unfold_concrete(concrete(Node)));
- _ ->
- Node
- end.
-
-unfold_concrete(Val) ->
- case Val of
- _ when tuple(Val) ->
- c_tuple_skel(unfold_concrete_list(tuple_to_list(Val)));
- [H|T] ->
- c_cons_skel(unfold_concrete(H), unfold_concrete(T));
- _ ->
- abstract(Val)
- end.
-
-unfold_concrete_list([E | Es]) ->
- [unfold_concrete(E) | unfold_concrete_list(Es)];
-unfold_concrete_list([]) ->
- [].
-
-
-%% ---------------------------------------------------------------------
-
--record(module, {ann = [], name, exports, attrs, defs}).
-
-
-%% @spec c_module(Name::cerl(), Exports, Definitions) -> cerl()
-%%
-%% Exports = [cerl()]
-%% Definitions = [{cerl(), cerl()}]
-%%
-%% @equiv c_module(Name, Exports, [], Definitions)
-
-c_module(Name, Exports, Es) ->
- #module{name = Name, exports = Exports, attrs = [], defs = Es}.
-
-
-%% @spec c_module(Name::cerl(), Exports, Attributes, Definitions) ->
-%% cerl()
-%%
-%% Exports = [cerl()]
-%% Attributes = [{cerl(), cerl()}]
-%% Definitions = [{cerl(), cerl()}]
-%%
-%% @doc Creates an abstract module definition. The result represents
-%% -%% module Name [E1, ..., Ek] -%% attributes [K1 = T1, ..., -%% Km = Tm] -%% V1 = F1 -%% ... -%% Vn = Fn -%% end-%% -%% if
Exports
= [E1, ..., Ek]
,
-%% Attributes
= [{K1, T1}, ..., {Km, Tm}]
,
-%% and Definitions
= [{V1, F1}, ..., {Vn,
-%% Fn}]
.
-%%
-%% Name
and all the Ki
must be atom
-%% literals, and all the Ti
must be constant literals. All
-%% the Vi
and Ei
must have type
-%% var
and represent function names. All the
-%% Fi
must have type 'fun'
.
true
if Node
is an abstract
-%% module definition, otherwise false
.
-%%
-%% @see type/1
-
-is_c_module(#module{}) ->
- true;
-is_c_module(_) ->
- false.
-
-
-%% @spec module_name(Node::cerl()) -> cerl()
-%%
-%% @doc Returns the name subtree of an abstract module definition.
-%%
-%% @see c_module/4
-
-module_name(Node) ->
- Node#module.name.
-
-
-%% @spec module_exports(Node::cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of exports subtrees of an abstract module
-%% definition.
-%%
-%% @see c_module/4
-
-module_exports(Node) ->
- Node#module.exports.
-
-
-%% @spec module_attrs(Node::cerl()) -> [{cerl(), cerl()}]
-%%
-%% @doc Returns the list of pairs of attribute key/value subtrees of
-%% an abstract module definition.
-%%
-%% @see c_module/4
-
-module_attrs(Node) ->
- Node#module.attrs.
-
-
-%% @spec module_defs(Node::cerl()) -> [{cerl(), cerl()}]
-%%
-%% @doc Returns the list of function definitions of an abstract module
-%% definition.
-%%
-%% @see c_module/4
-
-module_defs(Node) ->
- Node#module.defs.
-
-
-%% @spec module_vars(Node::cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of left-hand side function variable subtrees
-%% of an abstract module definition.
-%%
-%% @see c_module/4
-
-module_vars(Node) ->
- [F || {F, _} <- module_defs(Node)].
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_int(Value::integer()) -> cerl()
-%%
-%%
-%% @doc Creates an abstract integer literal. The lexical
-%% representation is the canonical decimal numeral of
-%% Value
.
-%%
-%% @see ann_c_int/2
-%% @see is_c_int/1
-%% @see int_val/1
-%% @see int_lit/1
-%% @see c_char/1
-
-c_int(Value) ->
- #literal{val = Value}.
-
-
-%% @spec ann_c_int(As::[term()], Value::integer()) -> cerl()
-%% @see c_int/1
-
-ann_c_int(As, Value) ->
- #literal{val = Value, ann = As}.
-
-
-%% @spec is_c_int(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
represents an
-%% integer literal, otherwise false
.
-%% @see c_int/1
-
-is_c_int(#literal{val = V}) when integer(V) ->
- true;
-is_c_int(_) ->
- false.
-
-
-%% @spec int_val(cerl()) -> integer()
-%%
-%% @doc Returns the value represented by an integer literal node.
-%% @see c_int/1
-
-int_val(Node) ->
- Node#literal.val.
-
-
-%% @spec int_lit(cerl()) -> string()
-%%
-%% @doc Returns the numeral string represented by an integer literal
-%% node.
-%% @see c_int/1
-
-int_lit(Node) ->
- integer_to_list(int_val(Node)).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_float(Value::float()) -> cerl()
-%%
-%% @doc Creates an abstract floating-point literal. The lexical
-%% representation is the decimal floating-point numeral of
-%% Value
.
-%%
-%% @see ann_c_float/2
-%% @see is_c_float/1
-%% @see float_val/1
-%% @see float_lit/1
-
-%% Note that not all floating-point numerals can be represented with
-%% full precision.
-
-c_float(Value) ->
- #literal{val = Value}.
-
-
-%% @spec ann_c_float(As::[term()], Value::float()) -> cerl()
-%% @see c_float/1
-
-ann_c_float(As, Value) ->
- #literal{val = Value, ann = As}.
-
-
-%% @spec is_c_float(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
represents a
-%% floating-point literal, otherwise false
.
-%% @see c_float/1
-
-is_c_float(#literal{val = V}) when float(V) ->
- true;
-is_c_float(_) ->
- false.
-
-
-%% @spec float_val(cerl()) -> float()
-%%
-%% @doc Returns the value represented by a floating-point literal
-%% node.
-%% @see c_float/1
-
-float_val(Node) ->
- Node#literal.val.
-
-
-%% @spec float_lit(cerl()) -> string()
-%%
-%% @doc Returns the numeral string represented by a floating-point
-%% literal node.
-%% @see c_float/1
-
-float_lit(Node) ->
- float_to_list(float_val(Node)).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_atom(Name) -> cerl()
-%% Name = atom() | string()
-%%
-%% @doc Creates an abstract atom literal. The print name of the atom
-%% is the character sequence represented by Name
.
-%%
-%% Note: passing a string as argument to this function causes a -%% corresponding atom to be created for the internal representation.
-%% -%% @see ann_c_atom/2 -%% @see is_c_atom/1 -%% @see atom_val/1 -%% @see atom_name/1 -%% @see atom_lit/1 - -c_atom(Name) when atom(Name) -> - #literal{val = Name}; -c_atom(Name) -> - #literal{val = list_to_atom(Name)}. - - -%% @spec ann_c_atom(As::[term()], Name) -> cerl() -%% Name = atom() | string() -%% @see c_atom/1 - -ann_c_atom(As, Name) when atom(Name) -> - #literal{val = Name, ann = As}; -ann_c_atom(As, Name) -> - #literal{val = list_to_atom(Name), ann = As}. - - -%% @spec is_c_atom(Node::cerl()) -> boolean() -%% -%% @doc Returnstrue
if Node
represents an
-%% atom literal, otherwise false
.
-%%
-%% @see c_atom/1
-
-is_c_atom(#literal{val = V}) when atom(V) ->
- true;
-is_c_atom(_) ->
- false.
-
-%% @spec atom_val(cerl())-> atom()
-%%
-%% @doc Returns the value represented by an abstract atom.
-%%
-%% @see c_atom/1
-
-atom_val(Node) ->
- Node#literal.val.
-
-
-%% @spec atom_name(cerl()) -> string()
-%%
-%% @doc Returns the printname of an abstract atom.
-%%
-%% @see c_atom/1
-
-atom_name(Node) ->
- atom_to_list(atom_val(Node)).
-
-
-%% @spec atom_lit(cerl()) -> string()
-%%
-%% @doc Returns the literal string represented by an abstract
-%% atom. This always includes surrounding single-quote characters.
-%%
-%% Note that an abstract atom may have several literal
-%% representations, and that the representation yielded by this
-%% function is not fixed; e.g.,
-%% atom_lit(c_atom("a\012b"))
could yield the string
-%% "\'a\\nb\'"
.
char()
as a subset of
-%% integer()
, this function is equivalent to
-%% c_int/1
. Otherwise, if the given value is an integer,
-%% it will be converted to the character with the corresponding
-%% code. The lexical representation of a character is
-%% "$Char
", where Char
is a single
-%% printing character or an escape sequence.
-%%
-%% @see c_int/1
-%% @see c_string/1
-%% @see ann_c_char/2
-%% @see is_c_char/1
-%% @see char_val/1
-%% @see char_lit/1
-%% @see is_print_char/1
-
-c_char(Value) when integer(Value), Value >= 0 ->
- #literal{val = Value}.
-
-
-%% @spec ann_c_char(As::[term()], Value::char()) -> cerl()
-%% @see c_char/1
-
-ann_c_char(As, Value) ->
- #literal{val = Value, ann = As}.
-
-
-%% @spec is_c_char(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
may represent a
-%% character literal, otherwise false
.
-%%
-%% If the local implementation of Erlang defines
-%% char()
as a subset of integer()
, then
-%% is_c_int(Node)
will also yield
-%% true
.
true
if Node
may represent a
-%% "printing" character, otherwise false
. (Cf.
-%% is_c_char/1
.) A "printing" character has either a
-%% given graphical representation, or a "named" escape sequence such
-%% as "\n
". Currently, only ISO 8859-1 (Latin-1)
-%% character values are recognized.
-%%
-%% @see c_char/1
-%% @see is_c_char/1
-
-is_print_char(#literal{val = V}) when integer(V), V >= 0 ->
- is_print_char_value(V);
-is_print_char(_) ->
- false.
-
-
-%% @spec char_val(cerl()) -> char()
-%%
-%% @doc Returns the value represented by an abstract character literal.
-%%
-%% @see c_char/1
-
-char_val(Node) ->
- Node#literal.val.
-
-
-%% @spec char_lit(cerl()) -> string()
-%%
-%% @doc Returns the literal string represented by an abstract
-%% character. This includes a leading $
-%% character. Currently, all characters that are not in the set of ISO
-%% 8859-1 (Latin-1) "printing" characters will be escaped.
-%%
-%% @see c_char/1
-
-char_lit(Node) ->
- io_lib:write_char(char_val(Node)).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_string(Value::string()) -> cerl()
-%%
-%% @doc Creates an abstract string literal. Equivalent to creating an
-%% abstract list of the corresponding character literals
-%% (cf. is_c_string/1
), but is typically more
-%% efficient. The lexical representation of a string is
-%% ""Chars"
", where Chars
is a
-%% sequence of printing characters or spaces.
-%%
-%% @see c_char/1
-%% @see ann_c_string/2
-%% @see is_c_string/1
-%% @see string_val/1
-%% @see string_lit/1
-%% @see is_print_string/1
-
-c_string(Value) ->
- #literal{val = Value}.
-
-
-%% @spec ann_c_string(As::[term()], Value::string()) -> cerl()
-%% @see c_string/1
-
-ann_c_string(As, Value) ->
- #literal{val = Value, ann = As}.
-
-
-%% @spec is_c_string(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
may represent a
-%% string literal, otherwise false
. Strings are defined
-%% as lists of characters; see is_c_char/1
for details.
-%%
-%% @see c_string/1
-%% @see is_c_char/1
-%% @see is_print_string/1
-
-is_c_string(#literal{val = V}) ->
- is_char_list(V);
-is_c_string(_) ->
- false.
-
-
-%% @spec is_print_string(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
may represent a
-%% string literal containing only "printing" characters, otherwise
-%% false
. See is_c_string/1
and
-%% is_print_char/1
for details. Currently, only ISO
-%% 8859-1 (Latin-1) character values are recognized.
-%%
-%% @see c_string/1
-%% @see is_c_string/1
-%% @see is_print_char/1
-
-is_print_string(#literal{val = V}) ->
- is_print_char_list(V);
-is_print_string(_) ->
- false.
-
-
-%% @spec string_val(cerl()) -> string()
-%%
-%% @doc Returns the value represented by an abstract string literal.
-%%
-%% @see c_string/1
-
-string_val(Node) ->
- Node#literal.val.
-
-
-%% @spec string_lit(cerl()) -> string()
-%%
-%% @doc Returns the literal string represented by an abstract string.
-%% This includes surrounding double-quote characters
-%% "..."
. Currently, characters that are not in the set
-%% of ISO 8859-1 (Latin-1) "printing" characters will be escaped,
-%% except for spaces.
-%%
-%% @see c_string/1
-
-string_lit(Node) ->
- io_lib:write_string(string_val(Node)).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_nil() -> cerl()
-%%
-%% @doc Creates an abstract empty list. The result represents
-%% "[]
". The empty list is traditionally called "nil".
-%%
-%% @see ann_c_nil/1
-%% @see is_c_list/1
-%% @see c_cons/2
-
-c_nil() ->
- #literal{val = []}.
-
-
-%% @spec ann_c_nil(As::[term()]) -> cerl()
-%% @see c_nil/0
-
-ann_c_nil(As) ->
- #literal{val = [], ann = As}.
-
-
-%% @spec is_c_nil(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% empty list, otherwise false
.
-
-is_c_nil(#literal{val = []}) ->
- true;
-is_c_nil(_) ->
- false.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_cons(Head::cerl(), Tail::cerl()) -> cerl()
-%%
-%% @doc Creates an abstract list constructor. The result represents
-%% "[Head | Tail]
". Note that if both
-%% Head
and Tail
have type
-%% literal
, then the result will also have type
-%% literal
, and annotations on Head
and
-%% Tail
are lost.
-%%
-%% Recall that in Erlang, the tail element of a list constructor is -%% not necessarily a list.
-%% -%% @see ann_c_cons/3 -%% @see update_c_cons/3 -%% @see c_cons_skel/2 -%% @see is_c_cons/1 -%% @see cons_hd/1 -%% @see cons_tl/1 -%% @see is_c_list/1 -%% @see c_nil/0 -%% @see list_elements/1 -%% @see list_length/1 -%% @see make_list/2 - --record(cons, {ann = [], hd, tl}). - -%% *Always* collapse literals. - -c_cons(#literal{val = Head}, #literal{val = Tail}) -> - #literal{val = [Head | Tail]}; -c_cons(Head, Tail) -> - #cons{hd = Head, tl = Tail}. - - -%% @spec ann_c_cons(As::[term()], Head::cerl(), Tail::cerl()) -> cerl() -%% @see c_cons/2 - -ann_c_cons(As, #literal{val = Head}, #literal{val = Tail}) -> - #literal{val = [Head | Tail], ann = As}; -ann_c_cons(As, Head, Tail) -> - #cons{hd = Head, tl = Tail, ann = As}. - - -%% @spec update_c_cons(Old::cerl(), Head::cerl(), Tail::cerl()) -> -%% cerl() -%% @see c_cons/2 - -update_c_cons(Node, #literal{val = Head}, #literal{val = Tail}) -> - #literal{val = [Head | Tail], ann = get_ann(Node)}; -update_c_cons(Node, Head, Tail) -> - #cons{hd = Head, tl = Tail, ann = get_ann(Node)}. - - -%% @spec c_cons_skel(Head::cerl(), Tail::cerl()) -> cerl() -%% -%% @doc Creates an abstract list constructor skeleton. Does not fold -%% constant literals, i.e., the result always has type -%%cons
, representing "[Head |
-%% Tail]
".
-%%
-%% This function is occasionally useful when it is necessary to have
-%% annotations on the subnodes of a list constructor node, even when the
-%% subnodes are constant literals. Note however that
-%% is_literal/1
will yield false
and
-%% concrete/1
will fail if passed the result from this
-%% function.
fold_literal/1
can be used to revert a node to the
-%% normal-form representation.
true
if Node
is an abstract
-%% list constructor, otherwise false
.
-
-is_c_cons(#cons{}) ->
- true;
-is_c_cons(#literal{val = [_ | _]}) ->
- true;
-is_c_cons(_) ->
- false.
-
-
-%% @spec cons_hd(cerl()) -> cerl()
-%%
-%% @doc Returns the head subtree of an abstract list constructor.
-%%
-%% @see c_cons/2
-
-cons_hd(#cons{hd = Head}) ->
- Head;
-cons_hd(#literal{val = [Head | _]}) ->
- #literal{val = Head}.
-
-
-%% @spec cons_tl(cerl()) -> cerl()
-%%
-%% @doc Returns the tail subtree of an abstract list constructor.
-%%
-%% Recall that the tail does not necessarily represent a proper -%% list.
-%% -%% @see c_cons/2 - -cons_tl(#cons{tl = Tail}) -> - Tail; -cons_tl(#literal{val = [_ | Tail]}) -> - #literal{val = Tail}. - - -%% @spec is_c_list(Node::cerl()) -> boolean() -%% -%% @doc Returnstrue
if Node
represents a
-%% proper list, otherwise false
. A proper list is either
-%% the empty list []
, or a cons cell [Head |
-%% Tail]
, where recursively Tail
is a
-%% proper list.
-%%
-%% Note: Because Node
is a syntax tree, the actual
-%% run-time values corresponding to its subtrees may often be partially
-%% or completely unknown. Thus, if Node
represents e.g.
-%% "[... | Ns]
" (where Ns
is a variable), then
-%% the function will return false
, because it is not known
-%% whether Ns
will be bound to a list at run-time. If
-%% Node
instead represents e.g. "[1, 2, 3]
" or
-%% "[A | []]
", then the function will return
-%% true
.
Node
must represent a proper list. E.g., if
-%% Node
represents "[X1, X2 |
-%% [X3, X4 | []]
", then
-%% list_elements(Node)
yields the list [X1, X2, X3,
-%% X4]
.
-%%
-%% @see c_cons/2
-%% @see c_nil/1
-%% @see is_c_list/1
-%% @see list_length/1
-%% @see make_list/2
-
-list_elements(#cons{hd = Head, tl = Tail}) ->
- [Head | list_elements(Tail)];
-list_elements(#literal{val = V}) ->
- abstract_list(V).
-
-abstract_list([X | Xs]) ->
- [abstract(X) | abstract_list(Xs)];
-abstract_list([]) ->
- [].
-
-
-%% @spec list_length(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of element subtrees of an abstract list.
-%% Node
must represent a proper list. E.g., if
-%% Node
represents "[X1 | [X2, X3 | [X4, X5,
-%% X6]]]
", then list_length(Node)
returns the
-%% integer 6.
-%%
-%% Note: this is equivalent to
-%% length(list_elements(Node))
, but potentially more
-%% efficient.
List
-%% and the optional Tail
. If Tail
is
-%% none
, the result will represent a nil-terminated list,
-%% otherwise it represents "[... | Tail]
".
-%%
-%% @see c_cons/2
-%% @see c_nil/0
-%% @see ann_make_list/3
-%% @see update_list/3
-%% @see list_elements/1
-
-make_list(List, Tail) ->
- ann_make_list([], List, Tail).
-
-
-%% @spec update_list(Old::cerl(), List::[cerl()]) -> cerl()
-%% @equiv update_list(Old, List, none)
-
-update_list(Node, List) ->
- ann_make_list(get_ann(Node), List).
-
-
-%% @spec update_list(Old::cerl(), List::[cerl()], Tail) -> cerl()
-%%
-%% Tail = cerl() | none
-%%
-%% @see make_list/2
-%% @see update_list/2
-
-update_list(Node, List, Tail) ->
- ann_make_list(get_ann(Node), List, Tail).
-
-
-%% @spec ann_make_list(As::[term()], List::[cerl()]) -> cerl()
-%% @equiv ann_make_list(As, List, none)
-
-ann_make_list(As, List) ->
- ann_make_list(As, List, none).
-
-
-%% @spec ann_make_list(As::[term()], List::[cerl()], Tail) -> cerl()
-%%
-%% Tail = cerl() | none
-%%
-%% @see make_list/2
-%% @see ann_make_list/2
-
-ann_make_list(As, [H | T], Tail) ->
- ann_c_cons(As, H, make_list(T, Tail)); % `c_cons' folds literals
-ann_make_list(As, [], none) ->
- ann_c_nil(As);
-ann_make_list(_, [], Node) ->
- Node.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_tuple(Elements::[cerl()]) -> cerl()
-%%
-%% @doc Creates an abstract tuple. If Elements
is
-%% [E1, ..., En]
, the result represents
-%% "{E1, ..., En}
". Note that if all
-%% nodes in Elements
have type literal
, or if
-%% Elements
is empty, then the result will also have type
-%% literal
and annotations on nodes in
-%% Elements
are lost.
-%%
-%% Recall that Erlang has distinct 1-tuples, i.e., {X}
-%% is always distinct from X
itself.
tuple
,
-%% representing "{E1, ..., En}
", if
-%% Elements
is [E1, ..., En]
.
-%%
-%% This function is occasionally useful when it is necessary to have
-%% annotations on the subnodes of a tuple node, even when all the
-%% subnodes are constant literals. Note however that
-%% is_literal/1
will yield false
and
-%% concrete/1
will fail if passed the result from this
-%% function.
fold_literal/1
can be used to revert a node to the
-%% normal-form representation.
true
if Node
is an abstract
-%% tuple, otherwise false
.
-%%
-%% @see c_tuple/1
-
-is_c_tuple(#tuple{}) ->
- true;
-is_c_tuple(#literal{val = V}) when tuple(V) ->
- true;
-is_c_tuple(_) ->
- false.
-
-
-%% @spec tuple_es(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of element subtrees of an abstract tuple.
-%%
-%% @see c_tuple/1
-
-tuple_es(#tuple{es = Es}) ->
- Es;
-tuple_es(#literal{val = V}) ->
- make_lit_list(tuple_to_list(V)).
-
-
-%% @spec tuple_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of element subtrees of an abstract tuple.
-%%
-%% Note: this is equivalent to length(tuple_es(Node))
,
-%% but potentially more efficient.
Name
parameter.
-%%
-%% If a name is given by a single atom, it should either be a
-%% "simple" atom which does not need to be single-quoted in Erlang, or
-%% otherwise its print name should correspond to a proper Erlang
-%% variable, i.e., begin with an uppercase character or an
-%% underscore. Names on the form {A, N}
represent
-%% function name variables "A/N
"; these
-%% are special variables which may be bound only in the function
-%% definitions of a module or a letrec
. They may not be
-%% bound in let
expressions and cannot occur in clause
-%% patterns. The atom A
in a function name may be any
-%% atom; the integer N
must be nonnegative. The functions
-%% c_fname/2
etc. are utilities for handling function
-%% name variables.
When printing variable names, they must have the form of proper
-%% Core Erlang variables and function names. E.g., a name represented
-%% by an integer such as 42
could be formatted as
-%% "_42
", an atom 'Xxx'
simply as
-%% "Xxx
", and an atom foo
as
-%% "_foo
". However, one must assure that any two valid
-%% distinct names are never mapped to the same strings. Tuples such
-%% as {foo, 2}
representing function names can simply by
-%% formatted as "'foo'/2
", with no risk of conflicts.
true
if Node
is an abstract
-%% variable, otherwise false
.
-%%
-%% @see c_var/1
-
-is_c_var(#var{}) ->
- true;
-is_c_var(_) ->
- false.
-
-
-%% @spec c_fname(Name::atom(), Arity::integer()) -> cerl()
-%% @equiv c_var({Name, Arity})
-%% @see fname_id/1
-%% @see fname_arity/1
-%% @see is_c_fname/1
-%% @see ann_c_fname/3
-%% @see update_c_fname/3
-
-c_fname(Atom, Arity) ->
- c_var({Atom, Arity}).
-
-
-%% @spec ann_c_fname(As::[term()], Name::atom(), Arity::integer()) ->
-%% cerl()
-%% @equiv ann_c_var(As, {Atom, Arity})
-%% @see c_fname/2
-
-ann_c_fname(As, Atom, Arity) ->
- ann_c_var(As, {Atom, Arity}).
-
-
-%% @spec update_c_fname(Old::cerl(), Name::atom()) -> cerl()
-%% @doc Like update_c_fname/3
, but takes the arity from
-%% Node
.
-%% @see update_c_fname/3
-%% @see c_fname/2
-
-update_c_fname(#var{name = {_, Arity}, ann = As}, Atom) ->
- #var{name = {Atom, Arity}, ann = As}.
-
-
-%% @spec update_c_fname(Old::cerl(), Name::atom(), Arity::integer()) ->
-%% cerl()
-%% @equiv update_c_var(Old, {Atom, Arity})
-%% @see update_c_fname/2
-%% @see c_fname/2
-
-update_c_fname(Node, Atom, Arity) ->
- update_c_var(Node, {Atom, Arity}).
-
-
-%% @spec is_c_fname(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% function name variable, otherwise false
.
-%%
-%% @see c_fname/2
-%% @see c_var/1
-%% @see c_var_name/1
-
-is_c_fname(#var{name = {A, N}}) when atom(A), integer(N), N >= 0 ->
- true;
-is_c_fname(_) ->
- false.
-
-
-%% @spec var_name(cerl()) -> var_name()
-%%
-%% @doc Returns the name of an abstract variable.
-%%
-%% @see c_var/1
-
-var_name(Node) ->
- Node#var.name.
-
-
-%% @spec fname_id(cerl()) -> atom()
-%%
-%% @doc Returns the identifier part of an abstract function name
-%% variable.
-%%
-%% @see fname_arity/1
-%% @see c_fname/2
-
-fname_id(#var{name={A,_}}) ->
- A.
-
-
-%% @spec fname_arity(cerl()) -> integer()
-%%
-%% @doc Returns the arity part of an abstract function name variable.
-%%
-%% @see fname_id/1
-%% @see c_fname/2
-
-fname_arity(#var{name={_,N}}) ->
- N.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_values(Elements::[cerl()]) -> cerl()
-%%
-%% @doc Creates an abstract value list. If Elements
is
-%% [E1, ..., En]
, the result represents
-%% "<E1, ..., En>
".
-%%
-%% @see ann_c_values/2
-%% @see update_c_values/2
-%% @see is_c_values/1
-%% @see values_es/1
-%% @see values_arity/1
-
--record(values, {ann = [], es}).
-
-c_values(Es) ->
- #values{es = Es}.
-
-
-%% @spec ann_c_values(As::[term()], Elements::[cerl()]) -> cerl()
-%% @see c_values/1
-
-ann_c_values(As, Es) ->
- #values{es = Es, ann = As}.
-
-
-%% @spec update_c_values(Old::cerl(), Elements::[cerl()]) -> cerl()
-%% @see c_values/1
-
-update_c_values(Node, Es) ->
- #values{es = Es, ann = get_ann(Node)}.
-
-
-%% @spec is_c_values(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% value list; otherwise false
.
-%%
-%% @see c_values/1
-
-is_c_values(#values{}) ->
- true;
-is_c_values(_) ->
- false.
-
-
-%% @spec values_es(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of element subtrees of an abstract value
-%% list.
-%%
-%% @see c_values/1
-%% @see values_arity/1
-
-values_es(Node) ->
- Node#values.es.
-
-
-%% @spec values_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of element subtrees of an abstract value
-%% list.
-%%
-%% Note: This is equivalent to
-%% length(values_es(Node))
, but potentially more
-%% efficient.
Segments
is [S1, ..., Sn]
, the result
-%% represents "#{S1, ..., Sn}#
". All the
-%% Si
must have type bitstr
.
-%%
-%% @see ann_c_binary/2
-%% @see update_c_binary/2
-%% @see is_c_binary/1
-%% @see binary_segments/1
-%% @see c_bitstr/5
-
--record(binary, {ann = [], segments}).
-
-c_binary(Segments) ->
- #binary{segments = Segments}.
-
-
-%% @spec ann_c_binary(As::[term()], Segments::[cerl()]) -> cerl()
-%% @see c_binary/1
-
-ann_c_binary(As, Segments) ->
- #binary{segments = Segments, ann = As}.
-
-
-%% @spec update_c_binary(Old::cerl(), Segments::[cerl()]) -> cerl()
-%% @see c_binary/1
-
-update_c_binary(Node, Segments) ->
- #binary{segments = Segments, ann = get_ann(Node)}.
-
-
-%% @spec is_c_binary(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% binary-template; otherwise false
.
-%%
-%% @see c_binary/1
-
-is_c_binary(#binary{}) ->
- true;
-is_c_binary(_) ->
- false.
-
-
-%% @spec binary_segments(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of segment subtrees of an abstract
-%% binary-template.
-%%
-%% @see c_binary/1
-%% @see c_bitstr/5
-
-binary_segments(Node) ->
- Node#binary.segments.
-
-
-%% @spec c_bitstr(Value::cerl(), Size::cerl(), Unit::cerl(),
-%% Type::cerl(), Flags::cerl()) -> cerl()
-%%
-%% @doc Creates an abstract bit-string template. These can only occur as
-%% components of an abstract binary-template (see {@link c_binary/1}).
-%% The result represents "#<Value>(Size,
-%% Unit, Type, Flags)
", where
-%% Unit
must represent a positive integer constant,
-%% Type
must represent a constant atom (one of
-%% 'integer'
, 'float'
, or
-%% 'binary'
), and Flags
must represent a
-%% constant list "[F1, ..., Fn]"
where
-%% all the Fi
are atoms.
-%%
-%% @see c_binary/1
-%% @see ann_c_bitstr/6
-%% @see update_c_bitstr/6
-%% @see is_c_bitstr/1
-%% @see bitstr_val/1
-%% @see bitstr_size/1
-%% @see bitstr_unit/1
-%% @see bitstr_type/1
-%% @see bitstr_flags/1
-
--record(bitstr, {ann = [], val, size, unit, type, flags}).
-
-c_bitstr(Val, Size, Unit, Type, Flags) ->
- #bitstr{val = Val, size = Size, unit = Unit, type = Type,
- flags = Flags}.
-
-
-%% @spec c_bitstr(Value::cerl(), Size::cerl(), Type::cerl(),
-%% Flags::cerl()) -> cerl()
-%% @equiv c_bitstr(Value, Size, abstract(1), Type, Flags)
-
-c_bitstr(Val, Size, Type, Flags) ->
- c_bitstr(Val, Size, abstract(1), Type, Flags).
-
-
-%% @spec c_bitstr(Value::cerl(), Type::cerl(),
-%% Flags::cerl()) -> cerl()
-%% @equiv c_bitstr(Value, abstract(all), abstract(1), Type, Flags)
-
-c_bitstr(Val, Type, Flags) ->
- c_bitstr(Val, abstract(all), abstract(1), Type, Flags).
-
-
-%% @spec ann_c_bitstr(As::[term()], Value::cerl(), Size::cerl(),
-%% Unit::cerl(), Type::cerl(), Flags::cerl()) -> cerl()
-%% @see c_bitstr/5
-%% @see ann_c_bitstr/5
-
-ann_c_bitstr(As, Val, Size, Unit, Type, Flags) ->
- #bitstr{val = Val, size = Size, unit = Unit, type = Type,
- flags = Flags, ann = As}.
-
-%% @spec ann_c_bitstr(As::[term()], Value::cerl(), Size::cerl(),
-%% Type::cerl(), Flags::cerl()) -> cerl()
-%% @equiv ann_c_bitstr(As, Value, Size, abstract(1), Type, Flags)
-
-ann_c_bitstr(As, Value, Size, Type, Flags) ->
- ann_c_bitstr(As, Value, Size, abstract(1), Type, Flags).
-
-
-%% @spec update_c_bitstr(Old::cerl(), Value::cerl(), Size::cerl(),
-%% Unit::cerl(), Type::cerl(), Flags::cerl()) -> cerl()
-%% @see c_bitstr/5
-%% @see update_c_bitstr/5
-
-update_c_bitstr(Node, Val, Size, Unit, Type, Flags) ->
- #bitstr{val = Val, size = Size, unit = Unit, type = Type,
- flags = Flags, ann = get_ann(Node)}.
-
-
-%% @spec update_c_bitstr(Old::cerl(), Value::cerl(), Size::cerl(),
-%% Type::cerl(), Flags::cerl()) -> cerl()
-%% @equiv update_c_bitstr(Node, Value, Size, abstract(1), Type, Flags)
-
-update_c_bitstr(Node, Value, Size, Type, Flags) ->
- update_c_bitstr(Node, Value, Size, abstract(1), Type, Flags).
-
-%% @spec is_c_bitstr(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% bit-string template; otherwise false
.
-%%
-%% @see c_bitstr/5
-
-is_c_bitstr(#bitstr{}) ->
- true;
-is_c_bitstr(_) ->
- false.
-
-
-%% @spec bitstr_val(cerl()) -> cerl()
-%%
-%% @doc Returns the value subtree of an abstract bit-string template.
-%%
-%% @see c_bitstr/5
-
-bitstr_val(Node) ->
- Node#bitstr.val.
-
-
-%% @spec bitstr_size(cerl()) -> cerl()
-%%
-%% @doc Returns the size subtree of an abstract bit-string template.
-%%
-%% @see c_bitstr/5
-
-bitstr_size(Node) ->
- Node#bitstr.size.
-
-
-%% @spec bitstr_bitsize(cerl()) -> integer() | any | all
-%%
-%% @doc Returns the total size in bits of an abstract bit-string
-%% template. If the size field is an integer literal, the result is the
-%% product of the size and unit values; if the size field is the atom
-%% literal all
, the atom all
is returned; in
-%% all other cases, the atom any
is returned.
-%%
-%% @see c_bitstr/5
-
-bitstr_bitsize(Node) ->
- Size = Node#bitstr.size,
- case is_literal(Size) of
- true ->
- case concrete(Size) of
- all ->
- all;
- S when integer(S) ->
- S*concrete(Node#bitstr.unit);
- true ->
- any
- end;
- false ->
- any
- end.
-
-
-%% @spec bitstr_unit(cerl()) -> cerl()
-%%
-%% @doc Returns the unit subtree of an abstract bit-string template.
-%%
-%% @see c_bitstr/5
-
-bitstr_unit(Node) ->
- Node#bitstr.unit.
-
-
-%% @spec bitstr_type(cerl()) -> cerl()
-%%
-%% @doc Returns the type subtree of an abstract bit-string template.
-%%
-%% @see c_bitstr/5
-
-bitstr_type(Node) ->
- Node#bitstr.type.
-
-
-%% @spec bitstr_flags(cerl()) -> cerl()
-%%
-%% @doc Returns the flags subtree of an abstract bit-string template.
-%%
-%% @see c_bitstr/5
-
-bitstr_flags(Node) ->
- Node#bitstr.flags.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_fun(Variables::[cerl()], Body::cerl()) -> cerl()
-%%
-%% @doc Creates an abstract fun-expression. If Variables
-%% is [V1, ..., Vn]
, the result represents "fun
-%% (V1, ..., Vn) -> Body
". All the
-%% Vi
must have type var
.
-%%
-%% @see ann_c_fun/3
-%% @see update_c_fun/3
-%% @see is_c_fun/1
-%% @see fun_vars/1
-%% @see fun_body/1
-%% @see fun_arity/1
-
--record('fun', {ann = [], vars, body}).
-
-c_fun(Variables, Body) ->
- #'fun'{vars = Variables, body = Body}.
-
-
-%% @spec ann_c_fun(As::[term()], Variables::[cerl()], Body::cerl()) ->
-%% cerl()
-%% @see c_fun/2
-
-ann_c_fun(As, Variables, Body) ->
- #'fun'{vars = Variables, body = Body, ann = As}.
-
-
-%% @spec update_c_fun(Old::cerl(), Variables::[cerl()],
-%% Body::cerl()) -> cerl()
-%% @see c_fun/2
-
-update_c_fun(Node, Variables, Body) ->
- #'fun'{vars = Variables, body = Body, ann = get_ann(Node)}.
-
-
-%% @spec is_c_fun(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% fun-expression, otherwise false
.
-%%
-%% @see c_fun/2
-
-is_c_fun(#'fun'{}) ->
- true; % Now this is fun!
-is_c_fun(_) ->
- false.
-
-
-%% @spec fun_vars(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of parameter subtrees of an abstract
-%% fun-expression.
-%%
-%% @see c_fun/2
-%% @see fun_arity/1
-
-fun_vars(Node) ->
- Node#'fun'.vars.
-
-
-%% @spec fun_body(cerl()) -> cerl()
-%%
-%% @doc Returns the body subtree of an abstract fun-expression.
-%%
-%% @see c_fun/2
-
-fun_body(Node) ->
- Node#'fun'.body.
-
-
-%% @spec fun_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of parameter subtrees of an abstract
-%% fun-expression.
-%%
-%% Note: this is equivalent to length(fun_vars(Node))
,
-%% but potentially more efficient.
do Argument Body
".
-%%
-%% @see ann_c_seq/3
-%% @see update_c_seq/3
-%% @see is_c_seq/1
-%% @see seq_arg/1
-%% @see seq_body/1
-
--record(seq, {ann = [], arg, body}).
-
-c_seq(Argument, Body) ->
- #seq{arg = Argument, body = Body}.
-
-
-%% @spec ann_c_seq(As::[term()], Argument::cerl(), Body::cerl()) ->
-%% cerl()
-%% @see c_seq/2
-
-ann_c_seq(As, Argument, Body) ->
- #seq{arg = Argument, body = Body, ann = As}.
-
-
-%% @spec update_c_seq(Old::cerl(), Argument::cerl(), Body::cerl()) ->
-%% cerl()
-%% @see c_seq/2
-
-update_c_seq(Node, Argument, Body) ->
- #seq{arg = Argument, body = Body, ann = get_ann(Node)}.
-
-
-%% @spec is_c_seq(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% sequencing expression, otherwise false
.
-%%
-%% @see c_seq/2
-
-is_c_seq(#seq{}) ->
- true;
-is_c_seq(_) ->
- false.
-
-
-%% @spec seq_arg(cerl()) -> cerl()
-%%
-%% @doc Returns the argument subtree of an abstract sequencing
-%% expression.
-%%
-%% @see c_seq/2
-
-seq_arg(Node) ->
- Node#seq.arg.
-
-
-%% @spec seq_body(cerl()) -> cerl()
-%%
-%% @doc Returns the body subtree of an abstract sequencing expression.
-%%
-%% @see c_seq/2
-
-seq_body(Node) ->
- Node#seq.body.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_let(Variables::[cerl()], Argument::cerl(), Body::cerl()) ->
-%% cerl()
-%%
-%% @doc Creates an abstract let-expression. If Variables
-%% is [V1, ..., Vn]
, the result represents "let
-%% <V1, ..., Vn> = Argument in
-%% Body
". All the Vi
must have type
-%% var
.
-%%
-%% @see ann_c_let/4
-%% @see update_c_let/4
-%% @see is_c_let/1
-%% @see let_vars/1
-%% @see let_arg/1
-%% @see let_body/1
-%% @see let_arity/1
-
--record('let', {ann = [], vars, arg, body}).
-
-c_let(Variables, Argument, Body) ->
- #'let'{vars = Variables, arg = Argument, body = Body}.
-
-
-%% ann_c_let(As, Variables, Argument, Body) -> Node
-%% @see c_let/3
-
-ann_c_let(As, Variables, Argument, Body) ->
- #'let'{vars = Variables, arg = Argument, body = Body, ann = As}.
-
-
-%% update_c_let(Old, Variables, Argument, Body) -> Node
-%% @see c_let/3
-
-update_c_let(Node, Variables, Argument, Body) ->
- #'let'{vars = Variables, arg = Argument, body = Body,
- ann = get_ann(Node)}.
-
-
-%% @spec is_c_let(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% let-expression, otherwise false
.
-%%
-%% @see c_let/3
-
-is_c_let(#'let'{}) ->
- true;
-is_c_let(_) ->
- false.
-
-
-%% @spec let_vars(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of left-hand side variables of an abstract
-%% let-expression.
-%%
-%% @see c_let/3
-%% @see let_arity/1
-
-let_vars(Node) ->
- Node#'let'.vars.
-
-
-%% @spec let_arg(cerl()) -> cerl()
-%%
-%% @doc Returns the argument subtree of an abstract let-expression.
-%%
-%% @see c_let/3
-
-let_arg(Node) ->
- Node#'let'.arg.
-
-
-%% @spec let_body(cerl()) -> cerl()
-%%
-%% @doc Returns the body subtree of an abstract let-expression.
-%%
-%% @see c_let/3
-
-let_body(Node) ->
- Node#'let'.body.
-
-
-%% @spec let_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of left-hand side variables of an abstract
-%% let-expression.
-%%
-%% Note: this is equivalent to length(let_vars(Node))
,
-%% but potentially more efficient.
Definitions
is [{V1, F1}, ..., {Vn, Fn}]
,
-%% the result represents "letrec V1 = F1
-%% ... Vn = Fn in Body
. All the
-%% Vi
must have type var
and represent
-%% function names. All the Fi
must have type
-%% 'fun'
.
-%%
-%% @see ann_c_letrec/3
-%% @see update_c_letrec/3
-%% @see is_c_letrec/1
-%% @see letrec_defs/1
-%% @see letrec_body/1
-%% @see letrec_vars/1
-
--record(letrec, {ann = [], defs, body}).
-
-c_letrec(Defs, Body) ->
- #letrec{defs = Defs, body = Body}.
-
-
-%% @spec ann_c_letrec(As::[term()], Definitions::[{cerl(), cerl()}],
-%% Body::cerl()) -> cerl()
-%% @see c_letrec/2
-
-ann_c_letrec(As, Defs, Body) ->
- #letrec{defs = Defs, body = Body, ann = As}.
-
-
-%% @spec update_c_letrec(Old::cerl(),
-%% Definitions::[{cerl(), cerl()}],
-%% Body::cerl()) -> cerl()
-%% @see c_letrec/2
-
-update_c_letrec(Node, Defs, Body) ->
- #letrec{defs = Defs, body = Body, ann = get_ann(Node)}.
-
-
-%% @spec is_c_letrec(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% letrec-expression, otherwise false
.
-%%
-%% @see c_letrec/2
-
-is_c_letrec(#letrec{}) ->
- true;
-is_c_letrec(_) ->
- false.
-
-
-%% @spec letrec_defs(Node::cerl()) -> [{cerl(), cerl()}]
-%%
-%% @doc Returns the list of definitions of an abstract
-%% letrec-expression. If Node
represents "letrec
-%% V1 = F1 ... Vn = Fn in
-%% Body
", the returned value is [{V1, F1}, ...,
-%% {Vn, Fn}]
.
-%%
-%% @see c_letrec/2
-
-letrec_defs(Node) ->
- Node#letrec.defs.
-
-
-%% @spec letrec_body(cerl()) -> cerl()
-%%
-%% @doc Returns the body subtree of an abstract letrec-expression.
-%%
-%% @see c_letrec/2
-
-letrec_body(Node) ->
- Node#letrec.body.
-
-
-%% @spec letrec_vars(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of left-hand side function variable subtrees
-%% of a letrec-expression. If Node
represents
-%% "letrec V1 = F1 ... Vn =
-%% Fn in Body
", the returned value is
-%% [V1, ..., Vn]
.
-%%
-%% @see c_letrec/2
-
-letrec_vars(Node) ->
- [F || {F, _} <- letrec_defs(Node)].
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_case(Argument::cerl(), Clauses::[cerl()]) -> cerl()
-%%
-%% @doc Creates an abstract case-expression. If Clauses
-%% is [C1, ..., Cn]
, the result represents "case
-%% Argument of C1 ... Cn
-%% end
". Clauses
must not be empty.
-%%
-%% @see ann_c_case/3
-%% @see update_c_case/3
-%% @see is_c_case/1
-%% @see c_clause/3
-%% @see case_arg/1
-%% @see case_clauses/1
-%% @see case_arity/1
-
--record('case', {ann = [], arg, clauses}).
-
-c_case(Expr, Clauses) ->
- #'case'{arg = Expr, clauses = Clauses}.
-
-
-%% @spec ann_c_case(As::[term()], Argument::cerl(),
-%% Clauses::[cerl()]) -> cerl()
-%% @see c_case/2
-
-ann_c_case(As, Expr, Clauses) ->
- #'case'{arg = Expr, clauses = Clauses, ann = As}.
-
-
-%% @spec update_c_case(Old::cerl(), Argument::cerl(),
-%% Clauses::[cerl()]) -> cerl()
-%% @see c_case/2
-
-update_c_case(Node, Expr, Clauses) ->
- #'case'{arg = Expr, clauses = Clauses, ann = get_ann(Node)}.
-
-
-%% is_c_case(Node) -> boolean()
-%%
-%% Node = cerl()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% case-expression; otherwise false
.
-%%
-%% @see c_case/2
-
-is_c_case(#'case'{}) ->
- true;
-is_c_case(_) ->
- false.
-
-
-%% @spec case_arg(cerl()) -> cerl()
-%%
-%% @doc Returns the argument subtree of an abstract case-expression.
-%%
-%% @see c_case/2
-
-case_arg(Node) ->
- Node#'case'.arg.
-
-
-%% @spec case_clauses(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of clause subtrees of an abstract
-%% case-expression.
-%%
-%% @see c_case/2
-%% @see case_arity/1
-
-case_clauses(Node) ->
- Node#'case'.clauses.
-
-
-%% @spec case_arity(Node::cerl()) -> integer()
-%%
-%% @doc Equivalent to
-%% clause_arity(hd(case_clauses(Node)))
, but potentially
-%% more efficient.
-%%
-%% @see c_case/2
-%% @see case_clauses/1
-%% @see clause_arity/1
-
-case_arity(Node) ->
- clause_arity(hd(case_clauses(Node))).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_clause(Patterns::[cerl()], Body::cerl()) -> cerl()
-%% @equiv c_clause(Patterns, c_atom(true), Body)
-%% @see c_atom/1
-
-c_clause(Patterns, Body) ->
- c_clause(Patterns, c_atom(true), Body).
-
-
-%% @spec c_clause(Patterns::[cerl()], Guard::cerl(), Body::cerl()) ->
-%% cerl()
-%%
-%% @doc Creates an an abstract clause. If Patterns
is
-%% [P1, ..., Pn]
, the result represents
-%% "<P1, ..., Pn> when Guard ->
-%% Body
".
-%%
-%% @see c_clause/2
-%% @see ann_c_clause/4
-%% @see update_c_clause/4
-%% @see is_c_clause/1
-%% @see c_case/2
-%% @see c_receive/3
-%% @see clause_pats/1
-%% @see clause_guard/1
-%% @see clause_body/1
-%% @see clause_arity/1
-%% @see clause_vars/1
-
--record(clause, {ann = [], pats, guard, body}).
-
-c_clause(Patterns, Guard, Body) ->
- #clause{pats = Patterns, guard = Guard, body = Body}.
-
-
-%% @spec ann_c_clause(As::[term()], Patterns::[cerl()],
-%% Body::cerl()) -> cerl()
-%% @equiv ann_c_clause(As, Patterns, c_atom(true), Body)
-%% @see c_clause/3
-ann_c_clause(As, Patterns, Body) ->
- ann_c_clause(As, Patterns, c_atom(true), Body).
-
-
-%% @spec ann_c_clause(As::[term()], Patterns::[cerl()], Guard::cerl(),
-%% Body::cerl()) -> cerl()
-%% @see ann_c_clause/3
-%% @see c_clause/3
-
-ann_c_clause(As, Patterns, Guard, Body) ->
- #clause{pats = Patterns, guard = Guard, body = Body, ann = As}.
-
-
-%% @spec update_c_clause(Old::cerl(), Patterns::[cerl()],
-%% Guard::cerl(), Body::cerl()) -> cerl()
-%% @see c_clause/3
-
-update_c_clause(Node, Patterns, Guard, Body) ->
- #clause{pats = Patterns, guard = Guard, body = Body,
- ann = get_ann(Node)}.
-
-
-%% @spec is_c_clause(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% clause, otherwise false
.
-%%
-%% @see c_clause/3
-
-is_c_clause(#clause{}) ->
- true;
-is_c_clause(_) ->
- false.
-
-
-%% @spec clause_pats(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of pattern subtrees of an abstract clause.
-%%
-%% @see c_clause/3
-%% @see clause_arity/1
-
-clause_pats(Node) ->
- Node#clause.pats.
-
-
-%% @spec clause_guard(cerl()) -> cerl()
-%%
-%% @doc Returns the guard subtree of an abstract clause.
-%%
-%% @see c_clause/3
-
-clause_guard(Node) ->
- Node#clause.guard.
-
-
-%% @spec clause_body(cerl()) -> cerl()
-%%
-%% @doc Returns the body subtree of an abstract clause.
-%%
-%% @see c_clause/3
-
-clause_body(Node) ->
- Node#clause.body.
-
-
-%% @spec clause_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of pattern subtrees of an abstract clause.
-%%
-%% Note: this is equivalent to
-%% length(clause_pats(Node))
, but potentially more
-%% efficient.
Node
does not represent a
-%% well-formed Core Erlang clause pattern. The order of listing is not
-%% defined.
-%%
-%% @see pat_list_vars/1
-%% @see clause_vars/1
-
-pat_vars(Node) ->
- pat_vars(Node, []).
-
-pat_vars(Node, Vs) ->
- case type(Node) of
- var ->
- [Node | Vs];
- literal ->
- Vs;
- cons ->
- pat_vars(cons_hd(Node), pat_vars(cons_tl(Node), Vs));
- tuple ->
- pat_list_vars(tuple_es(Node), Vs);
- binary ->
- pat_list_vars(binary_segments(Node), Vs);
- bitstr ->
- pat_vars(bitstr_val(Node), Vs);
- alias ->
- pat_vars(alias_pat(Node), [alias_var(Node) | Vs])
- end.
-
-
-%% @spec pat_list_vars(Patterns::[cerl()]) -> [cerl()]
-%%
-%% @doc Returns the list of all abstract variables in the given
-%% patterns. An exception is thrown if some element in
-%% Patterns
does not represent a well-formed Core Erlang
-%% clause pattern. The order of listing is not defined.
-%%
-%% @see pat_vars/1
-%% @see clause_vars/1
-
-pat_list_vars(Ps) ->
- pat_list_vars(Ps, []).
-
-pat_list_vars([P | Ps], Vs) ->
- pat_list_vars(Ps, pat_vars(P, Vs));
-pat_list_vars([], Vs) ->
- Vs.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_alias(Variable::cerl(), Pattern::cerl()) -> cerl()
-%%
-%% @doc Creates an abstract pattern alias. The result represents
-%% "Variable = Pattern
".
-%%
-%% @see ann_c_alias/3
-%% @see update_c_alias/3
-%% @see is_c_alias/1
-%% @see alias_var/1
-%% @see alias_pat/1
-%% @see c_clause/3
-
--record(alias, {ann = [], var, pat}).
-
-c_alias(Var, Pattern) ->
- #alias{var = Var, pat = Pattern}.
-
-
-%% @spec ann_c_alias(As::[term()], Variable::cerl(),
-%% Pattern::cerl()) -> cerl()
-%% @see c_alias/2
-
-ann_c_alias(As, Var, Pattern) ->
- #alias{var = Var, pat = Pattern, ann = As}.
-
-
-%% @spec update_c_alias(Old::cerl(), Variable::cerl(),
-%% Pattern::cerl()) -> cerl()
-%% @see c_alias/2
-
-update_c_alias(Node, Var, Pattern) ->
- #alias{var = Var, pat = Pattern, ann = get_ann(Node)}.
-
-
-%% @spec is_c_alias(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% pattern alias, otherwise false
.
-%%
-%% @see c_alias/2
-
-is_c_alias(#alias{}) ->
- true;
-is_c_alias(_) ->
- false.
-
-
-%% @spec alias_var(cerl()) -> cerl()
-%%
-%% @doc Returns the variable subtree of an abstract pattern alias.
-%%
-%% @see c_alias/2
-
-alias_var(Node) ->
- Node#alias.var.
-
-
-%% @spec alias_pat(cerl()) -> cerl()
-%%
-%% @doc Returns the pattern subtree of an abstract pattern alias.
-%%
-%% @see c_alias/2
-
-alias_pat(Node) ->
- Node#alias.pat.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_receive(Clauses::[cerl()]) -> cerl()
-%% @equiv c_receive(Clauses, c_atom(infinity), c_atom(true))
-%% @see c_atom/1
-
-c_receive(Clauses) ->
- c_receive(Clauses, c_atom(infinity), c_atom(true)).
-
-
-%% @spec c_receive(Clauses::[cerl()], Timeout::cerl(),
-%% Action::cerl()) -> cerl()
-%%
-%% @doc Creates an abstract receive-expression. If
-%% Clauses
is [C1, ..., Cn]
, the result
-%% represents "receive C1 ... Cn after
-%% Timeout -> Action end
".
-%%
-%% @see c_receive/1
-%% @see ann_c_receive/4
-%% @see update_c_receive/4
-%% @see is_c_receive/1
-%% @see receive_clauses/1
-%% @see receive_timeout/1
-%% @see receive_action/1
-
--record('receive', {ann = [], clauses, timeout, action}).
-
-c_receive(Clauses, Timeout, Action) ->
- #'receive'{clauses = Clauses, timeout = Timeout, action = Action}.
-
-
-%% @spec ann_c_receive(As::[term()], Clauses::[cerl()]) -> cerl()
-%% @equiv ann_c_receive(As, Clauses, c_atom(infinity), c_atom(true))
-%% @see c_receive/3
-%% @see c_atom/1
-
-ann_c_receive(As, Clauses) ->
- ann_c_receive(As, Clauses, c_atom(infinity), c_atom(true)).
-
-
-%% @spec ann_c_receive(As::[term()], Clauses::[cerl()],
-%% Timeout::cerl(), Action::cerl()) -> cerl()
-%% @see ann_c_receive/2
-%% @see c_receive/3
-
-ann_c_receive(As, Clauses, Timeout, Action) ->
- #'receive'{clauses = Clauses, timeout = Timeout, action = Action,
- ann = As}.
-
-
-%% @spec update_c_receive(Old::cerl(), Clauses::[cerl()],
-%% Timeout::cerl(), Action::cerl()) -> cerl()
-%% @see c_receive/3
-
-update_c_receive(Node, Clauses, Timeout, Action) ->
- #'receive'{clauses = Clauses, timeout = Timeout, action = Action,
- ann = get_ann(Node)}.
-
-
-%% @spec is_c_receive(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% receive-expression, otherwise false
.
-%%
-%% @see c_receive/3
-
-is_c_receive(#'receive'{}) ->
- true;
-is_c_receive(_) ->
- false.
-
-
-%% @spec receive_clauses(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of clause subtrees of an abstract
-%% receive-expression.
-%%
-%% @see c_receive/3
-
-receive_clauses(Node) ->
- Node#'receive'.clauses.
-
-
-%% @spec receive_timeout(cerl()) -> cerl()
-%%
-%% @doc Returns the timeout subtree of an abstract receive-expression.
-%%
-%% @see c_receive/3
-
-receive_timeout(Node) ->
- Node#'receive'.timeout.
-
-
-%% @spec receive_action(cerl()) -> cerl()
-%%
-%% @doc Returns the action subtree of an abstract receive-expression.
-%%
-%% @see c_receive/3
-
-receive_action(Node) ->
- Node#'receive'.action.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_apply(Operator::cerl(), Arguments::[cerl()]) -> cerl()
-%%
-%% @doc Creates an abstract function application. If
-%% Arguments
is [A1, ..., An]
, the result
-%% represents "apply Operator(A1, ...,
-%% An)
".
-%%
-%% @see ann_c_apply/3
-%% @see update_c_apply/3
-%% @see is_c_apply/1
-%% @see apply_op/1
-%% @see apply_args/1
-%% @see apply_arity/1
-%% @see c_call/3
-%% @see c_primop/2
-
--record(apply, {ann = [], op, args}).
-
-c_apply(Operator, Arguments) ->
- #apply{op = Operator, args = Arguments}.
-
-
-%% @spec ann_c_apply(As::[term()], Operator::cerl(),
-%% Arguments::[cerl()]) -> cerl()
-%% @see c_apply/2
-
-ann_c_apply(As, Operator, Arguments) ->
- #apply{op = Operator, args = Arguments, ann = As}.
-
-
-%% @spec update_c_apply(Old::cerl(), Operator::cerl(),
-%% Arguments::[cerl()]) -> cerl()
-%% @see c_apply/2
-
-update_c_apply(Node, Operator, Arguments) ->
- #apply{op = Operator, args = Arguments, ann = get_ann(Node)}.
-
-
-%% @spec is_c_apply(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% function application, otherwise false
.
-%%
-%% @see c_apply/2
-
-is_c_apply(#apply{}) ->
- true;
-is_c_apply(_) ->
- false.
-
-
-%% @spec apply_op(cerl()) -> cerl()
-%%
-%% @doc Returns the operator subtree of an abstract function
-%% application.
-%%
-%% @see c_apply/2
-
-apply_op(Node) ->
- Node#apply.op.
-
-
-%% @spec apply_args(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of argument subtrees of an abstract function
-%% application.
-%%
-%% @see c_apply/2
-%% @see apply_arity/1
-
-apply_args(Node) ->
- Node#apply.args.
-
-
-%% @spec apply_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of argument subtrees of an abstract
-%% function application.
-%%
-%% Note: this is equivalent to
-%% length(apply_args(Node))
, but potentially more
-%% efficient.
Arguments
is [A1, ..., An]
, the result
-%% represents "call Module:Name(A1,
-%% ..., An)
".
-%%
-%% @see ann_c_call/4
-%% @see update_c_call/4
-%% @see is_c_call/1
-%% @see call_module/1
-%% @see call_name/1
-%% @see call_args/1
-%% @see call_arity/1
-%% @see c_apply/2
-%% @see c_primop/2
-
--record(call, {ann = [], module, name, args}).
-
-c_call(Module, Name, Arguments) ->
- #call{module = Module, name = Name, args = Arguments}.
-
-
-%% @spec ann_c_call(As::[term()], Module::cerl(), Name::cerl(),
-%% Arguments::[cerl()]) -> cerl()
-%% @see c_call/3
-
-ann_c_call(As, Module, Name, Arguments) ->
- #call{module = Module, name = Name, args = Arguments, ann = As}.
-
-
-%% @spec update_c_call(Old::cerl(), Module::cerl(), Name::cerl(),
-%% Arguments::[cerl()]) -> cerl()
-%% @see c_call/3
-
-update_c_call(Node, Module, Name, Arguments) ->
- #call{module = Module, name = Name, args = Arguments,
- ann = get_ann(Node)}.
-
-
-%% @spec is_c_call(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% inter-module call expression; otherwise false
.
-%%
-%% @see c_call/3
-
-is_c_call(#call{}) ->
- true;
-is_c_call(_) ->
- false.
-
-
-%% @spec call_module(cerl()) -> cerl()
-%%
-%% @doc Returns the module subtree of an abstract inter-module call.
-%%
-%% @see c_call/3
-
-call_module(Node) ->
- Node#call.module.
-
-
-%% @spec call_name(cerl()) -> cerl()
-%%
-%% @doc Returns the name subtree of an abstract inter-module call.
-%%
-%% @see c_call/3
-
-call_name(Node) ->
- Node#call.name.
-
-
-%% @spec call_args(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of argument subtrees of an abstract
-%% inter-module call.
-%%
-%% @see c_call/3
-%% @see call_arity/1
-
-call_args(Node) ->
- Node#call.args.
-
-
-%% @spec call_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of argument subtrees of an abstract
-%% inter-module call.
-%%
-%% Note: this is equivalent to
-%% length(call_args(Node))
, but potentially more
-%% efficient.
Arguments
is [A1, ..., An]
, the result
-%% represents "primop Name(A1, ...,
-%% An)
". Name
must be an atom literal.
-%%
-%% @see ann_c_primop/3
-%% @see update_c_primop/3
-%% @see is_c_primop/1
-%% @see primop_name/1
-%% @see primop_args/1
-%% @see primop_arity/1
-%% @see c_apply/2
-%% @see c_call/3
-
--record(primop, {ann = [], name, args}).
-
-c_primop(Name, Arguments) ->
- #primop{name = Name, args = Arguments}.
-
-
-%% @spec ann_c_primop(As::[term()], Name::cerl(),
-%% Arguments::[cerl()]) -> cerl()
-%% @see c_primop/2
-
-ann_c_primop(As, Name, Arguments) ->
- #primop{name = Name, args = Arguments, ann = As}.
-
-
-%% @spec update_c_primop(Old::cerl(), Name::cerl(),
-%% Arguments::[cerl()]) -> cerl()
-%% @see c_primop/2
-
-update_c_primop(Node, Name, Arguments) ->
- #primop{name = Name, args = Arguments, ann = get_ann(Node)}.
-
-
-%% @spec is_c_primop(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% primitive operation call, otherwise false
.
-%%
-%% @see c_primop/2
-
-is_c_primop(#primop{}) ->
- true;
-is_c_primop(_) ->
- false.
-
-
-%% @spec primop_name(cerl()) -> cerl()
-%%
-%% @doc Returns the name subtree of an abstract primitive operation
-%% call.
-%%
-%% @see c_primop/2
-
-primop_name(Node) ->
- Node#primop.name.
-
-
-%% @spec primop_args(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of argument subtrees of an abstract primitive
-%% operation call.
-%%
-%% @see c_primop/2
-%% @see primop_arity/1
-
-primop_args(Node) ->
- Node#primop.args.
-
-
-%% @spec primop_arity(Node::cerl()) -> integer()
-%%
-%% @doc Returns the number of argument subtrees of an abstract
-%% primitive operation call.
-%%
-%% Note: this is equivalent to
-%% length(primop_args(Node))
, but potentially more
-%% efficient.
Variables
is
-%% [V1, ..., Vn]
and ExceptionVars
is
-%% [X1, ..., Xm]
, the result represents "try
-%% Argument of <V1, ..., Vn> ->
-%% Body catch <X1, ..., Xm> ->
-%% Handler
". All the Vi
and Xi
-%% must have type var
.
-%%
-%% @see ann_c_try/6
-%% @see update_c_try/6
-%% @see is_c_try/1
-%% @see try_arg/1
-%% @see try_vars/1
-%% @see try_body/1
-%% @see c_catch/1
-
--record('try', {ann = [], arg, vars, body, evars, handler}).
-
-c_try(Expr, Vs, Body, Evs, Handler) ->
- #'try'{arg = Expr, vars = Vs, body = Body,
- evars = Evs, handler = Handler}.
-
-
-%% @spec ann_c_try(As::[term()], Expression::cerl(),
-%% Variables::[cerl()], Body::cerl(),
-%% EVars::[cerl()], EBody::[cerl()]) -> cerl()
-%% @see c_try/3
-
-ann_c_try(As, Expr, Vs, Body, Evs, Handler) ->
- #'try'{arg = Expr, vars = Vs, body = Body,
- evars = Evs, handler = Handler, ann = As}.
-
-
-%% @spec update_c_try(Old::cerl(), Expression::cerl(),
-%% Variables::[cerl()], Body::cerl(),
-%% EVars::[cerl()], EBody::[cerl()]) -> cerl()
-%% @see c_try/3
-
-update_c_try(Node, Expr, Vs, Body, Evs, Handler) ->
- #'try'{arg = Expr, vars = Vs, body = Body,
- evars = Evs, handler = Handler, ann = get_ann(Node)}.
-
-
-%% @spec is_c_try(Node::cerl()) -> boolean()
-%%
-%% @doc Returns true
if Node
is an abstract
-%% try-expression, otherwise false
.
-%%
-%% @see c_try/3
-
-is_c_try(#'try'{}) ->
- true;
-is_c_try(_) ->
- false.
-
-
-%% @spec try_arg(cerl()) -> cerl()
-%%
-%% @doc Returns the expression subtree of an abstract try-expression.
-%%
-%% @see c_try/3
-
-try_arg(Node) ->
- Node#'try'.arg.
-
-
-%% @spec try_vars(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of success variable subtrees of an abstract
-%% try-expression.
-%%
-%% @see c_try/3
-
-try_vars(Node) ->
- Node#'try'.vars.
-
-
-%% @spec try_body(cerl()) -> cerl()
-%%
-%% @doc Returns the success body subtree of an abstract try-expression.
-%%
-%% @see c_try/3
-
-try_body(Node) ->
- Node#'try'.body.
-
-
-%% @spec try_evars(cerl()) -> [cerl()]
-%%
-%% @doc Returns the list of exception variable subtrees of an abstract
-%% try-expression.
-%%
-%% @see c_try/3
-
-try_evars(Node) ->
- Node#'try'.evars.
-
-
-%% @spec try_handler(cerl()) -> cerl()
-%%
-%% @doc Returns the exception body subtree of an abstract
-%% try-expression.
-%%
-%% @see c_try/3
-
-try_handler(Node) ->
- Node#'try'.handler.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec c_catch(Body::cerl()) -> cerl()
-%%
-%% @doc Creates an abstract catch-expression. The result represents
-%% "catch Body
".
-%%
-%% Note: catch-expressions can be rewritten as try-expressions, and -%% will eventually be removed from Core Erlang.
-%% -%% @see ann_c_catch/2 -%% @see update_c_catch/2 -%% @see is_c_catch/1 -%% @see catch_body/1 -%% @see c_try/3 - --record('catch', {ann = [], body}). - -c_catch(Body) -> - #'catch'{body = Body}. - - -%% @spec ann_c_catch(As::[term()], Body::cerl()) -> cerl() -%% @see c_catch/1 - -ann_c_catch(As, Body) -> - #'catch'{body = Body, ann = As}. - - -%% @spec update_c_catch(Old::cerl(), Body::cerl()) -> cerl() -%% @see c_catch/1 - -update_c_catch(Node, Body) -> - #'catch'{body = Body, ann = get_ann(Node)}. - - -%% @spec is_c_catch(Node::cerl()) -> boolean() -%% -%% @doc Returnstrue
if Node
is an abstract
-%% catch-expression, otherwise false
.
-%%
-%% @see c_catch/1
-
-is_c_catch(#'catch'{}) ->
- true;
-is_c_catch(_) ->
- false.
-
-
-%% @spec catch_body(Node::cerl()) -> cerl()
-%%
-%% @doc Returns the body subtree of an abstract catch-expression.
-%%
-%% @see c_catch/1
-
-catch_body(Node) ->
- Node#'catch'.body.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec to_records(Tree::cerl()) -> record(record_types())
-%%
-%% @doc Translates an abstract syntax tree to a corresponding explicit
-%% record representation. The records are defined in the file
-%% "cerl.hrl
".
-%%
-%% Note: Compound constant literals are always unfolded in the -%% record representation.
-%% -%% @see type/1 -%% @see from_records/1 - -to_records(Node) -> - A = get_ann(Node), - case type(Node) of - literal -> - lit_to_records(concrete(Node), A); - binary -> - #c_binary{anno = A, - segments = - list_to_records(binary_segments(Node))}; - bitstr -> - #c_bitstr{anno = A, - val = to_records(bitstr_val(Node)), - size = to_records(bitstr_size(Node)), - unit = to_records(bitstr_unit(Node)), - type = to_records(bitstr_type(Node)), - flags = to_records(bitstr_flags(Node))}; - cons -> - #c_cons{anno = A, - hd = to_records(cons_hd(Node)), - tl = to_records(cons_tl(Node))}; - tuple -> - #c_tuple{anno = A, - es = list_to_records(tuple_es(Node))}; - var -> - case is_c_fname(Node) of - true -> - #c_fname{anno = A, - id = fname_id(Node), - arity = fname_arity(Node)}; - false -> - #c_var{anno = A, name = var_name(Node)} - end; - values -> - #c_values{anno = A, - es = list_to_records(values_es(Node))}; - 'fun' -> - #c_fun{anno = A, - vars = list_to_records(fun_vars(Node)), - body = to_records(fun_body(Node))}; - seq -> - #c_seq{anno = A, - arg = to_records(seq_arg(Node)), - body = to_records(seq_body(Node))}; - 'let' -> - #c_let{anno = A, - vars = list_to_records(let_vars(Node)), - arg = to_records(let_arg(Node)), - body = to_records(let_body(Node))}; - letrec -> - #c_letrec{anno = A, - defs = [#c_def{name = to_records(N), - val = to_records(F)} - || {N, F} <- letrec_defs(Node)], - body = to_records(letrec_body(Node))}; - 'case' -> - #c_case{anno = A, - arg = to_records(case_arg(Node)), - clauses = - list_to_records(case_clauses(Node))}; - clause -> - #c_clause{anno = A, - pats = list_to_records(clause_pats(Node)), - guard = to_records(clause_guard(Node)), - body = to_records(clause_body(Node))}; - alias -> - #c_alias{anno = A, - var = to_records(alias_var(Node)), - pat = to_records(alias_pat(Node))}; - 'receive' -> - #c_receive{anno = A, - clauses = - list_to_records(receive_clauses(Node)), - timeout = - to_records(receive_timeout(Node)), - action = - to_records(receive_action(Node))}; - apply -> - #c_apply{anno = A, - op = to_records(apply_op(Node)), - args = list_to_records(apply_args(Node))}; - call -> - #c_call{anno = A, - module = to_records(call_module(Node)), - name = to_records(call_name(Node)), - args = list_to_records(call_args(Node))}; - primop -> - #c_primop{anno = A, - name = to_records(primop_name(Node)), - args = list_to_records(primop_args(Node))}; - 'try' -> - #c_try{anno = A, - arg = to_records(try_arg(Node)), - vars = list_to_records(try_vars(Node)), - body = to_records(try_body(Node)), - evars = list_to_records(try_evars(Node)), - handler = to_records(try_handler(Node))}; - 'catch' -> - #c_catch{anno = A, - body = to_records(catch_body(Node))}; - module -> - #c_module{anno = A, - name = to_records(module_name(Node)), - exports = list_to_records( - module_exports(Node)), - attrs = [#c_def{name = to_records(K), - val = to_records(V)} - || {K, V} <- module_attrs(Node)], - defs = [#c_def{name = to_records(N), - val = to_records(F)} - || {N, F} <- module_defs(Node)]} - end. - -list_to_records([T | Ts]) -> - [to_records(T) | list_to_records(Ts)]; -list_to_records([]) -> - []. - -lit_to_records(V, A) when integer(V) -> - #c_int{anno = A, val = V}; -lit_to_records(V, A) when float(V) -> - #c_float{anno = A, val = V}; -lit_to_records(V, A) when atom(V) -> - #c_atom{anno = A, val = V}; -lit_to_records([H | T] = V, A) -> - case is_print_char_list(V) of - true -> - #c_string{anno = A, val = V}; - false -> - #c_cons{anno = A, - hd = lit_to_records(H, []), - tl = lit_to_records(T, [])} - end; -lit_to_records([], A) -> - #c_nil{anno = A}; -lit_to_records(V, A) when tuple(V) -> - #c_tuple{anno = A, es = lit_list_to_records(tuple_to_list(V))}. - -lit_list_to_records([T | Ts]) -> - [lit_to_records(T, []) | lit_list_to_records(Ts)]; -lit_list_to_records([]) -> - []. - - -%% @spec from_records(Tree::record(record_types())) -> cerl() -%% -%% record_types() = c_alias | c_apply | c_call | c_case | c_catch | -%% c_clause | c_cons | c_def| c_fun | c_let | -%% c_letrec |c_lit | c_module | c_primop | -%% c_receive | c_seq | c_try | c_tuple | -%% c_values | c_var -%% -%% @doc Translates an explicit record representation to a -%% corresponding abstract syntax tree. The records are defined in the -%% file "cerl.hrl
".
-%%
-%% Note: Compound constant literals are folded, discarding
-%% annotations on subtrees. There are no c_def
nodes in
-%% the abstract representation; annotations on c_def
-%% records are discarded.
true
if Node
represents a
-%% data constructor, otherwise false
. Data constructors
-%% are cons cells, tuples, and atomic literals.
-%%
-%% @see data_type/1
-%% @see data_es/1
-%% @see data_arity/1
-
-is_data(#literal{}) ->
- true;
-is_data(#cons{}) ->
- true;
-is_data(#tuple{}) ->
- true;
-is_data(_) ->
- false.
-
-
-%% @spec data_type(Node::cerl()) -> dtype()
-%%
-%% dtype() = cons | tuple | {'atomic', Value}
-%% Value = integer() | float() | atom() | []
-%%
-%% @doc Returns a type descriptor for a data constructor
-%% node. (Cf. is_data/1
.) This is mainly useful for
-%% comparing types and for constructing new nodes of the same type
-%% (cf. make_data/2
). If Node
represents an
-%% integer, floating-point number, atom or empty list, the result is
-%% {'atomic', Value}
, where Value
is the value
-%% of concrete(Node)
, otherwise the result is either
-%% cons
or tuple
.
-%%
-%% Type descriptors can be compared for equality or order (in the -%% Erlang term order), but remember that floating-point values should -%% in general never be tested for equality.
-%% -%% @see is_data/1 -%% @see make_data/2 -%% @see type/1 -%% @see concrete/1 - -data_type(#literal{val = V}) -> - case V of - [_ | _] -> - cons; - _ when tuple(V) -> - tuple; - _ -> - {'atomic', V} - end; -data_type(#cons{}) -> - cons; -data_type(#tuple{}) -> - tuple. - - -%% @spec data_es(Node::cerl()) -> [cerl()] -%% -%% @doc Returns the list of subtrees of a data constructor node. If -%% the arity of the constructor is zero, the result is the empty list. -%% -%%Note: if data_type(Node)
is cons
, the
-%% number of subtrees is exactly two. If data_type(Node)
-%% is {'atomic', Value}
, the number of subtrees is
-%% zero.
length(data_es(Node))
, but
-%% potentially more efficient.
-%%
-%% @see is_data/1
-%% @see data_es/1
-
-data_arity(#literal{val = V}) ->
- case V of
- [_ | _] ->
- 2;
- _ when tuple(V) ->
- size(V);
- _ ->
- 0
- end;
-data_arity(#cons{}) ->
- 2;
-data_arity(#tuple{es = Es}) ->
- length(Es).
-
-
-%% @spec make_data(Type::dtype(), Elements::[cerl()]) -> cerl()
-%%
-%% @doc Creates a data constructor node with the specified type and
-%% subtrees. (Cf. data_type/1
.) An exception is thrown
-%% if the length of Elements
is invalid for the given
-%% Type
; see data_es/1
for arity constraints
-%% on constructor types.
-%%
-%% @see data_type/1
-%% @see data_es/1
-%% @see ann_make_data/3
-%% @see update_data/3
-%% @see make_data_skel/2
-
-make_data(CType, Es) ->
- ann_make_data([], CType, Es).
-
-
-%% @spec ann_make_data(As::[term()], Type::dtype(),
-%% Elements::[cerl()]) -> cerl()
-%% @see make_data/2
-
-ann_make_data(As, {'atomic', V}, []) -> #literal{val = V, ann = As};
-ann_make_data(As, cons, [H, T]) -> ann_c_cons(As, H, T);
-ann_make_data(As, tuple, Es) -> ann_c_tuple(As, Es).
-
-
-%% @spec update_data(Old::cerl(), Type::dtype(),
-%% Elements::[cerl()]) -> cerl()
-%% @see make_data/2
-
-update_data(Node, CType, Es) ->
- ann_make_data(get_ann(Node), CType, Es).
-
-
-%% @spec make_data_skel(Type::dtype(), Elements::[cerl()]) -> cerl()
-%%
-%% @doc Like make_data/2
, but analogous to
-%% c_tuple_skel/1
and c_cons_skel/2
.
-%%
-%% @see ann_make_data_skel/3
-%% @see update_data_skel/3
-%% @see make_data/2
-%% @see c_tuple_skel/1
-%% @see c_cons_skel/2
-
-make_data_skel(CType, Es) ->
- ann_make_data_skel([], CType, Es).
-
-
-%% @spec ann_make_data_skel(As::[term()], Type::dtype(),
-%% Elements::[cerl()]) -> cerl()
-%% @see make_data_skel/2
-
-ann_make_data_skel(As, {'atomic', V}, []) -> #literal{val = V, ann = As};
-ann_make_data_skel(As, cons, [H, T]) -> ann_c_cons_skel(As, H, T);
-ann_make_data_skel(As, tuple, Es) -> ann_c_tuple_skel(As, Es).
-
-
-%% @spec update_data_skel(Old::cerl(), Type::dtype(),
-%% Elements::[cerl()]) -> cerl()
-%% @see make_data_skel/2
-
-update_data_skel(Node, CType, Es) ->
- ann_make_data_skel(get_ann(Node), CType, Es).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec subtrees(Node::cerl()) -> [[cerl()]]
-%%
-%% @doc Returns the grouped list of all subtrees of a node. If
-%% Node
is a leaf node (cf. is_leaf/1
), this
-%% is the empty list, otherwise the result is always a nonempty list,
-%% containing the lists of subtrees of Node
, in
-%% left-to-right order as they occur in the printed program text, and
-%% grouped by category. Often, each group contains only a single
-%% subtree.
-%%
-%% Depending on the type of Node
, the size of some
-%% groups may be variable (e.g., the group consisting of all the
-%% elements of a tuple), while others always contain the same number
-%% of elements - usually exactly one (e.g., the group containing the
-%% argument expression of a case-expression). Note, however, that the
-%% exact structure of the returned list (for a given node type) should
-%% in general not be depended upon, since it might be subject to
-%% change without notice.
The function subtrees/1
and the constructor functions
-%% make_tree/2
and update_tree/2
can be a
-%% great help if one wants to traverse a syntax tree, visiting all its
-%% subtrees, but treat nodes of the tree in a uniform way in most or all
-%% cases. Using these functions makes this simple, and also assures that
-%% your code is not overly sensitive to extensions of the syntax tree
-%% data type, because any node types not explicitly handled by your code
-%% can be left to a default case.
For example: -%%
-%% postorder(F, Tree) -> -%% F(case subtrees(Tree) of -%% [] -> Tree; -%% List -> update_tree(Tree, -%% [[postorder(F, Subtree) -%% || Subtree <- Group] -%% || Group <- List]) -%% end). -%%-%% maps the function
F
on Tree
and all its
-%% subtrees, doing a post-order traversal of the syntax tree. (Note
-%% the use of update_tree/2
to preserve annotations.) For
-%% a simple function like:
-%% -%% f(Node) -> -%% case type(Node) of -%% atom -> atom("a_" ++ atom_name(Node)); -%% _ -> Node -%% end. -%%-%% the call
postorder(fun f/1, Tree)
will yield a new
-%% representation of Tree
in which all atom names have
-%% been extended with the prefix "a_", but nothing else (including
-%% annotations) has been changed.
-%%
-%% @see is_leaf/1
-%% @see make_tree/2
-%% @see update_tree/2
-
-subtrees(T) ->
- case is_leaf(T) of
- true ->
- [];
- false ->
- case type(T) of
- values ->
- [values_es(T)];
- binary ->
- [binary_segments(T)];
- bitstr ->
- [[bitstr_val(T)], [bitstr_size(T)],
- [bitstr_unit(T)], [bitstr_type(T)],
- [bitstr_flags(T)]];
- cons ->
- [[cons_hd(T)], [cons_tl(T)]];
- tuple ->
- [tuple_es(T)];
- 'let' ->
- [let_vars(T), [let_arg(T)], [let_body(T)]];
- seq ->
- [[seq_arg(T)], [seq_body(T)]];
- apply ->
- [[apply_op(T)], apply_args(T)];
- call ->
- [[call_module(T)], [call_name(T)],
- call_args(T)];
- primop ->
- [[primop_name(T)], primop_args(T)];
- 'case' ->
- [[case_arg(T)], case_clauses(T)];
- clause ->
- [clause_pats(T), [clause_guard(T)],
- [clause_body(T)]];
- alias ->
- [[alias_var(T)], [alias_pat(T)]];
- 'fun' ->
- [fun_vars(T), [fun_body(T)]];
- 'receive' ->
- [receive_clauses(T), [receive_timeout(T)],
- [receive_action(T)]];
- 'try' ->
- [[try_arg(T)], try_vars(T), [try_body(T)],
- try_evars(T), [try_handler(T)]];
- 'catch' ->
- [[catch_body(T)]];
- letrec ->
- Es = unfold_tuples(letrec_defs(T)),
- [Es, [letrec_body(T)]];
- module ->
- As = unfold_tuples(module_attrs(T)),
- Es = unfold_tuples(module_defs(T)),
- [[module_name(T)], module_exports(T), As, Es]
- end
- end.
-
-
-%% @spec update_tree(Old::cerl(), Groups::[[cerl()]]) -> cerl()
-%%
-%% @doc Creates a syntax tree with the given subtrees, and the same
-%% type and annotations as the Old
node. This is
-%% equivalent to ann_make_tree(get_ann(Node), type(Node),
-%% Groups)
, but potentially more efficient.
-%%
-%% @see update_tree/3
-%% @see ann_make_tree/3
-%% @see get_ann/1
-%% @see type/1
-
-update_tree(Node, Gs) ->
- ann_make_tree(get_ann(Node), type(Node), Gs).
-
-
-%% @spec update_tree(Old::cerl(), Type::atom(), Groups::[[cerl()]]) ->
-%% cerl()
-%%
-%% @doc Creates a syntax tree with the given type and subtrees, and
-%% the same annotations as the Old
node. This is
-%% equivalent to ann_make_tree(get_ann(Node), Type,
-%% Groups)
, but potentially more efficient.
-%%
-%% @see update_tree/2
-%% @see ann_make_tree/3
-%% @see get_ann/1
-
-update_tree(Node, Type, Gs) ->
- ann_make_tree(get_ann(Node), Type, Gs).
-
-
-%% @spec make_tree(Type::atom(), Groups::[[cerl()]]) -> cerl()
-%%
-%% @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
). Groups
must be a
-%% nonempty list of groups of syntax trees, representing the
-%% subtrees of a node of the given type, in left-to-right order as
-%% they would occur in the printed program text, grouped by category
-%% as done by subtrees/1
.
-%%
-%% The result of ann_make_tree(get_ann(Node), type(Node),
-%% subtrees(Node))
(cf. update_tree/2
) represents
-%% the same source code text as the original Node
,
-%% assuming that subtrees(Node)
yields a nonempty
-%% list. However, it does not necessarily have the exact same data
-%% representation as Node
.
make_tree/2
for details.
-%%
-%% @see make_tree/2
-
-ann_make_tree(As, values, [Es]) -> ann_c_values(As, Es);
-ann_make_tree(As, binary, [Ss]) -> ann_c_binary(As, Ss);
-ann_make_tree(As, bitstr, [[V],[S],[U],[T],[Fs]]) ->
- ann_c_bitstr(As, V, S, U, T, Fs);
-ann_make_tree(As, cons, [[H], [T]]) -> ann_c_cons(As, H, T);
-ann_make_tree(As, tuple, [Es]) -> ann_c_tuple(As, Es);
-ann_make_tree(As, 'let', [Vs, [A], [B]]) -> ann_c_let(As, Vs, A, B);
-ann_make_tree(As, seq, [[A], [B]]) -> ann_c_seq(As, A, B);
-ann_make_tree(As, apply, [[Op], Es]) -> ann_c_apply(As, Op, Es);
-ann_make_tree(As, call, [[M], [N], Es]) -> ann_c_call(As, M, N, Es);
-ann_make_tree(As, primop, [[N], Es]) -> ann_c_primop(As, N, Es);
-ann_make_tree(As, 'case', [[A], Cs]) -> ann_c_case(As, A, Cs);
-ann_make_tree(As, clause, [Ps, [G], [B]]) -> ann_c_clause(As, Ps, G, B);
-ann_make_tree(As, alias, [[V], [P]]) -> ann_c_alias(As, V, P);
-ann_make_tree(As, 'fun', [Vs, [B]]) -> ann_c_fun(As, Vs, B);
-ann_make_tree(As, 'receive', [Cs, [T], [A]]) ->
- ann_c_receive(As, Cs, T, A);
-ann_make_tree(As, 'try', [[E], Vs, [B], Evs, [H]]) ->
- ann_c_try(As, E, Vs, B, Evs, H);
-ann_make_tree(As, 'catch', [[B]]) -> ann_c_catch(As, B);
-ann_make_tree(As, letrec, [Es, [B]]) ->
- ann_c_letrec(As, fold_tuples(Es), B);
-ann_make_tree(As, module, [[N], Xs, Es, Ds]) ->
- ann_c_module(As, N, Xs, fold_tuples(Es), fold_tuples(Ds)).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec meta(Tree::cerl()) -> cerl()
-%%
-%% @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
-%% same source code text as Tree
(although the actual
-%% data representation may be different). The expression represented
-%% by MetaTree
is implementation independent
-%% with regard to the data structures used by the abstract syntax tree
-%% implementation.
-%%
-%% Any node in Tree
whose node type is
-%% var
(cf. type/1
), and whose list of
-%% annotations (cf. get_ann/1
) contains the atom
-%% meta_var
, will remain unchanged in the resulting tree,
-%% except that exactly one occurrence of meta_var
is
-%% removed from its annotation list.
The main use of the function meta/1
is to transform
-%% a data structure Tree
, which represents a piece of
-%% program code, into a form that is representation independent
-%% when printed. E.g., suppose Tree
represents a
-%% variable named "V". Then (assuming a function print/1
-%% for printing syntax trees), evaluating
-%% print(abstract(Tree))
- simply using
-%% abstract/1
to map the actual data structure onto a
-%% syntax tree representation - would output a string that might look
-%% something like "{var, ..., 'V'}
", which is obviously
-%% dependent on the implementation of the abstract syntax trees. This
-%% could e.g. be useful for caching a syntax tree in a file. However,
-%% in some situations like in a program generator generator (with two
-%% "generator"), it may be unacceptable. Using
-%% print(meta(Tree))
instead would output a
-%% representation independent syntax tree generating
-%% expression; in the above case, something like
-%% "cerl:c_var('V')
".
The implementation tries to generate compact code with respect -%% to literals and lists.
-%% -%% @see abstract/1 -%% @see type/1 -%% @see get_ann/1 - -meta(Node) -> - %% First of all we check for metavariables: - case type(Node) of - var -> - case lists:member(meta_var, get_ann(Node)) of - false -> - meta_0(var, Node); - true -> - %% A meta-variable: remove the first found - %% 'meta_var' annotation, but otherwise leave - %% the node unchanged. - set_ann(Node, lists:delete(meta_var, get_ann(Node))) - end; - Type -> - meta_0(Type, Node) - end. - -meta_0(Type, Node) -> - case get_ann(Node) of - [] -> - meta_1(Type, Node); - As -> - meta_call(set_ann, [meta_1(Type, Node), abstract(As)]) - end. - -meta_1(literal, Node) -> - %% We handle atomic literals separately, to get a bit - %% more compact code. For the rest, we use 'abstract'. - case concrete(Node) of - V when atom(V) -> - meta_call(c_atom, [Node]); - V when integer(V) -> - meta_call(c_int, [Node]); - V when float(V) -> - meta_call(c_float, [Node]); - [] -> - meta_call(c_nil, []); - _ -> - meta_call(abstract, [Node]) - end; -meta_1(var, Node) -> - %% A normal variable or function name. - meta_call(c_var, [abstract(var_name(Node))]); -meta_1(values, Node) -> - meta_call(c_values, - [make_list(meta_list(values_es(Node)))]); -meta_1(binary, Node) -> - meta_call(c_binary, - [make_list(meta_list(binary_segments(Node)))]); -meta_1(bitstr, Node) -> - meta_call(c_bitstr, - [meta(bitstr_val(Node)), - meta(bitstr_size(Node)), - meta(bitstr_unit(Node)), - meta(bitstr_type(Node)), - meta(bitstr_flags(Node))]); -meta_1(cons, Node) -> - %% The list is split up if some sublist has annotatations. If - %% we get exactly one element, we generate a 'c_cons' call - %% instead of 'make_list' to reconstruct the node. - case split_list(Node) of - {[H], none} -> - meta_call(c_cons, [meta(H), meta(c_nil())]); - {[H], Node1} -> - meta_call(c_cons, [meta(H), meta(Node1)]); - {L, none} -> - meta_call(make_list, [make_list(meta_list(L))]); - {L, Node1} -> - meta_call(make_list, - [make_list(meta_list(L)), meta(Node1)]) - end; -meta_1(tuple, Node) -> - meta_call(c_tuple, - [make_list(meta_list(tuple_es(Node)))]); -meta_1('let', Node) -> - meta_call(c_let, - [make_list(meta_list(let_vars(Node))), - meta(let_arg(Node)), meta(let_body(Node))]); -meta_1(seq, Node) -> - meta_call(c_seq, - [meta(seq_arg(Node)), meta(seq_body(Node))]); -meta_1(apply, Node) -> - meta_call(c_apply, - [meta(apply_op(Node)), - make_list(meta_list(apply_args(Node)))]); -meta_1(call, Node) -> - meta_call(c_call, - [meta(call_module(Node)), meta(call_name(Node)), - make_list(meta_list(call_args(Node)))]); -meta_1(primop, Node) -> - meta_call(c_primop, - [meta(primop_name(Node)), - make_list(meta_list(primop_args(Node)))]); -meta_1('case', Node) -> - meta_call(c_case, - [meta(case_arg(Node)), - make_list(meta_list(case_clauses(Node)))]); -meta_1(clause, Node) -> - meta_call(c_clause, - [make_list(meta_list(clause_pats(Node))), - meta(clause_guard(Node)), - meta(clause_body(Node))]); -meta_1(alias, Node) -> - meta_call(c_alias, - [meta(alias_var(Node)), meta(alias_pat(Node))]); -meta_1('fun', Node) -> - meta_call(c_fun, - [make_list(meta_list(fun_vars(Node))), - meta(fun_body(Node))]); -meta_1('receive', Node) -> - meta_call(c_receive, - [make_list(meta_list(receive_clauses(Node))), - meta(receive_timeout(Node)), - meta(receive_action(Node))]); -meta_1('try', Node) -> - meta_call(c_try, - [meta(try_arg(Node)), - make_list(meta_list(try_vars(Node))), - meta(try_body(Node)), - make_list(meta_list(try_evars(Node))), - meta(try_handler(Node))]); -meta_1('catch', Node) -> - meta_call(c_catch, [meta(catch_body(Node))]); -meta_1(letrec, Node) -> - meta_call(c_letrec, - [make_list([c_tuple([meta(N), meta(F)]) - || {N, F} <- letrec_defs(Node)]), - meta(letrec_body(Node))]); -meta_1(module, Node) -> - meta_call(c_module, - [meta(module_name(Node)), - make_list(meta_list(module_exports(Node))), - make_list([c_tuple([meta(A), meta(V)]) - || {A, V} <- module_attrs(Node)]), - make_list([c_tuple([meta(N), meta(F)]) - || {N, F} <- module_defs(Node)])]). - -meta_call(F, As) -> - c_call(c_atom(?MODULE), c_atom(F), As). - -meta_list([T | Ts]) -> - [meta(T) | meta_list(Ts)]; -meta_list([]) -> - []. - -split_list(Node) -> - split_list(set_ann(Node, []), []). - -split_list(Node, L) -> - A = get_ann(Node), - case type(Node) of - cons when A == [] -> - split_list(cons_tl(Node), [cons_hd(Node) | L]); - nil when A == [] -> - {lists:reverse(L), none}; - _ -> - {lists:reverse(L), Node} - end. - - -%% --------------------------------------------------------------------- - -%% General utilities - -is_lit_list([#literal{} | Es]) -> - is_lit_list(Es); -is_lit_list([_ | _]) -> - false; -is_lit_list([]) -> - true. - -lit_list_vals([#literal{val = V} | Es]) -> - [V | lit_list_vals(Es)]; -lit_list_vals([]) -> - []. - -make_lit_list([V | Vs]) -> - [#literal{val = V} | make_lit_list(Vs)]; -make_lit_list([]) -> - []. - -%% The following tests are the same as done by 'io_lib:char_list' and -%% 'io_lib:printable_list', respectively, but for a single character. - -is_char_value(V) when V >= $\000, V =< $\377 -> true; -is_char_value(_) -> false. - -is_print_char_value(V) when V >= $\040, V =< $\176 -> true; -is_print_char_value(V) when V >= $\240, V =< $\377 -> true; -is_print_char_value(V) when V =:= $\b -> true; -is_print_char_value(V) when V =:= $\d -> true; -is_print_char_value(V) when V =:= $\e -> true; -is_print_char_value(V) when V =:= $\f -> true; -is_print_char_value(V) when V =:= $\n -> true; -is_print_char_value(V) when V =:= $\r -> true; -is_print_char_value(V) when V =:= $\s -> true; -is_print_char_value(V) when V =:= $\t -> true; -is_print_char_value(V) when V =:= $\v -> true; -is_print_char_value(V) when V =:= $\" -> true; -is_print_char_value(V) when V =:= $\' -> true; -is_print_char_value(V) when V =:= $\\ -> true; -is_print_char_value(_) -> false. - -is_char_list([V | Vs]) when integer(V) -> - case is_char_value(V) of - true -> - is_char_list(Vs); - false -> - false - end; -is_char_list([]) -> - true; -is_char_list(_) -> - false. - -is_print_char_list([V | Vs]) when integer(V) -> - case is_print_char_value(V) of - true -> - is_print_char_list(Vs); - false -> - false - end; -is_print_char_list([]) -> - true; -is_print_char_list(_) -> - false. - -unfold_tuples([{X, Y} | Ps]) -> - [X, Y | unfold_tuples(Ps)]; -unfold_tuples([]) -> - []. - -fold_tuples([X, Y | Es]) -> - [{X, Y} | fold_tuples(Es)]; -fold_tuples([]) -> - []. diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/cerl_clauses.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/cerl_clauses.erl deleted file mode 100644 index f207178f13..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/cerl_clauses.erl +++ /dev/null @@ -1,409 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Richard Carlsson. -%% Copyright (C) 1999-2002 Richard Carlsson. -%% Portions created by Ericsson are Copyright 2001, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: cerl_clauses.erl,v 1.2 2009/09/17 09:46:19 kostis Exp $ - -%% @doc Utility functions for Core Erlang case/receive clauses. -%% -%%Syntax trees are defined in the module cerl
.
true
if an abstract clause is a
-%% catch-all, otherwise false
. A clause is a catch-all if
-%% all its patterns are variables, and its guard expression always
-%% evaluates to true
; cf. eval_guard/1
.
-%%
-%% Note: Clause
must have type
-%% clause
.
true
if any of the abstract clauses in
-%% the list is a catch-all, otherwise false
. See
-%% is_catchall/1
for details.
-%%
-%% Note: each node in Clauses
must have type
-%% clause
.
{value, Term}
if the
-%% guard expression Expr
always yields the constant value
-%% Term
, and is otherwise none
.
-%%
-%% Note that although guard expressions should only yield boolean
-%% values, this function does not guarantee that Term
is
-%% either true
or false
. Also note that only
-%% simple constructs like let-expressions are examined recursively;
-%% general constant folding is not performed.
Clauses
-%% of abstract clauses (i.e., syntax trees of type clause
),
-%% and a list of switch expressions Exprs
. The function
-%% tries to uniquely select a single clause or discard unselectable
-%% clauses, with respect to the switch expressions. All abstract clauses
-%% in the list must have the same number of patterns. If
-%% Exprs
is not the empty list, it must have the same
-%% length as the number of patterns in each clause; see
-%% match_list/2
for details.
-%%
-%% A clause can only be selected if its guard expression always
-%% yields the atom true
, and a clause whose guard
-%% expression always yields the atom false
can never be
-%% selected. Other guard expressions are considered to have unknown
-%% value; cf. eval_guard/1
.
If a particular clause can be selected, the function returns
-%% {true, {Clause, Bindings}}
, where Clause
is
-%% the selected clause and Bindings
is a list of pairs
-%% {Var, SubExpr}
associating the variables occurring in
-%% the patterns of Clause
with the corresponding
-%% subexpressions in Exprs
. The list of bindings is given
-%% in innermost-first order; see the match/2
function for
-%% details.
If no clause could be definitely selected, the function returns
-%% {false, NewClauses}
, where NewClauses
is
-%% the list of entries in Clauses
that remain after
-%% eliminating unselectable clauses, preserving the relative order.
none
if a match is impossible, {true,
-%% Bindings}
if Pattern
definitely matches
-%% Expr
, and {false, Bindings}
if a match is
-%% not definite, but cannot be excluded. Bindings
is then
-%% a list of pairs {Var, SubExpr}
, associating each
-%% variable in the pattern with either the corresponding subexpression
-%% of Expr
, or with the atom any
if no
-%% matching subexpression exists. (Recall that variables may not be
-%% repeated in a Core Erlang pattern.) The list of bindings is given
-%% in innermost-first order; this should only be of interest if
-%% Pattern
contains one or more alias patterns. If the
-%% returned value is {true, []}
, it implies that the
-%% pattern and the expression are syntactically identical.
-%%
-%% Instead of a syntax tree, the atom any
can be
-%% passed for Expr
(or, more generally, be used for any
-%% subtree of Expr
, in as much the abstract syntax tree
-%% implementation allows it); this means that it cannot be decided
-%% whether the pattern will match or not, and the corresponding
-%% variable bindings will all map to any
. The typical use
-%% is for producing bindings for receive
clauses.
Note: Binary-syntax patterns are never structurally matched -%% against binary-syntax expressions by this function.
-%% -%%Examples: -%%
{X, Y}
" against the
-%% expression "{foo, f(Z)}
" yields {true,
-%% Bindings}
where Bindings
associates
-%% "X
" with the subtree "foo
" and
-%% "Y
" with the subtree "f(Z)
".{X, {bar, Y}}
" against
-%% expression "{foo, f(Z)}
" yields {false,
-%% Bindings}
where Bindings
associates
-%% "X
" with the subtree "foo
" and
-%% "Y
" with any
(because it is not known
-%% if "{foo, Y}
" might match the run-time value of
-%% "f(Z)
" or not).{foo, bar}
" against expression
-%% "{foo, f()}
" yields {false, []}
,
-%% telling us that there might be a match, but we cannot deduce any
-%% bindings.{foo, X = {bar, Y}}
against expression
-%% "{foo, {bar, baz}}
" yields {true,
-%% Bindings}
where Bindings
associates
-%% "Y
" with "baz
", and "X
"
-%% with "{bar, baz}
".{X, Y}
" against
-%% any
yields {false, Bindings}
where
-%% Bindings
associates both "X
" and
-%% "Y
" with any
.match/2
, but matching a sequence of patterns
-%% against a sequence of expressions. Passing an empty list for
-%% Exprs
is equivalent to passing a list of
-%% any
atoms of the same length as Patterns
.
-%%
-%% @see match/2
-
-match_list([], []) ->
- {true, []}; % no patterns always match
-match_list(Ps, []) ->
- match_list(Ps, lists:duplicate(length(Ps), any), []);
-match_list(Ps, Es) ->
- match_list(Ps, Es, []).
-
-match_list([P | Ps], [E | Es], Bs) ->
- case match(P, E, Bs) of
- {true, Bs1} ->
- match_list(Ps, Es, Bs1);
- {false, Bs1} ->
- %% Make sure "maybe" is preserved
- case match_list(Ps, Es, Bs1) of
- {_, Bs2} ->
- {false, Bs2};
- none ->
- none
- end;
- none ->
- none
- end;
-match_list([], [], Bs) ->
- {true, Bs}.
diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/cerl_inline.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/cerl_inline.erl
deleted file mode 100644
index e040904a19..0000000000
--- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/cerl_inline.erl
+++ /dev/null
@@ -1,2762 +0,0 @@
-%% ``The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved via the world wide web at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% The Initial Developer of the Original Code is Richard Carlsson.
-%% Copyright (C) 1999-2002 Richard Carlsson.
-%% Portions created by Ericsson are Copyright 2001, Ericsson Utvecklings
-%% AB. All Rights Reserved.''
-%%
-%% $Id: cerl_inline.erl,v 1.1 2008/12/17 09:53:41 mikpe Exp $
-%%
-%% Core Erlang inliner.
-
-%% =====================================================================
-%%
-%% This is an implementation of the algorithm by Waddell and Dybvig
-%% ("Fast and Effective Procedure Inlining", International Static
-%% Analysis Symposium 1997), adapted to the Core Erlang language.
-%%
-%% Instead of always renaming variables and function variables, this
-%% implementation uses the "no-shadowing strategy" of Peyton Jones and
-%% Marlow ("Secrets of the Glasgow Haskell Compiler Inliner", 1999).
-%%
-%% =====================================================================
-
-%% TODO: inline single-source-reference operands without size limit.
-
--module(cerl_inline).
-
--export([core_transform/2, transform/1, transform/2]).
-
--import(cerl, [abstract/1, alias_pat/1, alias_var/1, apply_args/1,
- apply_op/1, atom_name/1, atom_val/1, bitstr_val/1,
- bitstr_size/1, bitstr_unit/1, bitstr_type/1,
- bitstr_flags/1, binary_segments/1, update_c_alias/3,
- update_c_apply/3, update_c_binary/2, update_c_bitstr/6,
- update_c_call/4, update_c_case/3, update_c_catch/2,
- update_c_clause/4, c_fun/2, c_int/1, c_let/3,
- update_c_let/4, update_c_letrec/3, update_c_module/5,
- update_c_primop/3, update_c_receive/4, update_c_seq/3,
- c_seq/2, update_c_try/6, c_tuple/1, update_c_values/2,
- c_values/1, c_var/1, call_args/1, call_module/1,
- call_name/1, case_arity/1, case_arg/1, case_clauses/1,
- catch_body/1, clause_body/1, clause_guard/1,
- clause_pats/1, clause_vars/1, concrete/1, cons_hd/1,
- cons_tl/1, data_arity/1, data_es/1, data_type/1,
- fun_body/1, fun_vars/1, get_ann/1, int_val/1,
- is_c_atom/1, is_c_cons/1, is_c_fun/1, is_c_int/1,
- is_c_list/1, is_c_seq/1, is_c_tuple/1, is_c_var/1,
- is_data/1, is_literal/1, is_literal_term/1, let_arg/1,
- let_body/1, let_vars/1, letrec_body/1, letrec_defs/1,
- list_length/1, list_elements/1, update_data/3,
- make_list/1, make_data_skel/2, module_attrs/1,
- module_defs/1, module_exports/1, module_name/1,
- primop_args/1, primop_name/1, receive_action/1,
- receive_clauses/1, receive_timeout/1, seq_arg/1,
- seq_body/1, set_ann/2, try_arg/1, try_body/1, try_vars/1,
- try_evars/1, try_handler/1, tuple_es/1, tuple_arity/1,
- type/1, values_es/1, var_name/1]).
-
--import(lists, [foldl/3, foldr/3, mapfoldl/3, reverse/1]).
-
-%%
-%% Constants
-%%
-
-debug_runtime() -> false.
-debug_counters() -> false.
-
-%% Normal execution times for inlining are between 0.1 and 0.3 seconds
-%% (on the author's current equipment). The default effort limit of 150
-%% is high enough that most normal programs never hit the limit even
-%% once, and for difficult programs, it generally keeps the execution
-%% times below 2-5 seconds. Using an effort counter of 1000 will thus
-%% have no further effect on most programs, but some programs may take
-%% as much as 10 seconds or more. Effort counts larger than 2500 have
-%% never been observed even on very ill-conditioned programs.
-%%
-%% Size limits between 6 and 18 tend to actually shrink the code,
-%% because of the simplifications made possible by inlining. A limit of
-%% 16 seems to be optimal for this purpose, often shrinking the
-%% executable code by up to 10%. Size limits between 18 and 30 generally
-%% give the same code size as if no inlining was done (i.e., code
-%% duplication balances out the simplifications at these levels). A size
-%% limit between 1 and 5 tends to inline small functions and propagate
-%% constants, but does not cause much simplifications do be done, so the
-%% net effect will be a slight increase in code size. For size limits
-%% above 30, the executable code size tends to increase with about 10%
-%% per 100 units, with some variations depending on the sizes of
-%% functions in the source code.
-%%
-%% Typically, about 90% of the maximum speedup achievable is already
-%% reached using a size limit of 30, and 98% is reached at limits around
-%% 100-150; there is rarely any point in letting the code size increase
-%% by more than 10-15%. If too large functions are inlined, cache
-%% effects will slow the program down.
-
-default_effort() -> 150.
-default_size() -> 24.
-
-%% Base costs/weights for different kinds of expressions. If these are
-%% modified, the size limits above may have to be adjusted.
-
-weight(var) -> 0; % We count no cost for variable accesses.
-weight(values) -> 0; % Value aggregates have no cost in themselves.
-weight(literal) -> 1; % We assume efficient handling of constants.
-weight(data) -> 1; % Base cost; add 1 per element.
-weight(element) -> 1; % Cost of storing/fetching an element.
-weight(argument) -> 1; % Cost of passing a function argument.
-weight('fun') -> 6; % Base cost + average number of free vars.
-weight('let') -> 0; % Count no cost for let-bindings.
-weight(letrec) -> 0; % Like a let-binding.
-weight('case') -> 0; % Case switches have no base cost.
-weight(clause) -> 1; % Count one jump at the end of each clause body.
-weight('receive') -> 9; % Initialization/cleanup cost.
-weight('try') -> 1; % Assume efficient implementation.
-weight('catch') -> 1; % See `try'.
-weight(apply) -> 3; % Average base cost: call/return.
-weight(call) -> 3; % Assume remote-calls as efficient as `apply'.
-weight(primop) -> 2; % Assume more efficient than `apply'.
-weight(binary) -> 4; % Initialisation base cost.
-weight(bitstr) -> 3; % Coding/decoding a value; like a primop.
-weight(module) -> 1. % Like a letrec with a constant body
-
-%% These "reference" structures are used for variables and function
-%% variables. They keep track of the variable name, any bound operand,
-%% and the associated store location.
-
--record(ref, {name, opnd, loc}).
-
-%% Operand structures contain the operand expression, the renaming and
-%% environment, the state location, and the effort counter at the call
-%% site (cf. `visit').
-
--record(opnd, {expr, ren, env, loc, effort}).
-
-%% Since expressions are only visited in `effect' context when they are
-%% not bound to a referenced variable, only expressions visited in
-%% 'value' context are cached.
-
--record(cache, {expr, size}).
-
-%% The context flags for an application structure are kept separate from
-%% the structure itself. Note that the original algorithm had exactly
-%% one operand in each application context structure, while we can have
-%% several, or none.
-
--record(app, {opnds, ctxt, loc}).
-
-
-%%
-%% Interface functions
-%%
-
-%% Use compile option `{core_transform, inline}' to insert this as a
-%% compilation pass.
-
-core_transform(Code, Opts) ->
- cerl:to_records(transform(cerl:from_records(Code), Opts)).
-
-transform(Tree) ->
- transform(Tree, []).
-
-transform(Tree, Opts) ->
- main(Tree, value, Opts).
-
-main(Tree, Ctxt, Opts) ->
- %% We spawn a new process to do the work, so we don't have to worry
- %% about cluttering the process dictionary with debugging info, or
- %% proper deallocation of ets-tables.
- Opts1 = Opts ++ [{inline_size, default_size()},
- {inline_effort, default_effort()}],
- Reply = self(),
- Pid = spawn_link(fun () -> start(Reply, Tree, Ctxt, Opts1) end),
- receive
- {Pid1, Tree1} when Pid1 == Pid ->
- Tree1
- end.
-
-start(Reply, Tree, Ctxt, Opts) ->
- init_debug(),
- case debug_runtime() of
- true ->
- put(inline_start_time,
- element(1, erlang:statistics(runtime)));
- _ ->
- ok
- end,
- Size = max(1, proplists:get_value(inline_size, Opts)),
- Effort = max(1, proplists:get_value(inline_effort, Opts)),
- case proplists:get_bool(verbose, Opts) of
- true ->
- io:fwrite("Inlining: inline_size=~w inline_effort=~w\n",
- [Size, Effort]);
- false ->
- ok
- end,
-
- %% Note that the counters of the new state are passive.
- S = st__new(Effort, Size),
-
-%%% Initialization is not needed at present. Note that the code in
-%%% `inline_init' is not up-to-date with this module.
-%%% {Tree1, S1} = inline_init:init(Tree, S),
-%%% {Tree2, _S2} = i(Tree1, Ctxt, S1),
- {Tree2, _S2} = i(Tree, Ctxt, S),
- report_debug(),
- Reply ! {self(), Tree2}.
-
-init_debug() ->
- case debug_counters() of
- true ->
- put(counter_effort_triggers, 0),
- put(counter_effort_max, 0),
- put(counter_size_triggers, 0),
- put(counter_size_max, 0);
- _ ->
- ok
- end.
-
-report_debug() ->
- case debug_runtime() of
- true ->
- {Time, _} = erlang:statistics(runtime),
- report("Total run time for inlining: ~.2.0f s.\n",
- [(Time - get(inline_start_time))/1000]);
- _ ->
- ok
- end,
- case debug_counters() of
- true ->
- counter_stats();
- _ ->
- ok
- end.
-
-counter_stats() ->
- T1 = get(counter_effort_triggers),
- T2 = get(counter_size_triggers),
- E = get(counter_effort_max),
- S = get(counter_size_max),
- M1 = io_lib:fwrite("\tNumber of triggered "
- "effort counters: ~p.\n", [T1]),
- M2 = io_lib:fwrite("\tNumber of triggered "
- "size counters: ~p.\n", [T2]),
- M3 = io_lib:fwrite("\tLargest active effort counter: ~p.\n",
- [E]),
- M4 = io_lib:fwrite("\tLargest active size counter: ~p.\n",
- [S]),
- report("Counter statistics:\n~s", [[M1, M2, M3, M4]]).
-
-
-%% =====================================================================
-%% The main inlining function
-%%
-%% i(E :: coreErlang(),
-%% Ctxt :: value | effect | #app{}
-%% Ren :: renaming(),
-%% Env :: environment(),
-%% S :: state())
-%% -> {E', S'}
-%%
-%% Note: It is expected that the input source code ('E') does not
-%% contain free variables. If it does, there is a risk of accidental
-%% name capture, in case a generated "new" variable name happens to be
-%% the same as the name of a variable that is free further below in the
-%% tree; the algorithm only consults the current environment to check if
-%% a name already exists.
-%%
-%% The renaming maps names of source-code variable and function
-%% variables to new names as necessary to avoid clashes, according to
-%% the "no-shadowing" strategy. The environment maps *residual-code*
-%% variables and function variables to operands and global information.
-%% Separating the renaming from the environment, and using the
-%% residual-code variables instead of the source-code variables as its
-%% domain, improves the behaviour of the algorithm when code needs to be
-%% traversed more than once.
-%%
-%% Note that there is no such thing as a `test' context for expressions
-%% in (Core) Erlang (see `i_case' below for details).
-
-i(E, Ctxt, S) ->
- i(E, Ctxt, ren__identity(), env__empty(), S).
-
-i(E, Ctxt, Ren, Env, S0) ->
- %% Count one unit of effort on each pass.
- S = count_effort(1, S0),
- case is_data(E) of
- true ->
- i_data(E, Ctxt, Ren, Env, S);
- false ->
- case type(E) of
- var ->
- i_var(E, Ctxt, Ren, Env, S);
- values ->
- i_values(E, Ctxt, Ren, Env, S);
- 'fun' ->
- i_fun(E, Ctxt, Ren, Env, S);
- seq ->
- i_seq(E, Ctxt, Ren, Env, S);
- 'let' ->
- i_let(E, Ctxt, Ren, Env, S);
- letrec ->
- i_letrec(E, Ctxt, Ren, Env, S);
- 'case' ->
- i_case(E, Ctxt, Ren, Env, S);
- 'receive' ->
- i_receive(E, Ctxt, Ren, Env, S);
- apply ->
- i_apply(E, Ctxt, Ren, Env, S);
- call ->
- i_call(E, Ctxt, Ren, Env, S);
- primop ->
- i_primop(E, Ren, Env, S);
- 'try' ->
- i_try(E, Ctxt, Ren, Env, S);
- 'catch' ->
- i_catch(E, Ctxt, Ren, Env, S);
- binary ->
- i_binary(E, Ren, Env, S);
- module ->
- i_module(E, Ctxt, Ren, Env, S)
- end
- end.
-
-i_data(E, Ctxt, Ren, Env, S) ->
- case is_literal(E) of
- true ->
- %% This is the `(const c)' case of the original algorithm:
- %% literal terms which (regardless of size) do not need to
- %% be constructed dynamically at runtime - boldly assuming
- %% that the compiler/runtime system can handle this.
- case Ctxt of
- effect ->
- %% Reduce useless constants to a simple value.
- {void(), count_size(weight(literal), S)};
- _ ->
- %% (In Erlang, we cannot set all non-`false'
- %% constants to `true' in a `test' context, like we
- %% could do in Lisp or C, so the above is the only
- %% special case to be handled here.)
- {E, count_size(weight(literal), S)}
- end;
- false ->
- %% Data constructors are like to calls to safe built-in
- %% functions, for which we can "decide to inline"
- %% immediately; there is no need to create operand
- %% structures. In `effect' context, we can simply make a
- %% sequence of the argument expressions, also visited in
- %% `effect' context. In all other cases, the arguments are
- %% visited for value.
- case Ctxt of
- effect ->
- %% Note that this will count the sizes of the
- %% subexpressions, even though some or all of them
- %% might be discarded by the sequencing afterwards.
- {Es1, S1} = mapfoldl(fun (E, S) ->
- i(E, effect, Ren, Env,
- S)
- end,
- S, data_es(E)),
- E1 = foldl(fun (E1, E2) -> make_seq(E1, E2) end,
- void(), Es1),
- {E1, S1};
- _ ->
- {Es1, S1} = mapfoldl(fun (E, S) ->
- i(E, value, Ren, Env,
- S)
- end,
- S, data_es(E)),
- %% The total size/cost is the base cost for a data
- %% constructor plus the cost for storing each
- %% element.
- N = weight(data) + length(Es1) * weight(element),
- S2 = count_size(N, S1),
- {update_data(E, data_type(E), Es1), S2}
- end
- end.
-
-%% This is the `(ref x)' (variable use) case of the original algorithm.
-%% Note that binding occurrences are always handled in the respective
-%% cases of the binding constructs.
-
-i_var(E, Ctxt, Ren, Env, S) ->
- case Ctxt of
- effect ->
- %% Reduce useless variable references to a simple constant.
- %% This also avoids useless visiting of bound operands.
- {void(), count_size(weight(literal), S)};
- _ ->
- Name = var_name(E),
- case env__lookup(ren__map(Name, Ren), Env) of
- {ok, R} ->
- case R#ref.opnd of
- undefined ->
- %% The variable is not associated with an
- %% argument expression; just residualize it.
- residualize_var(R, S);
- Opnd ->
- i_var_1(R, Opnd, Ctxt, Env, S)
- end;
- error ->
- %% The variable is unbound. (It has not been
- %% accidentally captured, however, or it would have
- %% been in the environment.) We leave it as it is,
- %% without any warning.
- {E, count_size(weight(var), S)}
- end
- end.
-
-%% This first visits the bound operand and then does copy propagation.
-%% Note that we must first set the "inner-pending" flag, and clear the
-%% flag afterwards.
-
-i_var_1(R, Opnd, Ctxt, Env, S) ->
- %% If the operand is already "inner-pending", it is residualised.
- %% (In Lisp/C, if the variable might be assigned to, it should also
- %% be residualised.)
- L = Opnd#opnd.loc,
- case st__test_inner_pending(L, S) of
- true ->
- residualize_var(R, S);
- false ->
- S1 = st__mark_inner_pending(L, S),
- case catch {ok, visit(Opnd, S1)} of
- {ok, {E, S2}} ->
- %% Note that we pass the current environment and
- %% context to `copy', but not the current renaming.
- S3 = st__clear_inner_pending(L, S2),
- copy(R, Opnd, E, Ctxt, Env, S3);
- {'EXIT', X} ->
- exit(X);
- X ->
- %% If we use destructive update for the
- %% `inner-pending' flag, we must make sure to clear
- %% it also if we make a nonlocal return.
- st__clear_inner_pending(Opnd#opnd.loc, S1),
- throw(X)
- end
- end.
-
-%% A multiple-value aggregate `Syntax trees are defined in the module cerl
.
{foo,
-%% bar}
" has depth one, etc.
-
-depth(T) ->
- case subtrees(T) of
- [] ->
- 0;
- Gs ->
- 1 + lists:foldl(fun (G, A) -> erlang:max(depth_1(G), A) end, 0, Gs)
- end.
-
-depth_1(Ts) ->
- lists:foldl(fun (T, A) -> erlang:max(depth(T), A) end, 0, Ts).
-
-%% max(X, Y) when X > Y -> X;
-%% max(_, Y) -> Y.
-
-
-%% @spec size(Tree::cerl()) -> integer()
-%%
-%% @doc Returns the number of nodes in Tree
.
-
-size(T) ->
- fold(fun (_, S) -> S + 1 end, 0, T).
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec map(Function, Tree::cerl()) -> cerl()
-%%
-%% Function = (cerl()) -> cerl()
-%%
-%% @doc Maps a function onto the nodes of a tree. This replaces each
-%% node in the tree by the result of applying the given function on
-%% the original node, bottom-up.
-%%
-%% @see mapfold/3
-
-map(F, T) ->
- F(map_1(F, T)).
-
-map_1(F, T) ->
- case type(T) of
- literal ->
- case concrete(T) of
- [_ | _] ->
- update_c_cons(T, map(F, cons_hd(T)),
- map(F, cons_tl(T)));
- V when tuple_size(V) > 0 ->
- update_c_tuple(T, map_list(F, tuple_es(T)));
- _ ->
- T
- end;
- var ->
- T;
- values ->
- update_c_values(T, map_list(F, values_es(T)));
- cons ->
- update_c_cons_skel(T, map(F, cons_hd(T)),
- map(F, cons_tl(T)));
- tuple ->
- update_c_tuple_skel(T, map_list(F, tuple_es(T)));
- 'let' ->
- update_c_let(T, map_list(F, let_vars(T)),
- map(F, let_arg(T)),
- map(F, let_body(T)));
- seq ->
- update_c_seq(T, map(F, seq_arg(T)),
- map(F, seq_body(T)));
- apply ->
- update_c_apply(T, map(F, apply_op(T)),
- map_list(F, apply_args(T)));
- call ->
- update_c_call(T, map(F, call_module(T)),
- map(F, call_name(T)),
- map_list(F, call_args(T)));
- primop ->
- update_c_primop(T, map(F, primop_name(T)),
- map_list(F, primop_args(T)));
- 'case' ->
- update_c_case(T, map(F, case_arg(T)),
- map_list(F, case_clauses(T)));
- clause ->
- update_c_clause(T, map_list(F, clause_pats(T)),
- map(F, clause_guard(T)),
- map(F, clause_body(T)));
- alias ->
- update_c_alias(T, map(F, alias_var(T)),
- map(F, alias_pat(T)));
- 'fun' ->
- update_c_fun(T, map_list(F, fun_vars(T)),
- map(F, fun_body(T)));
- 'receive' ->
- update_c_receive(T, map_list(F, receive_clauses(T)),
- map(F, receive_timeout(T)),
- map(F, receive_action(T)));
- 'try' ->
- update_c_try(T, map(F, try_arg(T)),
- map_list(F, try_vars(T)),
- map(F, try_body(T)),
- map_list(F, try_evars(T)),
- map(F, try_handler(T)));
- 'catch' ->
- update_c_catch(T, map(F, catch_body(T)));
- binary ->
- update_c_binary(T, map_list(F, binary_segments(T)));
- bitstr ->
- update_c_bitstr(T, map(F, bitstr_val(T)),
- map(F, bitstr_size(T)),
- map(F, bitstr_unit(T)),
- map(F, bitstr_type(T)),
- map(F, bitstr_flags(T)));
- letrec ->
- update_c_letrec(T, map_pairs(F, letrec_defs(T)),
- map(F, letrec_body(T)));
- module ->
- update_c_module(T, map(F, module_name(T)),
- map_list(F, module_exports(T)),
- map_pairs(F, module_attrs(T)),
- map_pairs(F, module_defs(T)))
- end.
-
-map_list(F, [T | Ts]) ->
- [map(F, T) | map_list(F, Ts)];
-map_list(_, []) ->
- [].
-
-map_pairs(F, [{T1, T2} | Ps]) ->
- [{map(F, T1), map(F, T2)} | map_pairs(F, Ps)];
-map_pairs(_, []) ->
- [].
-
-
-%% @spec fold(Function, Unit::term(), Tree::cerl()) -> term()
-%%
-%% Function = (cerl(), term()) -> term()
-%%
-%% @doc Does a fold operation over the nodes of the tree. The result
-%% is the value of Function(X1, Function(X2, ... Function(Xn,
-%% Unit) ... ))
, where X1, ..., Xn
are the nodes
-%% of Tree
in a post-order traversal.
-%%
-%% @see mapfold/3
-
-fold(F, S, T) ->
- F(T, fold_1(F, S, T)).
-
-fold_1(F, S, T) ->
- case type(T) of
- literal ->
- case concrete(T) of
- [_ | _] ->
- fold(F, fold(F, S, cons_hd(T)), cons_tl(T));
- V when tuple_size(V) > 0 ->
- fold_list(F, S, tuple_es(T));
- _ ->
- S
- end;
- var ->
- S;
- values ->
- fold_list(F, S, values_es(T));
- cons ->
- fold(F, fold(F, S, cons_hd(T)), cons_tl(T));
- tuple ->
- fold_list(F, S, tuple_es(T));
- 'let' ->
- fold(F, fold(F, fold_list(F, S, let_vars(T)),
- let_arg(T)),
- let_body(T));
- seq ->
- fold(F, fold(F, S, seq_arg(T)), seq_body(T));
- apply ->
- fold_list(F, fold(F, S, apply_op(T)), apply_args(T));
- call ->
- fold_list(F, fold(F, fold(F, S, call_module(T)),
- call_name(T)),
- call_args(T));
- primop ->
- fold_list(F, fold(F, S, primop_name(T)), primop_args(T));
- 'case' ->
- fold_list(F, fold(F, S, case_arg(T)), case_clauses(T));
- clause ->
- fold(F, fold(F, fold_list(F, S, clause_pats(T)),
- clause_guard(T)),
- clause_body(T));
- alias ->
- fold(F, fold(F, S, alias_var(T)), alias_pat(T));
- 'fun' ->
- fold(F, fold_list(F, S, fun_vars(T)), fun_body(T));
- 'receive' ->
- fold(F, fold(F, fold_list(F, S, receive_clauses(T)),
- receive_timeout(T)),
- receive_action(T));
- 'try' ->
- fold(F, fold_list(F, fold(F, fold_list(F, fold(F, S, try_arg(T)),
- try_vars(T)),
- try_body(T)),
- try_evars(T)),
- try_handler(T));
- 'catch' ->
- fold(F, S, catch_body(T));
- binary ->
- fold_list(F, S, binary_segments(T));
- bitstr ->
- fold(F,
- fold(F,
- fold(F,
- fold(F,
- fold(F, S, bitstr_val(T)),
- bitstr_size(T)),
- bitstr_unit(T)),
- bitstr_type(T)),
- bitstr_flags(T));
- letrec ->
- fold(F, fold_pairs(F, S, letrec_defs(T)), letrec_body(T));
- module ->
- fold_pairs(F,
- fold_pairs(F,
- fold_list(F,
- fold(F, S, module_name(T)),
- module_exports(T)),
- module_attrs(T)),
- module_defs(T))
- end.
-
-fold_list(F, S, [T | Ts]) ->
- fold_list(F, fold(F, S, T), Ts);
-fold_list(_, S, []) ->
- S.
-
-fold_pairs(F, S, [{T1, T2} | Ps]) ->
- fold_pairs(F, fold(F, fold(F, S, T1), T2), Ps);
-fold_pairs(_, S, []) ->
- S.
-
-
-%% @spec mapfold(Function, Initial::term(), Tree::cerl()) ->
-%% {cerl(), term()}
-%%
-%% Function = (cerl(), term()) -> {cerl(), term()}
-%%
-%% @doc Does a combined map/fold operation on the nodes of the
-%% tree. This is similar to map/2
, but also propagates a
-%% value from each application of Function
to the next,
-%% starting with the given value Initial
, while doing a
-%% post-order traversal of the tree, much like fold/3
.
-%%
-%% @see map/2
-%% @see fold/3
-
-mapfold(F, S0, T) ->
- case type(T) of
- literal ->
- case concrete(T) of
- [_ | _] ->
- {T1, S1} = mapfold(F, S0, cons_hd(T)),
- {T2, S2} = mapfold(F, S1, cons_tl(T)),
- F(update_c_cons(T, T1, T2), S2);
- V when tuple_size(V) > 0 ->
- {Ts, S1} = mapfold_list(F, S0, tuple_es(T)),
- F(update_c_tuple(T, Ts), S1);
- _ ->
- F(T, S0)
- end;
- var ->
- F(T, S0);
- values ->
- {Ts, S1} = mapfold_list(F, S0, values_es(T)),
- F(update_c_values(T, Ts), S1);
- cons ->
- {T1, S1} = mapfold(F, S0, cons_hd(T)),
- {T2, S2} = mapfold(F, S1, cons_tl(T)),
- F(update_c_cons_skel(T, T1, T2), S2);
- tuple ->
- {Ts, S1} = mapfold_list(F, S0, tuple_es(T)),
- F(update_c_tuple_skel(T, Ts), S1);
- 'let' ->
- {Vs, S1} = mapfold_list(F, S0, let_vars(T)),
- {A, S2} = mapfold(F, S1, let_arg(T)),
- {B, S3} = mapfold(F, S2, let_body(T)),
- F(update_c_let(T, Vs, A, B), S3);
- seq ->
- {A, S1} = mapfold(F, S0, seq_arg(T)),
- {B, S2} = mapfold(F, S1, seq_body(T)),
- F(update_c_seq(T, A, B), S2);
- apply ->
- {E, S1} = mapfold(F, S0, apply_op(T)),
- {As, S2} = mapfold_list(F, S1, apply_args(T)),
- F(update_c_apply(T, E, As), S2);
- call ->
- {M, S1} = mapfold(F, S0, call_module(T)),
- {N, S2} = mapfold(F, S1, call_name(T)),
- {As, S3} = mapfold_list(F, S2, call_args(T)),
- F(update_c_call(T, M, N, As), S3);
- primop ->
- {N, S1} = mapfold(F, S0, primop_name(T)),
- {As, S2} = mapfold_list(F, S1, primop_args(T)),
- F(update_c_primop(T, N, As), S2);
- 'case' ->
- {A, S1} = mapfold(F, S0, case_arg(T)),
- {Cs, S2} = mapfold_list(F, S1, case_clauses(T)),
- F(update_c_case(T, A, Cs), S2);
- clause ->
- {Ps, S1} = mapfold_list(F, S0, clause_pats(T)),
- {G, S2} = mapfold(F, S1, clause_guard(T)),
- {B, S3} = mapfold(F, S2, clause_body(T)),
- F(update_c_clause(T, Ps, G, B), S3);
- alias ->
- {V, S1} = mapfold(F, S0, alias_var(T)),
- {P, S2} = mapfold(F, S1, alias_pat(T)),
- F(update_c_alias(T, V, P), S2);
- 'fun' ->
- {Vs, S1} = mapfold_list(F, S0, fun_vars(T)),
- {B, S2} = mapfold(F, S1, fun_body(T)),
- F(update_c_fun(T, Vs, B), S2);
- 'receive' ->
- {Cs, S1} = mapfold_list(F, S0, receive_clauses(T)),
- {E, S2} = mapfold(F, S1, receive_timeout(T)),
- {A, S3} = mapfold(F, S2, receive_action(T)),
- F(update_c_receive(T, Cs, E, A), S3);
- 'try' ->
- {E, S1} = mapfold(F, S0, try_arg(T)),
- {Vs, S2} = mapfold_list(F, S1, try_vars(T)),
- {B, S3} = mapfold(F, S2, try_body(T)),
- {Evs, S4} = mapfold_list(F, S3, try_evars(T)),
- {H, S5} = mapfold(F, S4, try_handler(T)),
- F(update_c_try(T, E, Vs, B, Evs, H), S5);
- 'catch' ->
- {B, S1} = mapfold(F, S0, catch_body(T)),
- F(update_c_catch(T, B), S1);
- binary ->
- {Ds, S1} = mapfold_list(F, S0, binary_segments(T)),
- F(update_c_binary(T, Ds), S1);
- bitstr ->
- {Val, S1} = mapfold(F, S0, bitstr_val(T)),
- {Size, S2} = mapfold(F, S1, bitstr_size(T)),
- {Unit, S3} = mapfold(F, S2, bitstr_unit(T)),
- {Type, S4} = mapfold(F, S3, bitstr_type(T)),
- {Flags, S5} = mapfold(F, S4, bitstr_flags(T)),
- F(update_c_bitstr(T, Val, Size, Unit, Type, Flags), S5);
- letrec ->
- {Ds, S1} = mapfold_pairs(F, S0, letrec_defs(T)),
- {B, S2} = mapfold(F, S1, letrec_body(T)),
- F(update_c_letrec(T, Ds, B), S2);
- module ->
- {N, S1} = mapfold(F, S0, module_name(T)),
- {Es, S2} = mapfold_list(F, S1, module_exports(T)),
- {As, S3} = mapfold_pairs(F, S2, module_attrs(T)),
- {Ds, S4} = mapfold_pairs(F, S3, module_defs(T)),
- F(update_c_module(T, N, Es, As, Ds), S4)
- end.
-
-mapfold_list(F, S0, [T | Ts]) ->
- {T1, S1} = mapfold(F, S0, T),
- {Ts1, S2} = mapfold_list(F, S1, Ts),
- {[T1 | Ts1], S2};
-mapfold_list(_, S, []) ->
- {[], S}.
-
-mapfold_pairs(F, S0, [{T1, T2} | Ps]) ->
- {T3, S1} = mapfold(F, S0, T1),
- {T4, S2} = mapfold(F, S1, T2),
- {Ps1, S3} = mapfold_pairs(F, S2, Ps),
- {[{T3, T4} | Ps1], S3};
-mapfold_pairs(_, S, []) ->
- {[], S}.
-
-
-%% ---------------------------------------------------------------------
-
-%% @spec variables(Tree::cerl()) -> [var_name()]
-%%
-%% var_name() = integer() | atom() | {atom(), integer()}
-%%
-%% @doc Returns an ordered-set list of the names of all variables in
-%% the syntax tree. (This includes function name variables.) An
-%% exception is thrown if Tree
does not represent a
-%% well-formed Core Erlang syntax tree.
-%%
-%% @see free_variables/1
-
-variables(T) ->
- variables(T, false).
-
-
-%% @spec free_variables(Tree::cerl()) -> [var_name()]
-%%
-%% @doc Like variables/1
, but only includes variables
-%% that are free in the tree.
-%%
-%% @see variables/1
-
-free_variables(T) ->
- variables(T, true).
-
-
-%% This is not exported
-
-variables(T, S) ->
- case type(T) of
- literal ->
- [];
- var ->
- [var_name(T)];
- values ->
- vars_in_list(values_es(T), S);
- cons ->
- ordsets:union(variables(cons_hd(T), S),
- variables(cons_tl(T), S));
- tuple ->
- vars_in_list(tuple_es(T), S);
- 'let' ->
- Vs = variables(let_body(T), S),
- Vs1 = var_list_names(let_vars(T)),
- Vs2 = case S of
- true ->
- ordsets:subtract(Vs, Vs1);
- false ->
- ordsets:union(Vs, Vs1)
- end,
- ordsets:union(variables(let_arg(T), S), Vs2);
- seq ->
- ordsets:union(variables(seq_arg(T), S),
- variables(seq_body(T), S));
- apply ->
- ordsets:union(
- variables(apply_op(T), S),
- vars_in_list(apply_args(T), S));
- call ->
- ordsets:union(variables(call_module(T), S),
- ordsets:union(
- variables(call_name(T), S),
- vars_in_list(call_args(T), S)));
- primop ->
- vars_in_list(primop_args(T), S);
- 'case' ->
- ordsets:union(variables(case_arg(T), S),
- vars_in_list(case_clauses(T), S));
- clause ->
- Vs = ordsets:union(variables(clause_guard(T), S),
- variables(clause_body(T), S)),
- Vs1 = vars_in_list(clause_pats(T), S),
- case S of
- true ->
- ordsets:subtract(Vs, Vs1);
- false ->
- ordsets:union(Vs, Vs1)
- end;
- alias ->
- ordsets:add_element(var_name(alias_var(T)),
- variables(alias_pat(T)));
- 'fun' ->
- Vs = variables(fun_body(T), S),
- Vs1 = var_list_names(fun_vars(T)),
- case S of
- true ->
- ordsets:subtract(Vs, Vs1);
- false ->
- ordsets:union(Vs, Vs1)
- end;
- 'receive' ->
- ordsets:union(
- vars_in_list(receive_clauses(T), S),
- ordsets:union(variables(receive_timeout(T), S),
- variables(receive_action(T), S)));
- 'try' ->
- Vs = variables(try_body(T), S),
- Vs1 = var_list_names(try_vars(T)),
- Vs2 = case S of
- true ->
- ordsets:subtract(Vs, Vs1);
- false ->
- ordsets:union(Vs, Vs1)
- end,
- Vs3 = variables(try_handler(T), S),
- Vs4 = var_list_names(try_evars(T)),
- Vs5 = case S of
- true ->
- ordsets:subtract(Vs3, Vs4);
- false ->
- ordsets:union(Vs3, Vs4)
- end,
- ordsets:union(variables(try_arg(T), S),
- ordsets:union(Vs2, Vs5));
- 'catch' ->
- variables(catch_body(T), S);
- binary ->
- vars_in_list(binary_segments(T), S);
- bitstr ->
- ordsets:union(variables(bitstr_val(T), S),
- variables(bitstr_size(T), S));
- letrec ->
- Vs = vars_in_defs(letrec_defs(T), S),
- Vs1 = ordsets:union(variables(letrec_body(T), S), Vs),
- Vs2 = var_list_names(letrec_vars(T)),
- case S of
- true ->
- ordsets:subtract(Vs1, Vs2);
- false ->
- ordsets:union(Vs1, Vs2)
- end;
- module ->
- Vs = vars_in_defs(module_defs(T), S),
- Vs1 = ordsets:union(vars_in_list(module_exports(T), S), Vs),
- Vs2 = var_list_names(module_vars(T)),
- case S of
- true ->
- ordsets:subtract(Vs1, Vs2);
- false ->
- ordsets:union(Vs1, Vs2)
- end
- end.
-
-vars_in_list(Ts, S) ->
- vars_in_list(Ts, S, []).
-
-vars_in_list([T | Ts], S, A) ->
- vars_in_list(Ts, S, ordsets:union(variables(T, S), A));
-vars_in_list([], _, A) ->
- A.
-
-%% Note that this function only visits the right-hand side of function
-%% definitions.
-
-vars_in_defs(Ds, S) ->
- vars_in_defs(Ds, S, []).
-
-vars_in_defs([{_, F} | Ds], S, A) ->
- vars_in_defs(Ds, S, ordsets:union(variables(F, S), A));
-vars_in_defs([], _, A) ->
- A.
-
-%% This amounts to insertion sort. Since the lists are generally short,
-%% it is hardly worthwhile to use an asymptotically better sort.
-
-var_list_names(Vs) ->
- var_list_names(Vs, []).
-
-var_list_names([V | Vs], A) ->
- var_list_names(Vs, ordsets:add_element(var_name(V), A));
-var_list_names([], A) ->
- A.
-
-
-%% ---------------------------------------------------------------------
-
-%% label(Tree::cerl()) -> {cerl(), integer()}
-%%
-%% @equiv label(Tree, 0)
-
-label(T) ->
- label(T, 0).
-
-%% @spec label(Tree::cerl(), N::integer()) -> {cerl(), integer()}
-%%
-%% @doc Labels each expression in the tree. A term {label,
-%% L}
is prefixed to the annotation list of each expression node,
-%% where L is a unique number for every node, except for variables (and
-%% function name variables) which get the same label if they represent
-%% the same variable. Constant literal nodes are not labeled.
-%%
-%% The returned value is a tuple {NewTree, Max}
, where
-%% NewTree
is the labeled tree and Max
is 1
-%% plus the largest label value used. All previous annotation terms on
-%% the form {label, X}
are deleted.
The values of L used in the tree is a dense range from
-%% N
to Max - 1
, where N =< Max
-%% =< N + size(Tree)
. Note that it is possible that no
-%% labels are used at all, i.e., N = Max
.
Note: All instances of free variables will be given distinct -%% labels.
-%% -%% @see label/1 -%% @see size/1 - -label(T, N) -> - label(T, N, dict:new()). - -label(T, N, Env) -> - case type(T) of - literal -> - %% Constant literals are not labeled. - {T, N}; - var -> - case dict:find(var_name(T), Env) of - {ok, L} -> - {As, _} = label_ann(T, L), - N1 = N; - error -> - {As, N1} = label_ann(T, N) - end, - {set_ann(T, As), N1}; - values -> - {Ts, N1} = label_list(values_es(T), N, Env), - {As, N2} = label_ann(T, N1), - {ann_c_values(As, Ts), N2}; - cons -> - {T1, N1} = label(cons_hd(T), N, Env), - {T2, N2} = label(cons_tl(T), N1, Env), - {As, N3} = label_ann(T, N2), - {ann_c_cons_skel(As, T1, T2), N3}; - tuple -> - {Ts, N1} = label_list(tuple_es(T), N, Env), - {As, N2} = label_ann(T, N1), - {ann_c_tuple_skel(As, Ts), N2}; - 'let' -> - {A, N1} = label(let_arg(T), N, Env), - {Vs, N2, Env1} = label_vars(let_vars(T), N1, Env), - {B, N3} = label(let_body(T), N2, Env1), - {As, N4} = label_ann(T, N3), - {ann_c_let(As, Vs, A, B), N4}; - seq -> - {A, N1} = label(seq_arg(T), N, Env), - {B, N2} = label(seq_body(T), N1, Env), - {As, N3} = label_ann(T, N2), - {ann_c_seq(As, A, B), N3}; - apply -> - {E, N1} = label(apply_op(T), N, Env), - {Es, N2} = label_list(apply_args(T), N1, Env), - {As, N3} = label_ann(T, N2), - {ann_c_apply(As, E, Es), N3}; - call -> - {M, N1} = label(call_module(T), N, Env), - {F, N2} = label(call_name(T), N1, Env), - {Es, N3} = label_list(call_args(T), N2, Env), - {As, N4} = label_ann(T, N3), - {ann_c_call(As, M, F, Es), N4}; - primop -> - {F, N1} = label(primop_name(T), N, Env), - {Es, N2} = label_list(primop_args(T), N1, Env), - {As, N3} = label_ann(T, N2), - {ann_c_primop(As, F, Es), N3}; - 'case' -> - {A, N1} = label(case_arg(T), N, Env), - {Cs, N2} = label_list(case_clauses(T), N1, Env), - {As, N3} = label_ann(T, N2), - {ann_c_case(As, A, Cs), N3}; - clause -> - {_, N1, Env1} = label_vars(clause_vars(T), N, Env), - {Ps, N2} = label_list(clause_pats(T), N1, Env1), - {G, N3} = label(clause_guard(T), N2, Env1), - {B, N4} = label(clause_body(T), N3, Env1), - {As, N5} = label_ann(T, N4), - {ann_c_clause(As, Ps, G, B), N5}; - alias -> - {V, N1} = label(alias_var(T), N, Env), - {P, N2} = label(alias_pat(T), N1, Env), - {As, N3} = label_ann(T, N2), - {ann_c_alias(As, V, P), N3}; - 'fun' -> - {Vs, N1, Env1} = label_vars(fun_vars(T), N, Env), - {B, N2} = label(fun_body(T), N1, Env1), - {As, N3} = label_ann(T, N2), - {ann_c_fun(As, Vs, B), N3}; - 'receive' -> - {Cs, N1} = label_list(receive_clauses(T), N, Env), - {E, N2} = label(receive_timeout(T), N1, Env), - {A, N3} = label(receive_action(T), N2, Env), - {As, N4} = label_ann(T, N3), - {ann_c_receive(As, Cs, E, A), N4}; - 'try' -> - {E, N1} = label(try_arg(T), N, Env), - {Vs, N2, Env1} = label_vars(try_vars(T), N1, Env), - {B, N3} = label(try_body(T), N2, Env1), - {Evs, N4, Env2} = label_vars(try_evars(T), N3, Env), - {H, N5} = label(try_handler(T), N4, Env2), - {As, N6} = label_ann(T, N5), - {ann_c_try(As, E, Vs, B, Evs, H), N6}; - 'catch' -> - {B, N1} = label(catch_body(T), N, Env), - {As, N2} = label_ann(T, N1), - {ann_c_catch(As, B), N2}; - binary -> - {Ds, N1} = label_list(binary_segments(T), N, Env), - {As, N2} = label_ann(T, N1), - {ann_c_binary(As, Ds), N2}; - bitstr -> - {Val, N1} = label(bitstr_val(T), N, Env), - {Size, N2} = label(bitstr_size(T), N1, Env), - {Unit, N3} = label(bitstr_unit(T), N2, Env), - {Type, N4} = label(bitstr_type(T), N3, Env), - {Flags, N5} = label(bitstr_flags(T), N4, Env), - {As, N6} = label_ann(T, N5), - {ann_c_bitstr(As, Val, Size, Unit, Type, Flags), N6}; - letrec -> - {_, N1, Env1} = label_vars(letrec_vars(T), N, Env), - {Ds, N2} = label_defs(letrec_defs(T), N1, Env1), - {B, N3} = label(letrec_body(T), N2, Env1), - {As, N4} = label_ann(T, N3), - {ann_c_letrec(As, Ds, B), N4}; - module -> - %% The module name is not labeled. - {_, N1, Env1} = label_vars(module_vars(T), N, Env), - {Ts, N2} = label_defs(module_attrs(T), N1, Env1), - {Ds, N3} = label_defs(module_defs(T), N2, Env1), - {Es, N4} = label_list(module_exports(T), N3, Env1), - {As, N5} = label_ann(T, N4), - {ann_c_module(As, module_name(T), Es, Ts, Ds), N5} - end. - -label_list([T | Ts], N, Env) -> - {T1, N1} = label(T, N, Env), - {Ts1, N2} = label_list(Ts, N1, Env), - {[T1 | Ts1], N2}; -label_list([], N, _Env) -> - {[], N}. - -label_vars([T | Ts], N, Env) -> - Env1 = dict:store(var_name(T), N, Env), - {As, N1} = label_ann(T, N), - T1 = set_ann(T, As), - {Ts1, N2, Env2} = label_vars(Ts, N1, Env1), - {[T1 | Ts1], N2, Env2}; -label_vars([], N, Env) -> - {[], N, Env}. - -label_defs([{F, T} | Ds], N, Env) -> - {F1, N1} = label(F, N, Env), - {T1, N2} = label(T, N1, Env), - {Ds1, N3} = label_defs(Ds, N2, Env), - {[{F1, T1} | Ds1], N3}; -label_defs([], N, _Env) -> - {[], N}. - -label_ann(T, N) -> - {[{label, N} | filter_labels(get_ann(T))], N + 1}. - -filter_labels([{label, _} | As]) -> - filter_labels(As); -filter_labels([A | As]) -> - [A | filter_labels(As)]; -filter_labels([]) -> - []. diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/compile.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/compile.erl deleted file mode 100644 index 4542bf9eb9..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/compile.erl +++ /dev/null @@ -1,1109 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: compile.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% -%% Purpose: Run the Erlang compiler. - --module(compile). --include("erl_compile.hrl"). --include("core_parse.hrl"). - -%% High-level interface. --export([file/1,file/2,format_error/1,iofile/1]). --export([forms/1,forms/2]). --export([output_generated/1]). --export([options/0]). - -%% Erlc interface. --export([compile/3,compile_beam/3,compile_asm/3,compile_core/3]). - - --import(lists, [member/2,reverse/1,keysearch/3,last/1, - map/2,flatmap/2,foreach/2,foldr/3,any/2,filter/2]). - -%% file(FileName) -%% file(FileName, Options) -%% Compile the module in file FileName. - --define(DEFAULT_OPTIONS, [verbose,report_errors,report_warnings]). - --define(pass(P), {P,fun P/1}). - -file(File) -> file(File, ?DEFAULT_OPTIONS). - -file(File, Opts) when list(Opts) -> - do_compile({file,File}, Opts++env_default_opts()); -file(File, Opt) -> - file(File, [Opt|?DEFAULT_OPTIONS]). - -forms(File) -> forms(File, ?DEFAULT_OPTIONS). - -forms(Forms, Opts) when list(Opts) -> - do_compile({forms,Forms}, [binary|Opts++env_default_opts()]); -forms(Forms, Opts) when atom(Opts) -> - forms(Forms, [Opts|?DEFAULT_OPTIONS]). - -env_default_opts() -> - Key = "ERL_COMPILER_OPTIONS", - case os:getenv(Key) of - false -> []; - Str when list(Str) -> - case erl_scan:string(Str) of - {ok,Tokens,_} -> - case erl_parse:parse_term(Tokens ++ [{dot, 1}]) of - {ok,List} when list(List) -> List; - {ok,Term} -> [Term]; - {error,_Reason} -> - io:format("Ignoring bad term in ~s\n", [Key]), - [] - end; - {error, {_,_,_Reason}, _} -> - io:format("Ignoring bad term in ~s\n", [Key]), - [] - end - end. - -do_compile(Input, Opts0) -> - Opts = expand_opts(Opts0), - Self = self(), - Serv = spawn_link(fun() -> internal(Self, Input, Opts) end), - receive - {Serv,Rep} -> Rep - end. - -%% Given a list of compilation options, returns true if compile:file/2 -%% would have generated a Beam file, false otherwise (if only a binary or a -%% listing file would have been generated). - -output_generated(Opts) -> - any(fun ({save_binary,_F}) -> true; - (_Other) -> false - end, passes(file, expand_opts(Opts))). - -expand_opts(Opts) -> - foldr(fun expand_opt/2, [], Opts). - -expand_opt(basic_validation, Os) -> - [no_code_generation,to_pp,binary|Os]; -expand_opt(strong_validation, Os) -> - [no_code_generation,to_kernel,binary|Os]; -expand_opt(report, Os) -> - [report_errors,report_warnings|Os]; -expand_opt(return, Os) -> - [return_errors,return_warnings|Os]; -expand_opt(r7, Os) -> - [no_float_opt,no_new_funs,no_new_binaries,no_new_apply|Os]; -expand_opt(O, Os) -> [O|Os]. - -filter_opts(Opts0) -> - %% Native code generation is not supported if no_new_funs is given. - case member(no_new_funs, Opts0) of - false -> Opts0; - true -> Opts0 -- [native] - end. - -%% format_error(ErrorDescriptor) -> string() - -format_error(no_native_support) -> - "this system is not configured for native-code compilation."; -format_error({native, E}) -> - io_lib:fwrite("native-code compilation failed with reason: ~P.", - [E, 25]); -format_error({native_crash, E}) -> - io_lib:fwrite("native-code compilation crashed with reason: ~P.", - [E, 25]); -format_error({open,E}) -> - io_lib:format("open error '~s'", [file:format_error(E)]); -format_error({epp,E}) -> - epp:format_error(E); -format_error(write_error) -> - "error writing file"; -format_error({rename,S}) -> - io_lib:format("error renaming ~s", [S]); -format_error({parse_transform,M,R}) -> - io_lib:format("error in parse transform '~s': ~p", [M, R]); -format_error({core_transform,M,R}) -> - io_lib:format("error in core transform '~s': ~p", [M, R]); -format_error({crash,Pass,Reason}) -> - io_lib:format("internal error in ~p;\ncrash reason: ~p", [Pass,Reason]); -format_error({bad_return,Pass,Reason}) -> - io_lib:format("internal error in ~p;\nbad return value: ~p", [Pass,Reason]). - -%% The compile state record. --record(compile, {filename="", - dir="", - base="", - ifile="", - ofile="", - module=[], - code=[], - core_code=[], - abstract_code=[], %Abstract code for debugger. - options=[], - errors=[], - warnings=[]}). - -internal(Master, Input, Opts) -> - Master ! {self(), - case catch internal(Input, Opts) of - {'EXIT', Reason} -> - {error, Reason}; - Other -> - Other - end}. - -internal({forms,Forms}, Opts) -> - Ps = passes(forms, Opts), - internal_comp(Ps, "", "", #compile{code=Forms,options=Opts}); -internal({file,File}, Opts) -> - Ps = passes(file, Opts), - Compile = #compile{options=Opts}, - case member(from_core, Opts) of - true -> internal_comp(Ps, File, ".core", Compile); - false -> - case member(from_beam, Opts) of - true -> - internal_comp(Ps, File, ".beam", Compile); - false -> - case member(from_asm, Opts) orelse member(asm, Opts) of - true -> - internal_comp(Ps, File, ".S", Compile); - false -> - internal_comp(Ps, File, ".erl", Compile) - end - end - end. - -internal_comp(Passes, File, Suffix, St0) -> - Dir = filename:dirname(File), - Base = filename:basename(File, Suffix), - St1 = St0#compile{filename=File, dir=Dir, base=Base, - ifile=erlfile(Dir, Base, Suffix), - ofile=objfile(Base, St0)}, - Run = case member(time, St1#compile.options) of - true -> - io:format("Compiling ~p\n", [File]), - fun run_tc/2; - false -> fun({_Name,Fun}, St) -> catch Fun(St) end - end, - case fold_comp(Passes, Run, St1) of - {ok,St2} -> comp_ret_ok(St2); - {error,St2} -> comp_ret_err(St2) - end. - -fold_comp([{Name,Test,Pass}|Ps], Run, St) -> - case Test(St) of - false -> %Pass is not needed. - fold_comp(Ps, Run, St); - true -> %Run pass in the usual way. - fold_comp([{Name,Pass}|Ps], Run, St) - end; -fold_comp([{Name,Pass}|Ps], Run, St0) -> - case Run({Name,Pass}, St0) of - {ok,St1} -> fold_comp(Ps, Run, St1); - {error,St1} -> {error,St1}; - {'EXIT',Reason} -> - Es = [{St0#compile.ifile,[{none,?MODULE,{crash,Name,Reason}}]}], - {error,St0#compile{errors=St0#compile.errors ++ Es}}; - Other -> - Es = [{St0#compile.ifile,[{none,?MODULE,{bad_return,Name,Other}}]}], - {error,St0#compile{errors=St0#compile.errors ++ Es}} - end; -fold_comp([], _Run, St) -> {ok,St}. - -os_process_size() -> - case os:type() of - {unix, sunos} -> - Size = os:cmd("ps -o vsz -p " ++ os:getpid() ++ " | tail -1"), - list_to_integer(lib:nonl(Size)); - _ -> - 0 - end. - -run_tc({Name,Fun}, St) -> - Before0 = statistics(runtime), - Val = (catch Fun(St)), - After0 = statistics(runtime), - {Before_c, _} = Before0, - {After_c, _} = After0, - io:format(" ~-30s: ~10.3f s (~w k)\n", - [Name, (After_c-Before_c) / 1000, os_process_size()]), - Val. - -comp_ret_ok(#compile{code=Code,warnings=Warn,module=Mod,options=Opts}=St) -> - report_warnings(St), - Ret1 = case member(binary, Opts) andalso not member(no_code_generation, Opts) of - true -> [Code]; - false -> [] - end, - Ret2 = case member(return_warnings, Opts) of - true -> Ret1 ++ [Warn]; - false -> Ret1 - end, - list_to_tuple([ok,Mod|Ret2]). - -comp_ret_err(St) -> - report_errors(St), - report_warnings(St), - case member(return_errors, St#compile.options) of - true -> {error,St#compile.errors,St#compile.warnings}; - false -> error - end. - -%% passes(form|file, [Option]) -> [{Name,PassFun}] -%% Figure out which passes that need to be run. - -passes(forms, Opts) -> - select_passes(standard_passes(), Opts); -passes(file, Opts) -> - case member(from_beam, Opts) of - true -> - Ps = [?pass(read_beam_file)|binary_passes()], - select_passes(Ps, Opts); - false -> - Ps = case member(from_asm, Opts) orelse member(asm, Opts) of - true -> - [?pass(beam_consult_asm)|asm_passes()]; - false -> - case member(from_core, Opts) of - true -> - [?pass(parse_core)|core_passes()]; - false -> - [?pass(parse_module)|standard_passes()] - end - end, - Fs = select_passes(Ps, Opts), - - %% If the last pass saves the resulting binary to a file, - %% insert a first pass to remove the file. - case last(Fs) of - {save_binary,_Fun} -> [?pass(remove_file)|Fs]; - _Other -> Fs - end - end. - -%% select_passes([Command], Opts) -> [{Name,Function}] -%% Interpret the lists of commands to return a pure list of passes. -%% -%% Command can be one of: -%% -%% {pass,Mod} Will be expanded to a call to the external -%% function Mod:module(Code, Options). This -%% function must transform the code and return -%% {ok,NewCode} or {error,Term}. -%% Example: {pass,beam_codegen} -%% -%% {Name,Fun} Name is an atom giving the name of the pass. -%% Fun is an 'fun' taking one argument: a compile record. -%% The fun should return {ok,NewCompileRecord} or -%% {error,NewCompileRecord}. -%% Note: ?pass(Name) is equvivalent to {Name,fun Name/1}. -%% Example: ?pass(parse_module) -%% -%% {Name,Test,Fun} Like {Name,Fun} above, but the pass will be run -%% (and listed by the `time' option) only if Test(St) -%% returns true. -%% -%% {src_listing,Ext} Produces an Erlang source listing with the -%% the file extension Ext. (Ext should not contain -%% a period.) No more passes will be run. -%% -%% {listing,Ext} Produce an listing of the terms in the internal -%% representation. The extension of the listing -%% file will be Ext. (Ext should not contain -%% a period.) No more passes will be run. -%% -%% {done,Ext} End compilation at this point. Produce a listing -%% as with {listing,Ext}, unless 'binary' is -%% specified, in which case the current -%% representation of the code is returned without -%% creating an output file. -%% -%% {iff,Flag,Cmd} If the given Flag is given in the option list, -%% Cmd will be interpreted as a command. -%% Otherwise, Cmd will be ignored. -%% Example: {iff,dcg,{listing,"codegen}} -%% -%% {unless,Flag,Cmd} If the given Flag is NOT given in the option list, -%% Cmd will be interpreted as a command. -%% Otherwise, Cmd will be ignored. -%% Example: {unless,no_kernopt,{pass,sys_kernopt}} -%% - -select_passes([{pass,Mod}|Ps], Opts) -> - F = fun(St) -> - case catch Mod:module(St#compile.code, St#compile.options) of - {ok,Code} -> - {ok,St#compile{code=Code}}; - {error,Es} -> - {error,St#compile{errors=St#compile.errors ++ Es}} - end - end, - [{Mod,F}|select_passes(Ps, Opts)]; -select_passes([{src_listing,Ext}|_], _Opts) -> - [{listing,fun (St) -> src_listing(Ext, St) end}]; -select_passes([{listing,Ext}|_], _Opts) -> - [{listing,fun (St) -> listing(Ext, St) end}]; -select_passes([{done,Ext}|_], Opts) -> - select_passes([{unless,binary,{listing,Ext}}], Opts); -select_passes([{iff,Flag,Pass}|Ps], Opts) -> - select_cond(Flag, true, Pass, Ps, Opts); -select_passes([{unless,Flag,Pass}|Ps], Opts) -> - select_cond(Flag, false, Pass, Ps, Opts); -select_passes([{_,Fun}=P|Ps], Opts) when is_function(Fun) -> - [P|select_passes(Ps, Opts)]; -select_passes([{_,Test,Fun}=P|Ps], Opts) when is_function(Test), - is_function(Fun) -> - [P|select_passes(Ps, Opts)]; -select_passes([], _Opts) -> - []; -select_passes([List|Ps], Opts) when is_list(List) -> - case select_passes(List, Opts) of - [] -> select_passes(Ps, Opts); - Nested -> - case last(Nested) of - {listing,_Fun} -> Nested; - _Other -> Nested ++ select_passes(Ps, Opts) - end - end. - -select_cond(Flag, ShouldBe, Pass, Ps, Opts) -> - ShouldNotBe = not ShouldBe, - case member(Flag, Opts) of - ShouldBe -> select_passes([Pass|Ps], Opts); - ShouldNotBe -> select_passes(Ps, Opts) - end. - -%% The standard passes (almost) always run. - -standard_passes() -> - [?pass(transform_module), - {iff,'dpp',{listing,"pp"}}, - ?pass(lint_module), - {iff,'P',{src_listing,"P"}}, - {iff,'to_pp',{done,"P"}}, - - {iff,'dabstr',{listing,"abstr"}}, - {iff,debug_info,?pass(save_abstract_code)}, - - ?pass(expand_module), - {iff,'dexp',{listing,"expand"}}, - {iff,'E',{src_listing,"E"}}, - {iff,'to_exp',{done,"E"}}, - - %% Conversion to Core Erlang. - ?pass(core_module), - {iff,'dcore',{listing,"core"}}, - {iff,'to_core0',{done,"core"}} - | core_passes()]. - -core_passes() -> - %% Optimization and transforms of Core Erlang code. - [{unless,no_copt, - [{core_old_inliner,fun test_old_inliner/1,fun core_old_inliner/1}, - ?pass(core_fold_module), - {core_inline_module,fun test_core_inliner/1,fun core_inline_module/1}, - {core_fold_after_inline,fun test_core_inliner/1,fun core_fold_module/1}, - ?pass(core_transforms)]}, - {iff,dcopt,{listing,"copt"}}, - {iff,'to_core',{done,"core"}} - | kernel_passes()]. - -kernel_passes() -> - %% Destructive setelement/3 optimization and core lint. - [?pass(core_dsetel_module), - {iff,clint,?pass(core_lint_module)}, - {iff,core,?pass(save_core_code)}, - - %% Kernel Erlang and code generation. - ?pass(kernel_module), - {iff,dkern,{listing,"kernel"}}, - {iff,'to_kernel',{done,"kernel"}}, - {pass,v3_life}, - {iff,dlife,{listing,"life"}}, - {pass,v3_codegen}, - {iff,dcg,{listing,"codegen"}} - | asm_passes()]. - -asm_passes() -> - %% Assembly level optimisations. - [{unless,no_postopt, - [{pass,beam_block}, - {iff,dblk,{listing,"block"}}, - {unless,no_bopt,{pass,beam_bool}}, - {iff,dbool,{listing,"bool"}}, - {unless,no_topt,{pass,beam_type}}, - {iff,dtype,{listing,"type"}}, - {pass,beam_dead}, %Must always run since it splits blocks. - {iff,ddead,{listing,"dead"}}, - {unless,no_jopt,{pass,beam_jump}}, - {iff,djmp,{listing,"jump"}}, - {pass,beam_clean}, - {iff,dclean,{listing,"clean"}}, - {pass,beam_flatten}]}, - - %% If post optimizations are turned off, we still coalesce - %% adjacent labels and remove unused labels to keep the - %% HiPE compiler happy. - {iff,no_postopt, - [?pass(beam_unused_labels), - {pass,beam_clean}]}, - - {iff,dopt,{listing,"optimize"}}, - {iff,'S',{listing,"S"}}, - {iff,'to_asm',{done,"S"}}, - - {pass,beam_validator}, - ?pass(beam_asm) - | binary_passes()]. - -binary_passes() -> - [{native_compile,fun test_native/1,fun native_compile/1}, - {unless,binary,?pass(save_binary)}]. - -%%% -%%% Compiler passes. -%%% - -%% Remove the target file so we don't have an old one if the compilation fail. -remove_file(St) -> - file:delete(St#compile.ofile), - {ok,St}. - --record(asm_module, {module, - exports, - labels, - functions=[], - cfun, - code, - attributes=[]}). - -preprocess_asm_forms(Forms) -> - R = #asm_module{}, - R1 = collect_asm(Forms, R), - {R1#asm_module.module, - {R1#asm_module.module, - R1#asm_module.exports, - R1#asm_module.attributes, - R1#asm_module.functions, - R1#asm_module.labels}}. - -collect_asm([], R) -> - case R#asm_module.cfun of - undefined -> - R; - {A,B,C} -> - R#asm_module{functions=R#asm_module.functions++ - [{function,A,B,C,R#asm_module.code}]} - end; -collect_asm([{module,M} | Rest], R) -> - collect_asm(Rest, R#asm_module{module=M}); -collect_asm([{exports,M} | Rest], R) -> - collect_asm(Rest, R#asm_module{exports=M}); -collect_asm([{labels,M} | Rest], R) -> - collect_asm(Rest, R#asm_module{labels=M}); -collect_asm([{function,A,B,C} | Rest], R) -> - R1 = case R#asm_module.cfun of - undefined -> - R; - {A0,B0,C0} -> - R#asm_module{functions=R#asm_module.functions++ - [{function,A0,B0,C0,R#asm_module.code}]} - end, - collect_asm(Rest, R1#asm_module{cfun={A,B,C}, code=[]}); -collect_asm([{attributes, Attr} | Rest], R) -> - collect_asm(Rest, R#asm_module{attributes=Attr}); -collect_asm([X | Rest], R) -> - collect_asm(Rest, R#asm_module{code=R#asm_module.code++[X]}). - -beam_consult_asm(St) -> - case file:consult(St#compile.ifile) of - {ok, Forms0} -> - {Module, Forms} = preprocess_asm_forms(Forms0), - {ok,St#compile{module=Module, code=Forms}}; - {error,E} -> - Es = [{St#compile.ifile,[{none,?MODULE,{open,E}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -read_beam_file(St) -> - case file:read_file(St#compile.ifile) of - {ok,Beam} -> - Infile = St#compile.ifile, - case is_too_old(Infile) of - true -> - {ok,St#compile{module=none,code=none}}; - false -> - Mod0 = filename:rootname(filename:basename(Infile)), - Mod = list_to_atom(Mod0), - {ok,St#compile{module=Mod,code=Beam,ofile=Infile}} - end; - {error,E} -> - Es = [{St#compile.ifile,[{none,?MODULE,{open,E}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -is_too_old(BeamFile) -> - case beam_lib:chunks(BeamFile, ["CInf"]) of - {ok,{_,[{"CInf",Term0}]}} -> - Term = binary_to_term(Term0), - Opts = proplists:get_value(options, Term, []), - lists:member(no_new_funs, Opts); - _ -> false - end. - -parse_module(St) -> - Opts = St#compile.options, - Cwd = ".", - IncludePath = [Cwd, St#compile.dir|inc_paths(Opts)], - Tab = ets:new(compiler__tab, [protected,named_table]), - ets:insert(Tab, {compiler_options,Opts}), - R = epp:parse_file(St#compile.ifile, IncludePath, pre_defs(Opts)), - ets:delete(Tab), - case R of - {ok,Forms} -> - {ok,St#compile{code=Forms}}; - {error,E} -> - Es = [{St#compile.ifile,[{none,?MODULE,{epp,E}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -parse_core(St) -> - case file:read_file(St#compile.ifile) of - {ok,Bin} -> - case core_scan:string(binary_to_list(Bin)) of - {ok,Toks,_} -> - case core_parse:parse(Toks) of - {ok,Mod} -> - Name = (Mod#c_module.name)#c_atom.val, - {ok,St#compile{module=Name,code=Mod}}; - {error,E} -> - Es = [{St#compile.ifile,[E]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end; - {error,E,_} -> - Es = [{St#compile.ifile,[E]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end; - {error,E} -> - Es = [{St#compile.ifile,[{none,compile,{open,E}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -compile_options([{attribute,_L,compile,C}|Fs]) when is_list(C) -> - C ++ compile_options(Fs); -compile_options([{attribute,_L,compile,C}|Fs]) -> - [C|compile_options(Fs)]; -compile_options([_F|Fs]) -> compile_options(Fs); -compile_options([]) -> []. - -transforms(Os) -> [ M || {parse_transform,M} <- Os ]. - -transform_module(St) -> - %% Extract compile options from code into options field. - Ts = transforms(St#compile.options ++ compile_options(St#compile.code)), - foldl_transform(St, Ts). - -foldl_transform(St, [T|Ts]) -> - Name = "transform " ++ atom_to_list(T), - Fun = fun(S) -> T:parse_transform(S#compile.code, S#compile.options) end, - Run = case member(time, St#compile.options) of - true -> fun run_tc/2; - false -> fun({_Name,F}, S) -> catch F(S) end - end, - case Run({Name, Fun}, St) of - {error,Es,Ws} -> - {error,St#compile{warnings=St#compile.warnings ++ Ws, - errors=St#compile.errors ++ Es}}; - {'EXIT',R} -> - Es = [{St#compile.ifile,[{none,compile,{parse_transform,T,R}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}}; - Forms -> - foldl_transform(St#compile{code=Forms}, Ts) - end; -foldl_transform(St, []) -> {ok,St}. - -get_core_transforms(Opts) -> [M || {core_transform,M} <- Opts]. - -core_transforms(St) -> - %% The options field holds the complete list of options at this - - Ts = get_core_transforms(St#compile.options), - foldl_core_transforms(St, Ts). - -foldl_core_transforms(St, [T|Ts]) -> - Name = "core transform " ++ atom_to_list(T), - Fun = fun(S) -> T:core_transform(S#compile.code, S#compile.options) end, - Run = case member(time, St#compile.options) of - true -> fun run_tc/2; - false -> fun({_Name,F}, S) -> catch F(S) end - end, - case Run({Name, Fun}, St) of - {'EXIT',R} -> - Es = [{St#compile.ifile,[{none,compile,{core_transform,T,R}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}}; - Forms -> - foldl_core_transforms(St#compile{code=Forms}, Ts) - end; -foldl_core_transforms(St, []) -> {ok,St}. - -%%% Fetches the module name from a list of forms. The module attribute must -%%% be present. -get_module([{attribute,_,module,{M,_As}} | _]) -> M; -get_module([{attribute,_,module,M} | _]) -> M; -get_module([_ | Rest]) -> - get_module(Rest). - -%%% A #compile state is returned, where St.base has been filled in -%%% with the module name from Forms, as a string, in case it wasn't -%%% set in St (i.e., it was ""). -add_default_base(St, Forms) -> - F = St#compile.filename, - case F of - "" -> - M = get_module(Forms), - St#compile{base = atom_to_list(M)}; - _ -> - St - end. - -lint_module(St) -> - case erl_lint:module(St#compile.code, - St#compile.ifile, St#compile.options) of - {ok,Ws} -> - %% Insert name of module as base name, if needed. This is - %% for compile:forms to work with listing files. - St1 = add_default_base(St, St#compile.code), - {ok,St1#compile{warnings=St1#compile.warnings ++ Ws}}; - {error,Es,Ws} -> - {error,St#compile{warnings=St#compile.warnings ++ Ws, - errors=St#compile.errors ++ Es}} - end. - -core_lint_module(St) -> - case core_lint:module(St#compile.code, St#compile.options) of - {ok,Ws} -> - {ok,St#compile{warnings=St#compile.warnings ++ Ws}}; - {error,Es,Ws} -> - {error,St#compile{warnings=St#compile.warnings ++ Ws, - errors=St#compile.errors ++ Es}} - end. - -%% expand_module(State) -> State' -%% Do the common preprocessing of the input forms. - -expand_module(#compile{code=Code,options=Opts0}=St0) -> - {Mod,Exp,Forms,Opts1} = sys_pre_expand:module(Code, Opts0), - Opts2 = expand_opts(Opts1), - Opts = filter_opts(Opts2), - {ok,St0#compile{module=Mod,options=Opts,code={Mod,Exp,Forms}}}. - -core_module(#compile{code=Code0,options=Opts,ifile=File}=St) -> - {ok,Code,Ws} = v3_core:module(Code0, Opts), - {ok,St#compile{code=Code,warnings=St#compile.warnings ++ [{File,Ws}]}}. - -core_fold_module(#compile{code=Code0,options=Opts,ifile=File}=St) -> - {ok,Code,Ws} = sys_core_fold:module(Code0, Opts), - {ok,St#compile{code=Code,warnings=St#compile.warnings ++ [{File,Ws}]}}. - -test_old_inliner(#compile{options=Opts}) -> - %% The point of this test is to avoid loading the old inliner - %% if we know that it will not be used. - case any(fun(no_inline) -> true; - (_) -> false - end, Opts) of - true -> false; - false -> - any(fun({inline,_}) -> true; - (_) -> false - end, Opts) - end. - -test_core_inliner(#compile{options=Opts}) -> - case any(fun(no_inline) -> true; - (_) -> false - end, Opts) of - true -> false; - false -> - any(fun(inline) -> true; - (_) -> false - end, Opts) - end. - -core_old_inliner(#compile{code=Code0,options=Opts}=St) -> - case catch sys_core_inline:module(Code0, Opts) of - {ok,Code} -> - {ok,St#compile{code=Code}}; - {error,Es} -> - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -core_inline_module(#compile{code=Code0,options=Opts}=St) -> - Code = cerl_inline:core_transform(Code0, Opts), - {ok,St#compile{code=Code}}. - -core_dsetel_module(#compile{code=Code0,options=Opts}=St) -> - {ok,Code} = sys_core_dsetel:module(Code0, Opts), - {ok,St#compile{code=Code}}. - -kernel_module(#compile{code=Code0,options=Opts,ifile=File}=St) -> - {ok,Code,Ws} = v3_kernel:module(Code0, Opts), - {ok,St#compile{code=Code,warnings=St#compile.warnings ++ [{File,Ws}]}}. - -save_abstract_code(St) -> - {ok,St#compile{abstract_code=abstract_code(St)}}. - -abstract_code(#compile{code=Code}) -> - Abstr = {raw_abstract_v1,Code}, - case catch erlang:term_to_binary(Abstr, [compressed]) of - {'EXIT',_} -> term_to_binary(Abstr); - Other -> Other - end. - -save_core_code(St) -> - {ok,St#compile{core_code=cerl:from_records(St#compile.code)}}. - -beam_unused_labels(#compile{code=Code0}=St) -> - Code = beam_jump:module_labels(Code0), - {ok,St#compile{code=Code}}. - -beam_asm(#compile{ifile=File,code=Code0,abstract_code=Abst,options=Opts0}=St) -> - Source = filename:absname(File), - Opts = filter(fun is_informative_option/1, Opts0), - case beam_asm:module(Code0, Abst, Source, Opts) of - {ok,Code} -> {ok,St#compile{code=Code,abstract_code=[]}}; - {error,Es} -> {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -test_native(#compile{options=Opts}) -> - %% This test must be made late, because the r7 or no_new_funs options - %% will turn off the native option. - member(native, Opts). - -native_compile(#compile{code=none}=St) -> {ok,St}; -native_compile(St) -> - case erlang:system_info(hipe_architecture) of - undefined -> - Ws = [{St#compile.ifile,[{none,compile,no_native_support}]}], - {ok,St#compile{warnings=St#compile.warnings ++ Ws}}; - _ -> - native_compile_1(St) - end. - -native_compile_1(St) -> - Opts0 = [no_new_binaries|St#compile.options], - IgnoreErrors = member(ignore_native_errors, Opts0), - Opts = case keysearch(hipe, 1, Opts0) of - {value,{hipe,L}} when list(L) -> L; - {value,{hipe,X}} -> [X]; - _ -> [] - end, - case catch hipe:compile(St#compile.module, - St#compile.core_code, - St#compile.code, - Opts) of - {ok, {Type,Bin}} when binary(Bin) -> - {ok, embed_native_code(St, {Type,Bin})}; - {error, R} -> - case IgnoreErrors of - true -> - Ws = [{St#compile.ifile,[{none,?MODULE,{native,R}}]}], - {ok,St#compile{warnings=St#compile.warnings ++ Ws}}; - false -> - Es = [{St#compile.ifile,[{none,?MODULE,{native,R}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end; - {'EXIT',R} -> - case IgnoreErrors of - true -> - Ws = [{St#compile.ifile,[{none,?MODULE,{native_crash,R}}]}], - {ok,St#compile{warnings=St#compile.warnings ++ Ws}}; - false -> - exit(R) - end - end. - -embed_native_code(St, {Architecture,NativeCode}) -> - {ok, _, Chunks0} = beam_lib:all_chunks(St#compile.code), - ChunkName = hipe_unified_loader:chunk_name(Architecture), - Chunks1 = lists:keydelete(ChunkName, 1, Chunks0), - Chunks = Chunks1 ++ [{ChunkName,NativeCode}], - {ok, BeamPlusNative} = beam_lib:build_module(Chunks), - St#compile{code=BeamPlusNative}. - -%% Returns true if the option is informative and therefore should be included -%% in the option list of the compiled module. - -is_informative_option(beam) -> false; -is_informative_option(report_warnings) -> false; -is_informative_option(report_errors) -> false; -is_informative_option(binary) -> false; -is_informative_option(verbose) -> false; -is_informative_option(_) -> true. - -save_binary(#compile{code=none}=St) -> {ok,St}; -save_binary(St) -> - Tfile = tmpfile(St#compile.ofile), %Temp working file - case write_binary(Tfile, St#compile.code, St) of - ok -> - case file:rename(Tfile, St#compile.ofile) of - ok -> - {ok,St}; - {error,_Error} -> - file:delete(Tfile), - Es = [{St#compile.ofile,[{none,?MODULE,{rename,Tfile}}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end; - {error,_Error} -> - Es = [{Tfile,[{compile,write_error}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -write_binary(Name, Bin, St) -> - Opts = case member(compressed, St#compile.options) of - true -> [compressed]; - false -> [] - end, - case file:write_file(Name, Bin, Opts) of - ok -> ok; - {error,_}=Error -> Error - end. - -%% report_errors(State) -> ok -%% report_warnings(State) -> ok - -report_errors(St) -> - case member(report_errors, St#compile.options) of - true -> - foreach(fun ({{F,_L},Eds}) -> list_errors(F, Eds); - ({F,Eds}) -> list_errors(F, Eds) end, - St#compile.errors); - false -> ok - end. - -report_warnings(#compile{options=Opts,warnings=Ws0}) -> - case member(report_warnings, Opts) of - true -> - Ws1 = flatmap(fun({{F,_L},Eds}) -> format_message(F, Eds); - ({F,Eds}) -> format_message(F, Eds) end, - Ws0), - Ws = ordsets:from_list(Ws1), - foreach(fun({_,Str}) -> io:put_chars(Str) end, Ws); - false -> ok - end. - -format_message(F, [{Line,Mod,E}|Es]) -> - M = {Line,io_lib:format("~s:~w: Warning: ~s\n", [F,Line,Mod:format_error(E)])}, - [M|format_message(F, Es)]; -format_message(F, [{Mod,E}|Es]) -> - M = {none,io_lib:format("~s: Warning: ~s\n", [F,Mod:format_error(E)])}, - [M|format_message(F, Es)]; -format_message(_, []) -> []. - -%% list_errors(File, ErrorDescriptors) -> ok - -list_errors(F, [{Line,Mod,E}|Es]) -> - io:fwrite("~s:~w: ~s\n", [F,Line,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(F, [{Mod,E}|Es]) -> - io:fwrite("~s: ~s\n", [F,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(_F, []) -> ok. - -%% erlfile(Dir, Base) -> ErlFile -%% outfile(Base, Extension, Options) -> OutputFile -%% objfile(Base, Target, Options) -> ObjFile -%% tmpfile(ObjFile) -> TmpFile -%% Work out the correct input and output file names. - -iofile(File) when atom(File) -> - iofile(atom_to_list(File)); -iofile(File) -> - {filename:dirname(File), filename:basename(File, ".erl")}. - -erlfile(Dir, Base, Suffix) -> - filename:join(Dir, Base++Suffix). - -outfile(Base, Ext, Opts) when atom(Ext) -> - outfile(Base, atom_to_list(Ext), Opts); -outfile(Base, Ext, Opts) -> - Obase = case keysearch(outdir, 1, Opts) of - {value, {outdir, Odir}} -> filename:join(Odir, Base); - _Other -> Base % Not found or bad format - end, - Obase++"."++Ext. - -objfile(Base, St) -> - outfile(Base, "beam", St#compile.options). - -tmpfile(Ofile) -> - reverse([$#|tl(reverse(Ofile))]). - -%% pre_defs(Options) -%% inc_paths(Options) -%% Extract the predefined macros and include paths from the option list. - -pre_defs([{d,M,V}|Opts]) -> - [{M,V}|pre_defs(Opts)]; -pre_defs([{d,M}|Opts]) -> - [M|pre_defs(Opts)]; -pre_defs([_|Opts]) -> - pre_defs(Opts); -pre_defs([]) -> []. - -inc_paths(Opts) -> - [ P || {i,P} <- Opts, list(P) ]. - -src_listing(Ext, St) -> - listing(fun (Lf, {_Mod,_Exp,Fs}) -> do_src_listing(Lf, Fs); - (Lf, Fs) -> do_src_listing(Lf, Fs) end, - Ext, St). - -do_src_listing(Lf, Fs) -> - foreach(fun (F) -> io:put_chars(Lf, [erl_pp:form(F),"\n"]) end, - Fs). - -listing(Ext, St) -> - listing(fun(Lf, Fs) -> beam_listing:module(Lf, Fs) end, Ext, St). - -listing(LFun, Ext, St) -> - Lfile = outfile(St#compile.base, Ext, St#compile.options), - case file:open(Lfile, [write,delayed_write]) of - {ok,Lf} -> - LFun(Lf, St#compile.code), - ok = file:close(Lf), - {ok,St}; - {error,_Error} -> - Es = [{Lfile,[{none,compile,write_error}]}], - {error,St#compile{errors=St#compile.errors ++ Es}} - end. - -options() -> - help(standard_passes()). - -help([{iff,Flag,{src_listing,Ext}}|T]) -> - io:fwrite("~p - Generate .~s source listing file\n", [Flag,Ext]), - help(T); -help([{iff,Flag,{listing,Ext}}|T]) -> - io:fwrite("~p - Generate .~s file\n", [Flag,Ext]), - help(T); -help([{iff,Flag,{Name,Fun}}|T]) when function(Fun) -> - io:fwrite("~p - Run ~s\n", [Flag,Name]), - help(T); -help([{iff,_Flag,Action}|T]) -> - help(Action), - help(T); -help([{unless,Flag,{pass,Pass}}|T]) -> - io:fwrite("~p - Skip the ~s pass\n", [Flag,Pass]), - help(T); -help([{unless,no_postopt=Flag,List}|T]) when list(List) -> - %% Hard-coded knowledgde here. - io:fwrite("~p - Skip all post optimisation\n", [Flag]), - help(List), - help(T); -help([{unless,_Flag,Action}|T]) -> - help(Action), - help(T); -help([_|T]) -> - help(T); -help(_) -> - ok. - - -%% compile(AbsFileName, Outfilename, Options) -%% Compile entry point for erl_compile. - -compile(File0, _OutFile, Options) -> - File = shorten_filename(File0), - case file(File, make_erl_options(Options)) of - {ok,_Mod} -> ok; - Other -> Other - end. - -compile_beam(File0, _OutFile, Opts) -> - File = shorten_filename(File0), - case file(File, [from_beam|make_erl_options(Opts)]) of - {ok,_Mod} -> ok; - Other -> Other - end. - -compile_asm(File0, _OutFile, Opts) -> - File = shorten_filename(File0), - case file(File, [asm|make_erl_options(Opts)]) of - {ok,_Mod} -> ok; - Other -> Other - end. - -compile_core(File0, _OutFile, Opts) -> - File = shorten_filename(File0), - case file(File, [from_core|make_erl_options(Opts)]) of - {ok,_Mod} -> ok; - Other -> Other - end. - -shorten_filename(Name0) -> - {ok,Cwd} = file:get_cwd(), - case lists:prefix(Cwd, Name0) of - false -> Name0; - true -> - Name = case lists:nthtail(length(Cwd), Name0) of - "/"++N -> N; - N -> N - end, - Name - end. - -%% Converts generic compiler options to specific options. - -make_erl_options(Opts) -> - - %% This way of extracting will work even if the record passed - %% has more fields than known during compilation. - - Includes = Opts#options.includes, - Defines = Opts#options.defines, - Outdir = Opts#options.outdir, - Warning = Opts#options.warning, - Verbose = Opts#options.verbose, - Specific = Opts#options.specific, - OutputType = Opts#options.output_type, - Cwd = Opts#options.cwd, - - Options = - case Verbose of - true -> [verbose]; - false -> [] - end ++ - case Warning of - 0 -> []; - _ -> [report_warnings] - end ++ - map( - fun ({Name, Value}) -> - {d, Name, Value}; - (Name) -> - {d, Name} - end, - Defines) ++ - case OutputType of - undefined -> []; - jam -> [jam]; - beam -> [beam]; - native -> [native] - end, - - Options++[report_errors, {cwd, Cwd}, {outdir, Outdir}| - map(fun(Dir) -> {i, Dir} end, Includes)]++Specific. diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_lib.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_lib.erl deleted file mode 100644 index 3a6158286f..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_lib.erl +++ /dev/null @@ -1,509 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: core_lib.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% -%% Purpose: Core Erlang abstract syntax functions. - --module(core_lib). - --export([get_anno/1,set_anno/2]). --export([is_atomic/1,is_literal/1,is_literal_list/1, - is_simple/1,is_simple_list/1,is_simple_top/1]). --export([literal_value/1,make_literal/1]). --export([make_values/1]). --export([map/2, fold/3, mapfold/3]). --export([is_var_used/2]). - -%% -compile([export_all]). - --include("core_parse.hrl"). - -%% get_anno(Core) -> Anno. -%% set_anno(Core, Anno) -> Core. -%% Generic get/set annotation. - -get_anno(C) -> element(2, C). -set_anno(C, A) -> setelement(2, C, A). - -%% is_atomic(Expr) -> true | false. - -is_atomic(#c_char{}) -> true; -is_atomic(#c_int{}) -> true; -is_atomic(#c_float{}) -> true; -is_atomic(#c_atom{}) -> true; -is_atomic(#c_string{}) -> true; -is_atomic(#c_nil{}) -> true; -is_atomic(#c_fname{}) -> true; -is_atomic(_) -> false. - -%% is_literal(Expr) -> true | false. - -is_literal(#c_cons{hd=H,tl=T}) -> - case is_literal(H) of - true -> is_literal(T); - false -> false - end; -is_literal(#c_tuple{es=Es}) -> is_literal_list(Es); -is_literal(#c_binary{segments=Es}) -> is_lit_bin(Es); -is_literal(E) -> is_atomic(E). - -is_literal_list(Es) -> lists:all(fun is_literal/1, Es). - -is_lit_bin(Es) -> - lists:all(fun (#c_bitstr{val=E,size=S}) -> - is_literal(E) and is_literal(S) - end, Es). - -%% is_simple(Expr) -> true | false. - -is_simple(#c_var{}) -> true; -is_simple(#c_cons{hd=H,tl=T}) -> - case is_simple(H) of - true -> is_simple(T); - false -> false - end; -is_simple(#c_tuple{es=Es}) -> is_simple_list(Es); -is_simple(#c_binary{segments=Es}) -> is_simp_bin(Es); -is_simple(E) -> is_atomic(E). - -is_simple_list(Es) -> lists:all(fun is_simple/1, Es). - -is_simp_bin(Es) -> - lists:all(fun (#c_bitstr{val=E,size=S}) -> - is_simple(E) and is_simple(S) - end, Es). - -%% is_simple_top(Expr) -> true | false. -%% Only check if the top-level is a simple. - -is_simple_top(#c_var{}) -> true; -is_simple_top(#c_cons{}) -> true; -is_simple_top(#c_tuple{}) -> true; -is_simple_top(#c_binary{}) -> true; -is_simple_top(E) -> is_atomic(E). - -%% literal_value(LitExpr) -> Value. -%% Return the value of LitExpr. - -literal_value(#c_char{val=C}) -> C; -literal_value(#c_int{val=I}) -> I; -literal_value(#c_float{val=F}) -> F; -literal_value(#c_atom{val=A}) -> A; -literal_value(#c_string{val=S}) -> S; -literal_value(#c_nil{}) -> []; -literal_value(#c_cons{hd=H,tl=T}) -> - [literal_value(H)|literal_value(T)]; -literal_value(#c_tuple{es=Es}) -> - list_to_tuple(literal_value_list(Es)). - -literal_value_list(Vals) -> lists:map(fun literal_value/1, Vals). - -%% make_literal(Value) -> LitExpr. -%% Make a literal expression from an Erlang value. - -make_literal(I) when integer(I) -> #c_int{val=I}; -make_literal(F) when float(F) -> #c_float{val=F}; -make_literal(A) when atom(A) -> #c_atom{val=A}; -make_literal([]) -> #c_nil{}; -make_literal([H|T]) -> - #c_cons{hd=make_literal(H),tl=make_literal(T)}; -make_literal(T) when tuple(T) -> - #c_tuple{es=make_literal_list(tuple_to_list(T))}. - -make_literal_list(Vals) -> lists:map(fun make_literal/1, Vals). - -%% make_values([CoreExpr] | CoreExpr) -> #c_values{} | CoreExpr. -%% Make a suitable values structure, expr or values, depending on -%% Expr. - -make_values([E]) -> E; -make_values([H|_]=Es) -> #c_values{anno=get_anno(H),es=Es}; -make_values([]) -> #c_values{es=[]}; -make_values(E) -> E. - -%% map(MapFun, CoreExpr) -> CoreExpr. -%% This function traverses the core parse format, at each level -%% applying the submited argument function, assumed to do the real -%% work. -%% -%% The "eager" style, where each component of a construct are -%% descended to before the construct itself, admits that some -%% companion functions (the F:s) may be made simpler, since it may be -%% safely assumed that no lower illegal instanced will be -%% created/uncovered by actions on the current level. - -map(F, #c_tuple{es=Es}=R) -> - F(R#c_tuple{es=map_list(F, Es)}); -map(F, #c_cons{hd=Hd, tl=Tl}=R) -> - F(R#c_cons{hd=map(F, Hd), - tl=map(F, Tl)}); -map(F, #c_values{es=Es}=R) -> - F(R#c_values{es=map_list(F, Es)}); - -map(F, #c_alias{var=Var, pat=Pat}=R) -> - F(R#c_alias{var=map(F, Var), - pat=map(F, Pat)}); - -map(F, #c_module{defs=Defs}=R) -> - F(R#c_module{defs=map_list(F, Defs)}); -map(F, #c_def{val=Val}=R) -> - F(R#c_def{val=map(F, Val)}); - -map(F, #c_fun{vars=Vars, body=Body}=R) -> - F(R#c_fun{vars=map_list(F, Vars), - body=map(F, Body)}); -map(F, #c_let{vars=Vs, arg=Arg, body=Body}=R) -> - F(R#c_let{vars=map_list(F, Vs), - arg=map(F, Arg), - body=map(F, Body)}); -map(F, #c_letrec{defs=Fs,body=Body}=R) -> - F(R#c_letrec{defs=map_list(F, Fs), - body=map(F, Body)}); -map(F, #c_seq{arg=Arg, body=Body}=R) -> - F(R#c_seq{arg=map(F, Arg), - body=map(F, Body)}); -map(F, #c_case{arg=Arg, clauses=Clauses}=R) -> - F(R#c_case{arg=map(F, Arg), - clauses=map_list(F, Clauses)}); -map(F, #c_clause{pats=Ps, guard=Guard, body=Body}=R) -> - F(R#c_clause{pats=map_list(F, Ps), - guard=map(F, Guard), - body=map(F, Body)}); -map(F, #c_receive{clauses=Cls, timeout=Tout, action=Act}=R) -> - F(R#c_receive{clauses=map_list(F, Cls), - timeout=map(F, Tout), - action=map(F, Act)}); -map(F, #c_apply{op=Op,args=Args}=R) -> - F(R#c_apply{op=map(F, Op), - args=map_list(F, Args)}); -map(F, #c_call{module=M,name=N,args=Args}=R) -> - F(R#c_call{module=map(F, M), - name=map(F, N), - args=map_list(F, Args)}); -map(F, #c_primop{name=N,args=Args}=R) -> - F(R#c_primop{name=map(F, N), - args=map_list(F, Args)}); -map(F, #c_try{arg=Expr,vars=Vars,body=Body,evars=Evars,handler=Handler}=R) -> - F(R#c_try{arg=map(F, Expr), - vars=map(F, Vars), - body=map(F, Body), - evars=map(F, Evars), - handler=map(F, Handler)}); -map(F, #c_catch{body=Body}=R) -> - F(R#c_catch{body=map(F, Body)}); -map(F, T) -> F(T). %Atomic nodes. - -map_list(F, L) -> lists:map(fun (E) -> map(F, E) end, L). - -%% fold(FoldFun, Accumulator, CoreExpr) -> Accumulator. -%% This function traverses the core parse format, at each level -%% applying the submited argument function, assumed to do the real -%% work, and keeping the accumulated result in the A (accumulator) -%% argument. - -fold(F, Acc, #c_tuple{es=Es}=R) -> - F(R, fold_list(F, Acc, Es)); -fold(F, Acc, #c_cons{hd=Hd, tl=Tl}=R) -> - F(R, fold(F, fold(F, Acc, Hd), Tl)); -fold(F, Acc, #c_values{es=Es}=R) -> - F(R, fold_list(F, Acc, Es)); - -fold(F, Acc, #c_alias{pat=P,var=V}=R) -> - F(R, fold(F, fold(F, Acc, P), V)); - -fold(F, Acc, #c_module{defs=Defs}=R) -> - F(R, fold_list(F, Acc, Defs)); -fold(F, Acc, #c_def{val=Val}=R) -> - F(R, fold(F, Acc, Val)); - -fold(F, Acc, #c_fun{vars=Vars, body=Body}=R) -> - F(R, fold(F, fold_list(F, Acc, Vars), Body)); -fold(F, Acc, #c_let{vars=Vs, arg=Arg, body=Body}=R) -> - F(R, fold(F, fold(F, fold_list(F, Acc, Vs), Arg), Body)); -fold(F, Acc, #c_letrec{defs=Fs,body=Body}=R) -> - F(R, fold(F, fold_list(F, Acc, Fs), Body)); -fold(F, Acc, #c_seq{arg=Arg, body=Body}=R) -> - F(R, fold(F, fold(F, Acc, Arg), Body)); -fold(F, Acc, #c_case{arg=Arg, clauses=Clauses}=R) -> - F(R, fold_list(F, fold(F, Acc, Arg), Clauses)); -fold(F, Acc, #c_clause{pats=Ps,guard=G,body=B}=R) -> - F(R, fold(F, fold(F, fold_list(F, Acc, Ps), G), B)); -fold(F, Acc, #c_receive{clauses=Cl, timeout=Ti, action=Ac}=R) -> - F(R, fold_list(F, fold(F, fold(F, Acc, Ac), Ti), Cl)); -fold(F, Acc, #c_apply{op=Op, args=Args}=R) -> - F(R, fold_list(F, fold(F, Acc, Op), Args)); -fold(F, Acc, #c_call{module=Mod,name=Name,args=Args}=R) -> - F(R, fold_list(F, fold(F, fold(F, Acc, Mod), Name), Args)); -fold(F, Acc, #c_primop{name=Name,args=Args}=R) -> - F(R, fold_list(F, fold(F, Acc, Name), Args)); -fold(F, Acc, #c_try{arg=E,vars=Vs,body=Body,evars=Evs,handler=H}=R) -> - NewB = fold(F, fold_list(F, fold(F, Acc, E), Vs), Body), - F(R, fold(F, fold_list(F, NewB, Evs), H)); -fold(F, Acc, #c_catch{body=Body}=R) -> - F(R, fold(F, Acc, Body)); -fold(F, Acc, T) -> %Atomic nodes - F(T, Acc). - -fold_list(F, Acc, L) -> - lists:foldl(fun (E, A) -> fold(F, A, E) end, Acc, L). - -%% mapfold(MapfoldFun, Accumulator, CoreExpr) -> {CoreExpr,Accumulator}. -%% This function traverses the core parse format, at each level -%% applying the submited argument function, assumed to do the real -%% work, and keeping the accumulated result in the A (accumulator) -%% argument. - -mapfold(F, Acc0, #c_tuple{es=Es0}=R) -> - {Es1,Acc1} = mapfold_list(F, Acc0, Es0), - F(R#c_tuple{es=Es1}, Acc1); -mapfold(F, Acc0, #c_cons{hd=H0,tl=T0}=R) -> - {H1,Acc1} = mapfold(F, Acc0, H0), - {T1,Acc2} = mapfold(F, Acc1, T0), - F(R#c_cons{hd=H1,tl=T1}, Acc2); -mapfold(F, Acc0, #c_values{es=Es0}=R) -> - {Es1,Acc1} = mapfold_list(F, Acc0, Es0), - F(R#c_values{es=Es1}, Acc1); - -mapfold(F, Acc0, #c_alias{pat=P0,var=V0}=R) -> - {P1,Acc1} = mapfold(F, Acc0, P0), - {V1,Acc2} = mapfold(F, Acc1, V0), - F(R#c_alias{pat=P1,var=V1}, Acc2); - -mapfold(F, Acc0, #c_module{defs=D0}=R) -> - {D1,Acc1} = mapfold_list(F, Acc0, D0), - F(R#c_module{defs=D1}, Acc1); -mapfold(F, Acc0, #c_def{val=V0}=R) -> - {V1,Acc1} = mapfold(F, Acc0, V0), - F(R#c_def{val=V1}, Acc1); - -mapfold(F, Acc0, #c_fun{vars=Vs0, body=B0}=R) -> - {Vs1,Acc1} = mapfold_list(F, Acc0, Vs0), - {B1,Acc2} = mapfold(F, Acc1, B0), - F(R#c_fun{vars=Vs1,body=B1}, Acc2); -mapfold(F, Acc0, #c_let{vars=Vs0, arg=A0, body=B0}=R) -> - {Vs1,Acc1} = mapfold_list(F, Acc0, Vs0), - {A1,Acc2} = mapfold(F, Acc1, A0), - {B1,Acc3} = mapfold(F, Acc2, B0), - F(R#c_let{vars=Vs1,arg=A1,body=B1}, Acc3); -mapfold(F, Acc0, #c_letrec{defs=Fs0,body=B0}=R) -> - {Fs1,Acc1} = mapfold_list(F, Acc0, Fs0), - {B1,Acc2} = mapfold(F, Acc1, B0), - F(R#c_letrec{defs=Fs1,body=B1}, Acc2); -mapfold(F, Acc0, #c_seq{arg=A0, body=B0}=R) -> - {A1,Acc1} = mapfold(F, Acc0, A0), - {B1,Acc2} = mapfold(F, Acc1, B0), - F(R#c_seq{arg=A1,body=B1}, Acc2); -mapfold(F, Acc0, #c_case{arg=A0,clauses=Cs0}=R) -> - {A1,Acc1} = mapfold(F, Acc0, A0), - {Cs1,Acc2} = mapfold_list(F, Acc1, Cs0), - F(R#c_case{arg=A1,clauses=Cs1}, Acc2); -mapfold(F, Acc0, #c_clause{pats=Ps0,guard=G0,body=B0}=R) -> - {Ps1,Acc1} = mapfold_list(F, Acc0, Ps0), - {G1,Acc2} = mapfold(F, Acc1, G0), - {B1,Acc3} = mapfold(F, Acc2, B0), - F(R#c_clause{pats=Ps1,guard=G1,body=B1}, Acc3); -mapfold(F, Acc0, #c_receive{clauses=Cs0,timeout=T0,action=A0}=R) -> - {T1,Acc1} = mapfold(F, Acc0, T0), - {Cs1,Acc2} = mapfold_list(F, Acc1, Cs0), - {A1,Acc3} = mapfold(F, Acc2, A0), - F(R#c_receive{clauses=Cs1,timeout=T1,action=A1}, Acc3); -mapfold(F, Acc0, #c_apply{op=Op0, args=As0}=R) -> - {Op1,Acc1} = mapfold(F, Acc0, Op0), - {As1,Acc2} = mapfold_list(F, Acc1, As0), - F(R#c_apply{op=Op1,args=As1}, Acc2); -mapfold(F, Acc0, #c_call{module=M0,name=N0,args=As0}=R) -> - {M1,Acc1} = mapfold(F, Acc0, M0), - {N1,Acc2} = mapfold(F, Acc1, N0), - {As1,Acc3} = mapfold_list(F, Acc2, As0), - F(R#c_call{module=M1,name=N1,args=As1}, Acc3); -mapfold(F, Acc0, #c_primop{name=N0, args=As0}=R) -> - {N1,Acc1} = mapfold(F, Acc0, N0), - {As1,Acc2} = mapfold_list(F, Acc1, As0), - F(R#c_primop{name=N1,args=As1}, Acc2); -mapfold(F, Acc0, #c_try{arg=E0,vars=Vs0,body=B0,evars=Evs0,handler=H0}=R) -> - {E1,Acc1} = mapfold(F, Acc0, E0), - {Vs1,Acc2} = mapfold_list(F, Acc1, Vs0), - {B1,Acc3} = mapfold(F, Acc2, B0), - {Evs1,Acc4} = mapfold_list(F, Acc3, Evs0), - {H1,Acc5} = mapfold(F, Acc4, H0), - F(R#c_try{arg=E1,vars=Vs1,body=B1,evars=Evs1,handler=H1}, Acc5); -mapfold(F, Acc0, #c_catch{body=B0}=R) -> - {B1,Acc1} = mapfold(F, Acc0, B0), - F(R#c_catch{body=B1}, Acc1); -mapfold(F, Acc, T) -> %Atomic nodes - F(T, Acc). - -mapfold_list(F, Acc, L) -> - lists:mapfoldl(fun (E, A) -> mapfold(F, A, E) end, Acc, L). - -%% is_var_used(VarName, Expr) -> true | false. -%% Test if the variable VarName is used in Expr. - -is_var_used(V, B) -> vu_body(V, B). - -vu_body(V, #c_values{es=Es}) -> - vu_expr_list(V, Es); -vu_body(V, Body) -> - vu_expr(V, Body). - -vu_expr(V, #c_var{name=V2}) -> V =:= V2; -vu_expr(V, #c_cons{hd=H,tl=T}) -> - case vu_expr(V, H) of - true -> true; - false -> vu_expr(V, T) - end; -vu_expr(V, #c_tuple{es=Es}) -> - vu_expr_list(V, Es); -vu_expr(V, #c_binary{segments=Ss}) -> - vu_seg_list(V, Ss); -vu_expr(V, #c_fun{vars=Vs,body=B}) -> - %% Variables in fun shadow previous variables - case vu_var_list(V, Vs) of - true -> false; - false -> vu_body(V, B) - end; -vu_expr(V, #c_let{vars=Vs,arg=Arg,body=B}) -> - case vu_body(V, Arg) of - true -> true; - false -> - %% Variables in let shadow previous variables. - case vu_var_list(V, Vs) of - true -> false; - false -> vu_body(V, B) - end - end; -vu_expr(V, #c_letrec{defs=Fs,body=B}) -> - case lists:any(fun (#c_def{val=Fb}) -> vu_body(V, Fb) end, Fs) of - true -> true; - false -> vu_body(V, B) - end; -vu_expr(V, #c_seq{arg=Arg,body=B}) -> - case vu_expr(V, Arg) of - true -> true; - false -> vu_body(V, B) - end; -vu_expr(V, #c_case{arg=Arg,clauses=Cs}) -> - case vu_expr(V, Arg) of - true -> true; - false -> vu_clauses(V, Cs) - end; -vu_expr(V, #c_receive{clauses=Cs,timeout=T,action=A}) -> - case vu_clauses(V, Cs) of - true -> true; - false -> - case vu_expr(V, T) of - true -> true; - false -> vu_body(V, A) - end - end; -vu_expr(V, #c_apply{op=Op,args=As}) -> - vu_expr_list(V, [Op|As]); -vu_expr(V, #c_call{module=M,name=N,args=As}) -> - vu_expr_list(V, [M,N|As]); -vu_expr(V, #c_primop{args=As}) -> %Name is an atom - vu_expr_list(V, As); -vu_expr(V, #c_catch{body=B}) -> - vu_body(V, B); -vu_expr(V, #c_try{arg=E,vars=Vs,body=B,evars=Evs,handler=H}) -> - case vu_body(V, E) of - true -> true; - false -> - %% Variables shadow previous ones. - case case vu_var_list(V, Vs) of - true -> false; - false -> vu_body(V, B) - end of - true -> true; - false -> - case vu_var_list(V, Evs) of - true -> false; - false -> vu_body(V, H) - end - end - end; -vu_expr(_, _) -> false. %Everything else - -vu_expr_list(V, Es) -> - lists:any(fun(E) -> vu_expr(V, E) end, Es). - -vu_seg_list(V, Ss) -> - lists:any(fun (#c_bitstr{val=Val,size=Size}) -> - case vu_expr(V, Val) of - true -> true; - false -> vu_expr(V, Size) - end - end, Ss). - -%% vu_clause(VarName, Clause) -> true | false. -%% vu_clauses(VarName, [Clause]) -> true | false. -%% Have to get the pattern results right. - -vu_clause(V, #c_clause{pats=Ps,guard=G,body=B}) -> - case vu_pattern_list(V, Ps) of - {true,_Shad} -> true; %It is used - {false,true} -> false; %Shadowed - {false,false} -> %Not affected - case vu_expr(V, G) of - true -> true; - false ->vu_body(V, B) - end - end. - -vu_clauses(V, Cs) -> - lists:any(fun(C) -> vu_clause(V, C) end, Cs). - -%% vu_pattern(VarName, Pattern) -> {Used,Shadow}. -%% vu_pattern_list(VarName, [Pattern]) -> {Used,Shadow}. -%% Binaries complicate patterns as a variable can both be properly -%% used, in a bit segment size, and shadow. They can also do both. - -%%vu_pattern(V, Pat) -> vu_pattern(V, Pat, {false,false}). - -vu_pattern(V, #c_var{name=V2}, St) -> - setelement(2, St, V =:= V2); -vu_pattern(V, #c_cons{hd=H,tl=T}, St0) -> - case vu_pattern(V, H, St0) of - {true,true}=St1 -> St1; %Nothing more to know - St1 -> vu_pattern(V, T, St1) - end; -vu_pattern(V, #c_tuple{es=Es}, St) -> - vu_pattern_list(V, Es, St); -vu_pattern(V, #c_binary{segments=Ss}, St) -> - vu_pat_seg_list(V, Ss, St); -vu_pattern(V, #c_alias{var=Var,pat=P}, St0) -> - case vu_pattern(V, Var, St0) of - {true,true}=St1 -> St1; - St1 -> vu_pattern(V, P, St1) - end; -vu_pattern(_, _, St) -> St. - -vu_pattern_list(V, Ps) -> vu_pattern_list(V, Ps, {false,false}). - -vu_pattern_list(V, Ps, St0) -> - lists:foldl(fun(P, St) -> vu_pattern(V, P, St) end, St0, Ps). - -vu_pat_seg_list(V, Ss, St) -> - lists:foldl(fun (#c_bitstr{val=Val,size=Size}, St0) -> - case vu_pattern(V, Val, St0) of - {true,true}=St1 -> St1; - {_Used,Shad} -> {vu_expr(V, Size),Shad} - end - end, St, Ss). - -%% vu_var_list(VarName, [Var]) -> true | false. - -vu_var_list(V, Vs) -> - lists:any(fun (#c_var{name=V2}) -> V =:= V2 end, Vs). diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_lint.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_lint.erl deleted file mode 100644 index 2946fcb8c0..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_lint.erl +++ /dev/null @@ -1,515 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: core_lint.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% -%% Purpose : Do necessary checking of Core Erlang code. - -%% Check Core module for errors. Seeing this module is used in the -%% compiler after optimisations wedone more checking than would be -%% necessary after just parsing. Don't check all constructs. -%% -%% We check the following: -%% -%% All referred functions, called and exported, are defined. -%% Format of export list. -%% Format of attributes -%% Used variables are defined. -%% Variables in let and funs. -%% Patterns case clauses. -%% Values only as multiple values/variables/patterns. -%% Return same number of values as requested -%% Correct number of arguments -%% -%% Checks to add: -%% -%% Consistency of values/variables -%% Consistency of function return values/calls. -%% -%% We keep the names defined variables and functions in a ordered list -%% of variable names and function name/arity pairs. - --module(core_lint). - - --export([module/1,module/2,format_error/1]). - --import(lists, [reverse/1,all/2,foldl/3]). --import(ordsets, [add_element/2,is_element/2,union/2]). -%-import(ordsets, [subtract/2]). - --include("core_parse.hrl"). - -%% Define the lint state record. - --record(lint, {module=[], %Current module - func=[], %Current function - errors=[], %Errors - warnings=[]}). %Warnings - -%% Keep track of defined --record(def, {vars=[], - funs=[]}). - -%%-deftype retcount() -> any | unknown | int(). - -%% format_error(Error) -%% Return a string describing the error. - -format_error(invalid_exports) -> "invalid exports"; -format_error(invalid_attributes) -> "invalid attributes"; -format_error({undefined_function,{F,A}}) -> - io_lib:format("function ~w/~w undefined", [F,A]); -format_error({undefined_function,{F1,A1},{F2,A2}}) -> - io_lib:format("undefined function ~w/~w in ~w/~w", [F1,A1,F2,A2]); -format_error({illegal_expr,{F,A}}) -> - io_lib:format("illegal expression in ~w/~w", [F,A]); -format_error({illegal_guard,{F,A}}) -> - io_lib:format("illegal guard expression in ~w/~w", [F,A]); -format_error({illegal_pattern,{F,A}}) -> - io_lib:format("illegal pattern in ~w/~w", [F,A]); -format_error({illegal_try,{F,A}}) -> - io_lib:format("illegal try expression in ~w/~w", [F,A]); -format_error({pattern_mismatch,{F,A}}) -> - io_lib:format("pattern count mismatch in ~w/~w", [F,A]); -format_error({return_mismatch,{F,A}}) -> - io_lib:format("return count mismatch in ~w/~w", [F,A]); -format_error({arg_mismatch,{F,A}}) -> - io_lib:format("argument count mismatch in ~w/~w", [F,A]); -format_error({unbound_var,N,{F,A}}) -> - io_lib:format("unbound variable ~s in ~w/~w", [N,F,A]); -format_error({duplicate_var,N,{F,A}}) -> - io_lib:format("duplicate variable ~s in ~w/~w", [N,F,A]); -format_error({not_var,{F,A}}) -> - io_lib:format("expecting variable in ~w/~w", [F,A]); -format_error({not_pattern,{F,A}}) -> - io_lib:format("expecting pattern in ~w/~w", [F,A]); -format_error({not_bs_pattern,{F,A}}) -> - io_lib:format("expecting bit syntax pattern in ~w/~w", [F,A]). - -%% module(CoreMod) -> -%% module(CoreMod, [CompileOption]) -> -%% {ok,[Warning]} | {error,[Error],[Warning]} - -module(M) -> module(M, []). - -module(#c_module{name=M,exports=Es,attrs=As,defs=Ds}, _Opts) -> - Defined = defined_funcs(Ds), - St0 = #lint{module=M#c_atom.val}, - St1 = check_exports(Es, St0), - St2 = check_attrs(As, St1), - St3 = module_defs(Ds, Defined, St2), - St4 = check_state(Es, Defined, St3), - return_status(St4). - -%% defined_funcs([FuncDef]) -> [Fname]. - -defined_funcs(Fs) -> - foldl(fun (#c_def{name=#c_fname{id=I,arity=A}}, Def) -> - add_element({I,A}, Def) - end, [], Fs). - -%% return_status(State) -> -%% {ok,[Warning]} | {error,[Error],[Warning]} -%% Pack errors and warnings properly and return ok | error. - -return_status(St) -> - Ws = reverse(St#lint.warnings), - case reverse(St#lint.errors) of - [] -> {ok,[{St#lint.module,Ws}]}; - Es -> {error,[{St#lint.module,Es}],[{St#lint.module,Ws}]} - end. - -%% add_error(ErrorDescriptor, State) -> State' -%% add_warning(ErrorDescriptor, State) -> State' -%% Note that we don't use line numbers here. - -add_error(E, St) -> St#lint{errors=[{none,core_lint,E}|St#lint.errors]}. - -%%add_warning(W, St) -> St#lint{warnings=[{none,core_lint,W}|St#lint.warnings]}. - -check_exports(Es, St) -> - case all(fun (#c_fname{id=Name,arity=Arity}) when - atom(Name), integer(Arity) -> true; - (_) -> false - end, Es) of - true -> St; - false -> add_error(invalid_exports, St) - end. - -check_attrs(As, St) -> - case all(fun (#c_def{name=#c_atom{},val=V}) -> core_lib:is_literal(V); - (_) -> false - end, As) of - true -> St; - false -> add_error(invalid_attributes, St) - end. - -check_state(Es, Defined, St) -> - foldl(fun (#c_fname{id=N,arity=A}, St1) -> - F = {N,A}, - case is_element(F, Defined) of - true -> St1; - false -> add_error({undefined_function,F}, St) - end - end, St, Es). -% Undef = subtract(Es, Defined), -% St1 = foldl(fun (F, St) -> add_error({undefined_function,F}, St) end, -% St0, Undef), -% St1. - -%% module_defs(CoreBody, Defined, State) -> State. - -module_defs(B, Def, St) -> - %% Set top level function name. - foldl(fun (Func, St0) -> - #c_fname{id=F,arity=A} = Func#c_def.name, - St1 = St0#lint{func={F,A}}, - function(Func, Def, St1) - end, St, B). - -%% functions([Fdef], Defined, State) -> State. - -functions(Fs, Def, St0) -> - foldl(fun (F, St) -> function(F, Def, St) end, St0, Fs). - -%% function(CoreFunc, Defined, State) -> State. - -function(#c_def{name=#c_fname{},val=B}, Def, St) -> - %% Body must be a fun! - case B of - #c_fun{} -> expr(B, Def, any, St); - _ -> add_error({illegal_expr,St#lint.func}, St) - end. - -%% body(Expr, Defined, RetCount, State) -> State. - -body(#c_values{es=Es}, Def, Rt, St) -> - return_match(Rt, length(Es), expr_list(Es, Def, St)); -body(E, Def, Rt, St0) -> - St1 = expr(E, Def, Rt, St0), - case core_lib:is_simple_top(E) of - true -> return_match(Rt, 1, St1); - false -> St1 - end. - -%% guard(Expr, Defined, State) -> State. -%% Guards are boolean expressions with test wrapped in a protected. - -guard(Expr, Def, St) -> gexpr(Expr, Def, 1, St). - -%% guard_list([Expr], Defined, State) -> State. - -%% guard_list(Es, Def, St0) -> -%% foldl(fun (E, St) -> guard(E, Def, St) end, St0, Es). - -%% gbody(Expr, Defined, RetCount, State) -> State. - -gbody(#c_values{es=Es}, Def, Rt, St) -> - return_match(Rt, length(Es), gexpr_list(Es, Def, St)); -gbody(E, Def, Rt, St0) -> - St1 = gexpr(E, Def, Rt, St0), - case core_lib:is_simple_top(E) of - true -> return_match(Rt, 1, St1); - false -> St1 - end. - -gexpr(#c_var{name=N}, Def, _Rt, St) -> expr_var(N, Def, St); -gexpr(#c_int{}, _Def, _Rt, St) -> St; -gexpr(#c_float{}, _Def, _Rt, St) -> St; -gexpr(#c_atom{}, _Def, _Rt, St) -> St; -gexpr(#c_char{}, _Def, _Rt, St) -> St; -gexpr(#c_string{}, _Def, _Rt, St) -> St; -gexpr(#c_nil{}, _Def, _Rt, St) -> St; -gexpr(#c_cons{hd=H,tl=T}, Def, _Rt, St) -> - gexpr_list([H,T], Def, St); -gexpr(#c_tuple{es=Es}, Def, _Rt, St) -> - gexpr_list(Es, Def, St); -gexpr(#c_binary{segments=Ss}, Def, _Rt, St) -> - gbitstr_list(Ss, Def, St); -gexpr(#c_seq{arg=Arg,body=B}, Def, Rt, St0) -> - St1 = gexpr(Arg, Def, any, St0), %Ignore values - gbody(B, Def, Rt, St1); -gexpr(#c_let{vars=Vs,arg=Arg,body=B}, Def, Rt, St0) -> - St1 = gbody(Arg, Def, let_varcount(Vs), St0), %This is a guard body - {Lvs,St2} = variable_list(Vs, St1), - gbody(B, union(Lvs, Def), Rt, St2); -gexpr(#c_call{module=#c_atom{val=erlang}, - name=#c_atom{}, - args=As}, Def, 1, St) -> - gexpr_list(As, Def, St); -gexpr(#c_primop{name=N,args=As}, Def, _Rt, St0) when record(N, c_atom) -> - gexpr_list(As, Def, St0); -gexpr(#c_try{arg=E,vars=[#c_var{name=X}],body=#c_var{name=X}, - evars=[#c_var{},#c_var{},#c_var{}],handler=#c_atom{val=false}}, - Def, Rt, St) -> - gbody(E, Def, Rt, St); -gexpr(_, _, _, St) -> - add_error({illegal_guard,St#lint.func}, St). - -%% gexpr_list([Expr], Defined, State) -> State. - -gexpr_list(Es, Def, St0) -> - foldl(fun (E, St) -> gexpr(E, Def, 1, St) end, St0, Es). - -%% gbitstr_list([Elem], Defined, State) -> State. - -gbitstr_list(Es, Def, St0) -> - foldl(fun (E, St) -> gbitstr(E, Def, St) end, St0, Es). - -gbitstr(#c_bitstr{val=V,size=S,unit=U,type=T,flags=Fs}, Def, St0) -> - St1 = bit_type(U, T, Fs, St0), - gexpr_list([V,S], Def, St1). - -%% expr(Expr, Defined, RetCount, State) -> State. - -expr(#c_var{name=N}, Def, _Rt, St) -> expr_var(N, Def, St); -expr(#c_int{}, _Def, _Rt, St) -> St; -expr(#c_float{}, _Def, _Rt, St) -> St; -expr(#c_atom{}, _Def, _Rt, St) -> St; -expr(#c_char{}, _Def, _Rt, St) -> St; -expr(#c_string{}, _Def, _Rt, St) -> St; -expr(#c_nil{}, _Def, _Rt, St) -> St; -expr(#c_cons{hd=H,tl=T}, Def, _Rt, St) -> - expr_list([H,T], Def, St); -expr(#c_tuple{es=Es}, Def, _Rt, St) -> - expr_list(Es, Def, St); -expr(#c_binary{segments=Ss}, Def, _Rt, St) -> - bitstr_list(Ss, Def, St); -expr(#c_fname{id=I,arity=A}, Def, _Rt, St) -> - expr_fname({I,A}, Def, St); -expr(#c_fun{vars=Vs,body=B}, Def, Rt, St0) -> - {Vvs,St1} = variable_list(Vs, St0), - return_match(Rt, 1, body(B, union(Vvs, Def), any, St1)); -expr(#c_seq{arg=Arg,body=B}, Def, Rt, St0) -> - St1 = expr(Arg, Def, any, St0), %Ignore values - body(B, Def, Rt, St1); -expr(#c_let{vars=Vs,arg=Arg,body=B}, Def, Rt, St0) -> - St1 = body(Arg, Def, let_varcount(Vs), St0), %This is a body - {Lvs,St2} = variable_list(Vs, St1), - body(B, union(Lvs, Def), Rt, St2); -expr(#c_letrec{defs=Fs,body=B}, Def0, Rt, St0) -> - Def1 = union(defined_funcs(Fs), Def0), %All defined stuff - St1 = functions(Fs, Def1, St0), - body(B, Def1, Rt, St1#lint{func=St0#lint.func}); -expr(#c_case{arg=Arg,clauses=Cs}, Def, Rt, St0) -> - Pc = case_patcount(Cs), - St1 = body(Arg, Def, Pc, St0), - clauses(Cs, Def, Pc, Rt, St1); -expr(#c_receive{clauses=Cs,timeout=T,action=A}, Def, Rt, St0) -> - St1 = expr(T, Def, 1, St0), - St2 = body(A, Def, Rt, St1), - clauses(Cs, Def, 1, Rt, St2); -expr(#c_apply{op=Op,args=As}, Def, _Rt, St0) -> - St1 = apply_op(Op, Def, length(As), St0), - expr_list(As, Def, St1); -expr(#c_call{module=M,name=N,args=As}, Def, _Rt, St0) -> - St1 = expr(M, Def, 1, St0), - St2 = expr(N, Def, 1, St1), - expr_list(As, Def, St2); -expr(#c_primop{name=N,args=As}, Def, _Rt, St0) when record(N, c_atom) -> - expr_list(As, Def, St0); -expr(#c_catch{body=B}, Def, Rt, St) -> - return_match(Rt, 1, body(B, Def, 1, St)); -expr(#c_try{arg=A,vars=Vs,body=B,evars=Evs,handler=H}, Def, Rt, St0) -> - St1 = case length(Evs) of - 2 -> St0; - _ -> add_error({illegal_try,St0#lint.func}, St0) - end, - St2 = body(A, Def, let_varcount(Vs), St1), - {Ns,St3} = variable_list(Vs, St2), - St4 = body(B, union(Ns, Def), Rt, St3), - {Ens,St5} = variable_list(Evs, St4), - body(H, union(Ens, Def), Rt, St5); -expr(_, _, _, St) -> - %%io:fwrite("clint: ~p~n", [Other]), - add_error({illegal_expr,St#lint.func}, St). - -%% expr_list([Expr], Defined, State) -> State. - -expr_list(Es, Def, St0) -> - foldl(fun (E, St) -> expr(E, Def, 1, St) end, St0, Es). - -%% bitstr_list([Elem], Defined, State) -> State. - -bitstr_list(Es, Def, St0) -> - foldl(fun (E, St) -> bitstr(E, Def, St) end, St0, Es). - -bitstr(#c_bitstr{val=V,size=S,unit=U,type=T,flags=Fs}, Def, St0) -> - St1 = bit_type(U, T, Fs, St0), - expr_list([V,S], Def, St1). - -%% apply_op(Op, Defined, ArgCount, State) -> State. -%% A apply op is either an fname or an expression. - -apply_op(#c_fname{id=I,arity=A}, Def, Ac, St0) -> - St1 = expr_fname({I,A}, Def, St0), - arg_match(Ac, A, St1); -apply_op(E, Def, _, St) -> expr(E, Def, 1, St). %Hard to check - -%% expr_var(VarName, Defined, State) -> State. - -expr_var(N, Def, St) -> - case is_element(N, Def) of - true -> St; - false -> add_error({unbound_var,N,St#lint.func}, St) - end. - -%% expr_fname(Fname, Defined, State) -> State. - -expr_fname(Fname, Def, St) -> - case is_element(Fname, Def) of - true -> St; - false -> add_error({undefined_function,Fname,St#lint.func}, St) - end. - -%% let_varcount([Var]) -> int(). - -let_varcount([]) -> any; %Ignore values -let_varcount(Es) -> length(Es). - -%% case_patcount([Clause]) -> int(). - -case_patcount([#c_clause{pats=Ps}|_]) -> length(Ps). - -%% clauses([Clause], Defined, PatCount, RetCount, State) -> State. - -clauses(Cs, Def, Pc, Rt, St0) -> - foldl(fun (C, St) -> clause(C, Def, Pc, Rt, St) end, St0, Cs). - -%% clause(Clause, Defined, PatCount, RetCount, State) -> State. - -clause(#c_clause{pats=Ps,guard=G,body=B}, Def0, Pc, Rt, St0) -> - St1 = pattern_match(Pc, length(Ps), St0), - {Pvs,St2} = pattern_list(Ps, Def0, St1), - Def1 = union(Pvs, Def0), - St3 = guard(G, Def1, St2), - body(B, Def1, Rt, St3). - -%% variable(Var, [PatVar], State) -> {[VarName],State}. - -variable(#c_var{name=N}, Ps, St) -> - case is_element(N, Ps) of - true -> {[],add_error({duplicate_var,N,St#lint.func}, St)}; - false -> {[N],St} - end; -variable(_, Def, St) -> {Def,add_error({not_var,St#lint.func}, St)}. - -%% variable_list([Var], State) -> {[Var],State}. -%% variable_list([Var], [PatVar], State) -> {[Var],State}. - -variable_list(Vs, St) -> variable_list(Vs, [], St). - -variable_list(Vs, Ps, St) -> - foldl(fun (V, {Ps0,St0}) -> - {Vvs,St1} = variable(V, Ps0, St0), - {union(Vvs, Ps0),St1} - end, {Ps,St}, Vs). - -%% pattern(Pattern, Defined, State) -> {[PatVar],State}. -%% pattern(Pattern, Defined, [PatVar], State) -> {[PatVar],State}. -%% Patterns are complicated by sizes in binaries. These are pure -%% input variables which create no bindings. We, therefor, need to -%% carry around the original defined variables to get the correct -%% handling. - -%% pattern(P, Def, St) -> pattern(P, Def, [], St). - -pattern(#c_var{name=N}, Def, Ps, St) -> - pat_var(N, Def, Ps, St); -pattern(#c_int{}, _Def, Ps, St) -> {Ps,St}; -pattern(#c_float{}, _Def, Ps, St) -> {Ps,St}; -pattern(#c_atom{}, _Def, Ps, St) -> {Ps,St}; -pattern(#c_char{}, _Def, Ps, St) -> {Ps,St}; -pattern(#c_string{}, _Def, Ps, St) -> {Ps,St}; -pattern(#c_nil{}, _Def, Ps, St) -> {Ps,St}; -pattern(#c_cons{hd=H,tl=T}, Def, Ps, St) -> - pattern_list([H,T], Def, Ps, St); -pattern(#c_tuple{es=Es}, Def, Ps, St) -> - pattern_list(Es, Def, Ps, St); -pattern(#c_binary{segments=Ss}, Def, Ps, St) -> - pat_bin(Ss, Def, Ps, St); -pattern(#c_alias{var=V,pat=P}, Def, Ps, St0) -> - {Vvs,St1} = variable(V, Ps, St0), - pattern(P, Def, union(Vvs, Ps), St1); -pattern(_, _, Ps, St) -> {Ps,add_error({not_pattern,St#lint.func}, St)}. - -pat_var(N, _Def, Ps, St) -> - case is_element(N, Ps) of - true -> {Ps,add_error({duplicate_var,N,St#lint.func}, St)}; - false -> {add_element(N, Ps),St} - end. - -%% pat_bin_list([Elem], Defined, [PatVar], State) -> {[PatVar],State}. - -pat_bin(Es, Def, Ps0, St0) -> - foldl(fun (E, {Ps,St}) -> pat_segment(E, Def, Ps, St) end, {Ps0,St0}, Es). - -pat_segment(#c_bitstr{val=V,size=S,unit=U,type=T,flags=Fs}, Def, Ps, St0) -> - St1 = bit_type(U, T, Fs, St0), - St2 = pat_bit_expr(S, T, Def, St1), - pattern(V, Def, Ps, St2); -pat_segment(_, _, Ps, St) -> - {Ps,add_error({not_bs_pattern,St#lint.func}, St)}. - -%% pat_bit_expr(SizePat, Type, Defined, State) -> State. -%% Check the Size pattern, this is an input! Be a bit tough here. - -pat_bit_expr(#c_int{val=I}, _, _, St) when I >= 0 -> St; -pat_bit_expr(#c_var{name=N}, _, Def, St) -> - expr_var(N, Def, St); -pat_bit_expr(#c_atom{val=all}, binary, _Def, St) -> St; -pat_bit_expr(_, _, _, St) -> - add_error({illegal_expr,St#lint.func}, St). - -bit_type(Unit, Type, Flags, St) -> - U = core_lib:literal_value(Unit), - T = core_lib:literal_value(Type), - Fs = core_lib:literal_value(Flags), - case erl_bits:set_bit_type(default, [T,{unit,U}|Fs]) of - {ok,_,_} -> St; - {error,E} -> add_error({E,St#lint.func}, St) - end. - -%% pattern_list([Var], Defined, State) -> {[PatVar],State}. -%% pattern_list([Var], Defined, [PatVar], State) -> {[PatVar],State}. - -pattern_list(Pats, Def, St) -> pattern_list(Pats, Def, [], St). - -pattern_list(Pats, Def, Ps0, St0) -> - foldl(fun (P, {Ps,St}) -> pattern(P, Def, Ps, St) end, {Ps0,St0}, Pats). - -%% pattern_match(Required, Supplied, State) -> State. -%% Check that the required number of patterns match the supplied. - -pattern_match(N, N, St) -> St; -pattern_match(_Req, _Sup, St) -> - add_error({pattern_mismatch,St#lint.func}, St). - -%% return_match(Required, Supplied, State) -> State. -%% Check that the required number of return values match the supplied. - -return_match(any, _Sup, St) -> St; -return_match(_Req, unknown, St) -> St; -return_match(N, N, St) -> St; -return_match(_Req, _Sup, St) -> - add_error({return_mismatch,St#lint.func}, St). - -%% arg_match(Required, Supplied, State) -> State. - -arg_match(_Req, unknown, St) -> St; -arg_match(N, N, St) -> St; -arg_match(_Req, _Sup, St) -> - add_error({arg_mismatch,St#lint.func}, St). diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_parse.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_parse.erl deleted file mode 100644 index 942845bef7..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_parse.erl +++ /dev/null @@ -1,4911 +0,0 @@ --module(core_parse). --define(THIS_MODULE, core_parse). --export([parse/1, parse_and_scan/1, format_error/1]). - --export([abstract/1,abstract/2,normalise/1]). - -%% The following directive is needed for (significantly) faster compilation -%% of the generated .erl file by the HiPE compiler. Please do not remove. --compile([{hipe,[{regalloc,linear_scan}]}]). - --include("core_parse.hrl"). - -tok_val(T) -> element(3, T). -tok_line(T) -> element(2, T). - -abstract(T, _N) -> abstract(T). - -abstract(Term) -> core_lib:make_literal(Term). - -normalise(Core) -> core_lib:literal_value(Core). - -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: core_parse.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% The parser generator will insert appropriate declarations before this line.% - -parse(Tokens) -> - case catch yeccpars1(Tokens, false, 0, [], []) of - error -> - Errorline = - if Tokens == [] -> 0; true -> element(2, hd(Tokens)) end, - {error, - {Errorline, ?THIS_MODULE, "syntax error at or after this line."}}; - Other -> - Other - end. - -parse_and_scan({Mod, Fun, Args}) -> - case apply(Mod, Fun, Args) of - {eof, _} -> - {ok, eof}; - {error, Descriptor, _} -> - {error, Descriptor}; - {ok, Tokens, _} -> - yeccpars1(Tokens, {Mod, Fun, Args}, 0, [], []) - end. - -format_error(Message) -> - case io_lib:deep_char_list(Message) of - true -> - Message; - _ -> - io_lib:write(Message) - end. - -% To be used in grammar files to throw an error message to the parser toplevel. -% Doesn't have to be exported! -return_error(Line, Message) -> - throw({error, {Line, ?THIS_MODULE, Message}}). - - -% Don't change yeccpars1/6 too much, it is called recursively by yeccpars2/8! -yeccpars1([Token | Tokens], Tokenizer, State, States, Vstack) -> - yeccpars2(State, element(1, Token), States, Vstack, Token, Tokens, - Tokenizer); -yeccpars1([], {M, F, A}, State, States, Vstack) -> - case catch apply(M, F, A) of - {eof, Endline} -> - {error, {Endline, ?THIS_MODULE, "end_of_file"}}; - {error, Descriptor, _Endline} -> - {error, Descriptor}; - {'EXIT', Reason} -> - {error, {0, ?THIS_MODULE, Reason}}; - {ok, Tokens, _Endline} -> - case catch yeccpars1(Tokens, {M, F, A}, State, States, Vstack) of - error -> - Errorline = element(2, hd(Tokens)), - {error, {Errorline, ?THIS_MODULE, - "syntax error at or after this line."}}; - Other -> - Other - end - end; -yeccpars1([], false, State, States, Vstack) -> - yeccpars2(State, '$end', States, Vstack, {'$end', 999999}, [], false). - -% For internal use only. -yeccerror(Token) -> - {error, - {element(2, Token), ?THIS_MODULE, - ["syntax error before: ", yecctoken2string(Token)]}}. - -yecctoken2string({atom, _, A}) -> io_lib:write(A); -yecctoken2string({integer,_,N}) -> io_lib:write(N); -yecctoken2string({float,_,F}) -> io_lib:write(F); -yecctoken2string({char,_,C}) -> io_lib:write_char(C); -yecctoken2string({var,_,V}) -> io_lib:format('~s', [V]); -yecctoken2string({string,_,S}) -> io_lib:write_string(S); -yecctoken2string({reserved_symbol, _, A}) -> io_lib:format('~w', [A]); -yecctoken2string({_Cat, _, Val}) -> io_lib:format('~w', [Val]); - -yecctoken2string({'dot', _}) -> io_lib:format('~w', ['.']); -yecctoken2string({'$end', _}) -> - []; -yecctoken2string({Other, _}) when atom(Other) -> - io_lib:format('~w', [Other]); -yecctoken2string(Other) -> - io_lib:write(Other). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -yeccpars2(0, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 1, [0 | __Ss], [__T | __Stack]); -yeccpars2(0, 'module', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 2, [0 | __Ss], [__T | __Stack]); -yeccpars2(0, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(1, 'module', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 313, [1 | __Ss], [__T | __Stack]); -yeccpars2(1, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(2, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 4, [2 | __Ss], [__T | __Stack]); -yeccpars2(2, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(3, '$end', _, __Stack, _, _, _) -> - {ok, hd(__Stack)}; -yeccpars2(3, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(4, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 5, [4 | __Ss], [__T | __Stack]); -yeccpars2(4, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(5, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [5 | __Ss], [__T | __Stack]); -yeccpars2(5, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 306, [5 | __Ss], [__T | __Stack]); -yeccpars2(5, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(6, 'attributes', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 7, [6 | __Ss], [__T | __Stack]); -yeccpars2(6, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(7, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 276, [7 | __Ss], [__T | __Stack]); -yeccpars2(7, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(8, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 9, [8 | __Ss], [__T | __Stack]); -yeccpars2(8, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [8 | __Ss], [__T | __Stack]); -yeccpars2(8, __Cat, __Ss, __Stack, __T, __Ts, __Tzr) -> - __Val = [], - yeccpars2(13, __Cat, [8 | __Ss], [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(9, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [9 | __Ss], [__T | __Stack]); -yeccpars2(9, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(10, '=', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 20, [10 | __Ss], [__T | __Stack]); -yeccpars2(10, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(11, '/', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 18, [11 | __Ss], [__T | __Stack]); -yeccpars2(11, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(12, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 9, [12 | __Ss], [__T | __Stack]); -yeccpars2(12, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [12 | __Ss], [__T | __Stack]); -yeccpars2(12, __Cat, __Ss, __Stack, __T, __Ts, __Tzr) -> - __Val = [], - yeccpars2(17, __Cat, [12 | __Ss], [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(13, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(module_defs, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(14, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_function_name, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(15, 'end', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 16, [15 | __Ss], [__T | __Stack]); -yeccpars2(15, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(16, __Cat, __Ss, [__6,__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_module{name = #c_atom{val = tok_val(__2)}, exports = __3, attrs = __4, defs = __5}, - __Nss = lists:nthtail(5, __Ss), - yeccpars2(yeccgoto(module_definition, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(17, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__2], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(function_definitions, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(18, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 19, [18 | __Ss], [__T | __Stack]); -yeccpars2(18, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(19, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_fname{id = tok_val(__1), arity = tok_val(__3)}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(function_name, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(20, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [20 | __Ss], [__T | __Stack]); -yeccpars2(20, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 21, [20 | __Ss], [__T | __Stack]); -yeccpars2(20, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(21, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [21 | __Ss], [__T | __Stack]); -yeccpars2(21, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(22, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_def{name = __1, val = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(function_definition, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(23, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 25, [23 | __Ss], [__T | __Stack]); -yeccpars2(23, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(24, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_fun, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(25, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 27, [25 | __Ss], [__T | __Stack]); -yeccpars2(25, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [25 | __Ss], [__T | __Stack]); -yeccpars2(25, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [25 | __Ss], [__T | __Stack]); -yeccpars2(25, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(26, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [26 | __Ss], [__T | __Stack]); -yeccpars2(26, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(27, '->', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 265, [27 | __Ss], [__T | __Stack]); -yeccpars2(27, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(28, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 263, [28 | __Ss], [__T | __Stack]); -yeccpars2(28, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(anno_variables, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(29, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 32, [29 | __Ss], [__T | __Stack]); -yeccpars2(29, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(30, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_var{name = tok_val(__1)}, - yeccpars2(yeccgoto(variable, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(31, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_variable, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(32, '->', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 33, [32 | __Ss], [__T | __Stack]); -yeccpars2(32, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(33, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [33 | __Ss], [__T | __Stack]); -yeccpars2(33, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(34, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 247, [34 | __Ss], [__T | __Stack]); -yeccpars2(34, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(35, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [35 | __Ss], [__T | __Stack]); -yeccpars2(35, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(36, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 240, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [36 | __Ss], [__T | __Stack]); -yeccpars2(36, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(37, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 149, [37 | __Ss], [__T | __Stack]); -yeccpars2(37, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(38, __Cat, __Ss, [__6,__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_fun{vars = __3, body = __6}, - __Nss = lists:nthtail(5, __Ss), - yeccpars2(yeccgoto(fun_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(39, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(40, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [40 | __Ss], [__T | __Stack]); -yeccpars2(40, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(41, '/', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 18, [41 | __Ss], [__T | __Stack]); -yeccpars2(41, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_atom{val = tok_val(__1)}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(42, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(43, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(44, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [44 | __Ss], [__T | __Stack]); -yeccpars2(44, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(45, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(46, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [46 | __Ss], [__T | __Stack]); -yeccpars2(46, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(47, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(48, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [48 | __Ss], [__T | __Stack]); -yeccpars2(48, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(49, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(50, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_char{val = tok_val(__1)}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(51, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(52, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [52 | __Ss], [__T | __Stack]); -yeccpars2(52, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(53, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(54, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_float{val = tok_val(__1)}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(55, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(56, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(57, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_int{val = tok_val(__1)}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(58, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 83, [58 | __Ss], [__T | __Stack]); -yeccpars2(58, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [58 | __Ss], [__T | __Stack]); -yeccpars2(58, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [58 | __Ss], [__T | __Stack]); -yeccpars2(58, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(59, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(60, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 9, [60 | __Ss], [__T | __Stack]); -yeccpars2(60, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [60 | __Ss], [__T | __Stack]); -yeccpars2(60, __Cat, __Ss, __Stack, __T, __Ts, __Tzr) -> - __Val = [], - yeccpars2(210, __Cat, [60 | __Ss], [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(61, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(62, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_nil{}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(63, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 208, [63 | __Ss], [__T | __Stack]); -yeccpars2(63, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(64, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(65, 'after', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 99, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 97, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 96, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [65 | __Ss], [__T | __Stack]); -yeccpars2(65, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(66, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(67, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(68, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(69, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_string{val = tok_val(__1)}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(70, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [70 | __Ss], [__T | __Stack]); -yeccpars2(70, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(71, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(72, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(73, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(single_expression, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(74, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 77, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [74 | __Ss], [__T | __Stack]); -yeccpars2(74, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(75, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 79, [75 | __Ss], [__T | __Stack]); -yeccpars2(75, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(anno_expressions, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(76, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 78, [76 | __Ss], [__T | __Stack]); -yeccpars2(76, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(77, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_tuple{es = []}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(tuple, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(78, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_tuple{es = __2}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tuple, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(79, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [79 | __Ss], [__T | __Stack]); -yeccpars2(79, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(80, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(anno_expressions, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(81, 'of', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 82, [81 | __Ss], [__T | __Stack]); -yeccpars2(81, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(82, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 83, [82 | __Ss], [__T | __Stack]); -yeccpars2(82, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [82 | __Ss], [__T | __Stack]); -yeccpars2(82, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [82 | __Ss], [__T | __Stack]); -yeccpars2(82, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(83, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 92, [83 | __Ss], [__T | __Stack]); -yeccpars2(83, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [83 | __Ss], [__T | __Stack]); -yeccpars2(83, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [83 | __Ss], [__T | __Stack]); -yeccpars2(83, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(84, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(let_vars, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(85, '->', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 86, [85 | __Ss], [__T | __Stack]); -yeccpars2(85, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(86, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [86 | __Ss], [__T | __Stack]); -yeccpars2(86, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(87, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 88, [87 | __Ss], [__T | __Stack]); -yeccpars2(87, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(88, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 83, [88 | __Ss], [__T | __Stack]); -yeccpars2(88, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [88 | __Ss], [__T | __Stack]); -yeccpars2(88, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [88 | __Ss], [__T | __Stack]); -yeccpars2(88, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(89, '->', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 90, [89 | __Ss], [__T | __Stack]); -yeccpars2(89, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(90, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [90 | __Ss], [__T | __Stack]); -yeccpars2(90, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(91, __Cat, __Ss, [__10,__9,__8,__7,__6,__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = if length(__8) == 2 -> #c_try{arg = __2, vars = __4, body = __6, evars = __8, handler = __10}; true -> return_error(tok_line(__7),"expected 2 exception variables in 'try'") end, - __Nss = lists:nthtail(9, __Ss), - yeccpars2(yeccgoto(try_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(92, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(let_vars, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(93, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 94, [93 | __Ss], [__T | __Stack]); -yeccpars2(93, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(94, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(let_vars, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(95, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 190, [95 | __Ss], [__T | __Stack]); -yeccpars2(95, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(96, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 97, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [96 | __Ss], [__T | __Stack]); -yeccpars2(96, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(97, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 182, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [97 | __Ss], [__T | __Stack]); -yeccpars2(97, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(98, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 149, [98 | __Ss], [__T | __Stack]); -yeccpars2(98, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(99, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [99 | __Ss], [__T | __Stack]); -yeccpars2(99, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(100, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 97, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 96, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [100 | __Ss], [__T | __Stack]); -yeccpars2(100, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(anno_clauses, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(101, 'after', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 99, [101 | __Ss], [__T | __Stack]); -yeccpars2(101, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(102, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(clause_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(103, '=', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 162, [103 | __Ss], [__T | __Stack]); -yeccpars2(103, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(104, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_atom{val = tok_val(__1)}, - yeccpars2(yeccgoto(atomic_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(105, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(atomic_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(106, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(other_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(107, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(other_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(108, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_clause, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(109, 'when', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 164, [109 | __Ss], [__T | __Stack]); -yeccpars2(109, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(110, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(other_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(111, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(112, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = begin - {T,A} = __2, #c_receive{clauses = [], timeout = T, action = A} - end, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(receive_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(113, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(other_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(114, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 118, [114 | __Ss], [__T | __Stack]); -yeccpars2(114, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(115, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [115 | __Ss], [__T | __Stack]); -yeccpars2(115, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(116, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 120, [116 | __Ss], [__T | __Stack]); -yeccpars2(116, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(anno_patterns, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(117, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 119, [117 | __Ss], [__T | __Stack]); -yeccpars2(117, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(118, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_tuple{es = []}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(tuple_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(119, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_tuple{es = __2}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tuple_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(120, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [120 | __Ss], [__T | __Stack]); -yeccpars2(120, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(121, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(anno_patterns, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(122, '=', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 162, [122 | __Ss], [__T | __Stack]); -yeccpars2(122, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(123, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 159, [123 | __Ss], [__T | __Stack]); -yeccpars2(123, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(124, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 125, [124 | __Ss], [__T | __Stack]); -yeccpars2(124, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_variable, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(125, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [125 | __Ss], [__T | __Stack]); -yeccpars2(125, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(126, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 129, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 142, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 140, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 131, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 137, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 138, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 133, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 130, [126 | __Ss], [__T | __Stack]); -yeccpars2(126, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(127, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 128, [127 | __Ss], [__T | __Stack]); -yeccpars2(127, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(128, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = core_lib:set_anno(__2,__4), - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(anno_variable, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(129, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 129, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 142, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 140, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 131, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 137, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 138, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 133, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 149, [129 | __Ss], [__T | __Stack]); -yeccpars2(129, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(130, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(annotation, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(131, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = tok_val(__1), - yeccpars2(yeccgoto(atomic_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(132, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(133, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = tok_val(__1), - yeccpars2(yeccgoto(atomic_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(134, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(135, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 147, [135 | __Ss], [__T | __Stack]); -yeccpars2(135, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(constants, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(136, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 146, [136 | __Ss], [__T | __Stack]); -yeccpars2(136, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(137, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = tok_val(__1), - yeccpars2(yeccgoto(atomic_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(138, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = tok_val(__1), - yeccpars2(yeccgoto(atomic_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(139, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - yeccpars2(yeccgoto(atomic_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(140, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = tok_val(__1), - yeccpars2(yeccgoto(atomic_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(141, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(142, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 129, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 142, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 144, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 140, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 131, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 137, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 138, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 133, [142 | __Ss], [__T | __Stack]); -yeccpars2(142, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(143, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 145, [143 | __Ss], [__T | __Stack]); -yeccpars2(143, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(144, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = {}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(tuple_constant, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(145, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = list_to_tuple(__2), - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tuple_constant, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(146, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(annotation, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(147, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 129, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 142, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 140, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 131, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 137, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 138, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 133, [147 | __Ss], [__T | __Stack]); -yeccpars2(147, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(148, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(constants, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(149, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = {nil,tok_line(__1)}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(nil, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(150, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 151, [150 | __Ss], [__T | __Stack]); -yeccpars2(150, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 154, [150 | __Ss], [__T | __Stack]); -yeccpars2(150, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 152, [150 | __Ss], [__T | __Stack]); -yeccpars2(150, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(151, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 129, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 142, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 140, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 131, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 137, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 138, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 133, [151 | __Ss], [__T | __Stack]); -yeccpars2(151, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(152, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - yeccpars2(yeccgoto(tail_constant, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(153, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__2|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(cons_constant, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(154, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 129, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 142, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 140, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 131, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 137, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 138, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 133, [154 | __Ss], [__T | __Stack]); -yeccpars2(154, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(155, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 156, [155 | __Ss], [__T | __Stack]); -yeccpars2(155, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(156, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail_constant, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(157, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 151, [157 | __Ss], [__T | __Stack]); -yeccpars2(157, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 154, [157 | __Ss], [__T | __Stack]); -yeccpars2(157, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 152, [157 | __Ss], [__T | __Stack]); -yeccpars2(157, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(158, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__2|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail_constant, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(159, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [159 | __Ss], [__T | __Stack]); -yeccpars2(159, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(160, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 161, [160 | __Ss], [__T | __Stack]); -yeccpars2(160, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(161, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = core_lib:set_anno(__2,__4), - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(anno_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(162, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [162 | __Ss], [__T | __Stack]); -yeccpars2(162, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(163, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_alias{var = __1, pat = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(other_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(164, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [164 | __Ss], [__T | __Stack]); -yeccpars2(164, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(165, '->', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 166, [165 | __Ss], [__T | __Stack]); -yeccpars2(165, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(166, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [166 | __Ss], [__T | __Stack]); -yeccpars2(166, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(167, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_clause{pats = __1, guard = __3, body = __5}, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(clause, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(168, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = begin - {T,A} = __3, #c_receive{clauses = __2, timeout = T, action = A} - end, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(receive_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(169, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__2], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(anno_clauses, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(170, '->', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 171, [170 | __Ss], [__T | __Stack]); -yeccpars2(170, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(171, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [171 | __Ss], [__T | __Stack]); -yeccpars2(171, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(172, __Cat, __Ss, [__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = {__2,__4}, - __Nss = lists:nthtail(3, __Ss), - yeccpars2(yeccgoto(timeout, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(173, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 174, [173 | __Ss], [__T | __Stack]); -yeccpars2(173, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 177, [173 | __Ss], [__T | __Stack]); -yeccpars2(173, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 175, [173 | __Ss], [__T | __Stack]); -yeccpars2(173, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(174, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [174 | __Ss], [__T | __Stack]); -yeccpars2(174, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(175, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_nil{}, - yeccpars2(yeccgoto(tail_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(176, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_cons{hd = __2, tl = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(cons_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(177, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [177 | __Ss], [__T | __Stack]); -yeccpars2(177, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(178, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 179, [178 | __Ss], [__T | __Stack]); -yeccpars2(178, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(179, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(180, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 174, [180 | __Ss], [__T | __Stack]); -yeccpars2(180, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 177, [180 | __Ss], [__T | __Stack]); -yeccpars2(180, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 175, [180 | __Ss], [__T | __Stack]); -yeccpars2(180, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(181, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_cons{hd = __2, tl = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(182, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(clause_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(183, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 184, [183 | __Ss], [__T | __Stack]); -yeccpars2(183, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(184, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(clause_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(185, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 187, [185 | __Ss], [__T | __Stack]); -yeccpars2(185, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(186, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 159, [186 | __Ss], [__T | __Stack]); -yeccpars2(186, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(anno_pattern, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(187, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [187 | __Ss], [__T | __Stack]); -yeccpars2(187, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(188, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 189, [188 | __Ss], [__T | __Stack]); -yeccpars2(188, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(189, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = core_lib:set_anno(__2,__4), - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(anno_clause, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(190, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 191, [190 | __Ss], [__T | __Stack]); -yeccpars2(190, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 194, [190 | __Ss], [__T | __Stack]); -yeccpars2(190, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(191, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 200, [191 | __Ss], [__T | __Stack]); -yeccpars2(191, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(192, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 198, [192 | __Ss], [__T | __Stack]); -yeccpars2(192, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(segment_patterns, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(193, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 196, [193 | __Ss], [__T | __Stack]); -yeccpars2(193, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(194, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 195, [194 | __Ss], [__T | __Stack]); -yeccpars2(194, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(195, __Cat, __Ss, [__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_binary{segments = []}, - __Nss = lists:nthtail(3, __Ss), - yeccpars2(yeccgoto(binary_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(196, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 197, [196 | __Ss], [__T | __Stack]); -yeccpars2(196, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(197, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_binary{segments = __3}, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(binary_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(198, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 191, [198 | __Ss], [__T | __Stack]); -yeccpars2(198, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(199, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(segment_patterns, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(200, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 115, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [200 | __Ss], [__T | __Stack]); -yeccpars2(200, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(201, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 202, [201 | __Ss], [__T | __Stack]); -yeccpars2(201, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(202, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 203, [202 | __Ss], [__T | __Stack]); -yeccpars2(202, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(203, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 205, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [203 | __Ss], [__T | __Stack]); -yeccpars2(203, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(204, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = case __5 of [S,U,T,Fs] -> #c_bitstr{val = __3, size = S, unit = U, type = T, flags = Fs}; true -> return_error(tok_line(__1),"expected 4 arguments in binary segment") end, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(segment_pattern, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(205, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(arg_list, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(206, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 207, [206 | __Ss], [__T | __Stack]); -yeccpars2(206, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(207, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(arg_list, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(208, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 203, [208 | __Ss], [__T | __Stack]); -yeccpars2(208, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(209, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = begin - Name = #c_atom{val = tok_val(__2)}, #c_primop{name = Name, args = __3} - end, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(primop_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(210, 'in', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 211, [210 | __Ss], [__T | __Stack]); -yeccpars2(210, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(211, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [211 | __Ss], [__T | __Stack]); -yeccpars2(211, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(212, __Cat, __Ss, [__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_letrec{defs = __2, body = __4}, - __Nss = lists:nthtail(3, __Ss), - yeccpars2(yeccgoto(letrec_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(213, '=', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 214, [213 | __Ss], [__T | __Stack]); -yeccpars2(213, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(214, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [214 | __Ss], [__T | __Stack]); -yeccpars2(214, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(215, 'in', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 216, [215 | __Ss], [__T | __Stack]); -yeccpars2(215, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(216, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [216 | __Ss], [__T | __Stack]); -yeccpars2(216, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(217, __Cat, __Ss, [__6,__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_let{vars = __2, arg = __4, body = __6}, - __Nss = lists:nthtail(5, __Ss), - yeccpars2(yeccgoto(let_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(218, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [218 | __Ss], [__T | __Stack]); -yeccpars2(218, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(219, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_seq{arg = __2, body = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(sequence, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(220, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_catch{body = __2}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(catch_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(221, 'of', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 222, [221 | __Ss], [__T | __Stack]); -yeccpars2(221, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(222, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 97, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 96, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 95, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 98, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 114, [222 | __Ss], [__T | __Stack]); -yeccpars2(222, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(223, 'end', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 224, [223 | __Ss], [__T | __Stack]); -yeccpars2(223, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(224, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_case{arg = __2, clauses = __4}, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(case_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(225, ':', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 226, [225 | __Ss], [__T | __Stack]); -yeccpars2(225, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(226, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [226 | __Ss], [__T | __Stack]); -yeccpars2(226, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(227, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 203, [227 | __Ss], [__T | __Stack]); -yeccpars2(227, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(228, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_call{module = __2, name = __4, args = __5}, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(call_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(229, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 203, [229 | __Ss], [__T | __Stack]); -yeccpars2(229, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(230, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_apply{op = __2, args = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(application_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(231, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 232, [231 | __Ss], [__T | __Stack]); -yeccpars2(231, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 235, [231 | __Ss], [__T | __Stack]); -yeccpars2(231, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 233, [231 | __Ss], [__T | __Stack]); -yeccpars2(231, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(232, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [232 | __Ss], [__T | __Stack]); -yeccpars2(232, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(233, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_nil{}, - yeccpars2(yeccgoto(tail, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(234, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_cons{hd = __2, tl = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(cons, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(235, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [235 | __Ss], [__T | __Stack]); -yeccpars2(235, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(236, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 237, [236 | __Ss], [__T | __Stack]); -yeccpars2(236, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(237, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(238, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 232, [238 | __Ss], [__T | __Stack]); -yeccpars2(238, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 235, [238 | __Ss], [__T | __Stack]); -yeccpars2(238, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 233, [238 | __Ss], [__T | __Stack]); -yeccpars2(238, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(239, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_cons{hd = __2, tl = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(240, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_values{es = []}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(expression, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(241, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 242, [241 | __Ss], [__T | __Stack]); -yeccpars2(241, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(242, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_values{es = __2}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(expression, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(243, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 244, [243 | __Ss], [__T | __Stack]); -yeccpars2(243, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(244, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [244 | __Ss], [__T | __Stack]); -yeccpars2(244, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(245, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 246, [245 | __Ss], [__T | __Stack]); -yeccpars2(245, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(246, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = core_lib:set_anno(__2,__4), - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(anno_expression, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(247, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 248, [247 | __Ss], [__T | __Stack]); -yeccpars2(247, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 251, [247 | __Ss], [__T | __Stack]); -yeccpars2(247, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(248, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 257, [248 | __Ss], [__T | __Stack]); -yeccpars2(248, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(249, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 255, [249 | __Ss], [__T | __Stack]); -yeccpars2(249, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(segments, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(250, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 253, [250 | __Ss], [__T | __Stack]); -yeccpars2(250, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(251, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 252, [251 | __Ss], [__T | __Stack]); -yeccpars2(251, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(252, __Cat, __Ss, [__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_binary{segments = []}, - __Nss = lists:nthtail(3, __Ss), - yeccpars2(yeccgoto(binary, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(253, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 254, [253 | __Ss], [__T | __Stack]); -yeccpars2(253, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(254, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_binary{segments = __3}, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(binary, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(255, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 248, [255 | __Ss], [__T | __Stack]); -yeccpars2(255, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(256, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(segments, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(257, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [257 | __Ss], [__T | __Stack]); -yeccpars2(257, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(258, '>', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 259, [258 | __Ss], [__T | __Stack]); -yeccpars2(258, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(259, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 260, [259 | __Ss], [__T | __Stack]); -yeccpars2(259, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(260, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [260 | __Ss], [__T | __Stack]); -yeccpars2(260, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(261, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 262, [261 | __Ss], [__T | __Stack]); -yeccpars2(261, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(262, __Cat, __Ss, [__7,__6,__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = case __6 of [S,U,T,Fs] -> #c_bitstr{val = __3, size = S, unit = U, type = T, flags = Fs}; true -> return_error(tok_line(__1),"expected 4 arguments in binary segment") end, - __Nss = lists:nthtail(6, __Ss), - yeccpars2(yeccgoto(segment, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(263, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 26, [263 | __Ss], [__T | __Stack]); -yeccpars2(263, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [263 | __Ss], [__T | __Stack]); -yeccpars2(263, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(264, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(anno_variables, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(265, 'receive', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 65, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'catch', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 48, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'try', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 70, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'primop', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 63, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'call', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 44, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'apply', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 40, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'case', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 46, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'letrec', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 60, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'let', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 58, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'fun', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 23, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'do', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 52, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 41, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, '#', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 34, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 37, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 74, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, '<', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 36, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 35, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, 'var', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 30, [265 | __Ss], [__T | __Stack]); -yeccpars2(265, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(266, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_fun{vars = [], body = __5}, - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(fun_expr, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(267, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 125, [267 | __Ss], [__T | __Stack]); -yeccpars2(267, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(268, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 269, [268 | __Ss], [__T | __Stack]); -yeccpars2(268, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(269, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [269 | __Ss], [__T | __Stack]); -yeccpars2(269, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(270, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 271, [270 | __Ss], [__T | __Stack]); -yeccpars2(270, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(271, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = core_lib:set_anno(__2,__4), - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(anno_fun, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(272, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 273, [272 | __Ss], [__T | __Stack]); -yeccpars2(272, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(273, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [273 | __Ss], [__T | __Stack]); -yeccpars2(273, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(274, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 275, [274 | __Ss], [__T | __Stack]); -yeccpars2(274, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(275, __Cat, __Ss, [__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = core_lib:set_anno(__2,__4), - __Nss = lists:nthtail(4, __Ss), - yeccpars2(yeccgoto(anno_function_name, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(276, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 278, [276 | __Ss], [__T | __Stack]); -yeccpars2(276, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 277, [276 | __Ss], [__T | __Stack]); -yeccpars2(276, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(277, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(module_attribute, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(278, '=', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 284, [278 | __Ss], [__T | __Stack]); -yeccpars2(278, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(279, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 282, [279 | __Ss], [__T | __Stack]); -yeccpars2(279, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(attribute_list, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(280, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 281, [280 | __Ss], [__T | __Stack]); -yeccpars2(280, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(281, __Cat, __Ss, [__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __3, - __Nss = lists:nthtail(3, __Ss), - yeccpars2(yeccgoto(module_attribute, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(282, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 278, [282 | __Ss], [__T | __Stack]); -yeccpars2(282, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(283, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(attribute_list, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(284, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 285, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 290, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [284 | __Ss], [__T | __Stack]); -yeccpars2(284, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(285, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 285, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 290, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 149, [285 | __Ss], [__T | __Stack]); -yeccpars2(285, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(286, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(287, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(288, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_def{name = #c_atom{val = tok_val(__1)}, val = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(attribute, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(289, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(290, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 285, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 290, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 293, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [290 | __Ss], [__T | __Stack]); -yeccpars2(290, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(291, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 295, [291 | __Ss], [__T | __Stack]); -yeccpars2(291, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(literals, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(292, '}', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 294, [292 | __Ss], [__T | __Stack]); -yeccpars2(292, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(293, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_tuple{es = []}, - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(tuple_literal, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(294, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_tuple{es = __2}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tuple_literal, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(295, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 285, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 290, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [295 | __Ss], [__T | __Stack]); -yeccpars2(295, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(296, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(literals, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(297, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 298, [297 | __Ss], [__T | __Stack]); -yeccpars2(297, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 301, [297 | __Ss], [__T | __Stack]); -yeccpars2(297, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 299, [297 | __Ss], [__T | __Stack]); -yeccpars2(297, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(298, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 285, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 290, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [298 | __Ss], [__T | __Stack]); -yeccpars2(298, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(299, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_nil{}, - yeccpars2(yeccgoto(tail_literal, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(300, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_cons{hd = __2, tl = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(cons_literal, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(301, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 285, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, '{', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 290, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, 'string', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 69, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 104, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, 'float', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 54, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, 'integer', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 57, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, 'char', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 50, [301 | __Ss], [__T | __Stack]); -yeccpars2(301, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(302, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 303, [302 | __Ss], [__T | __Stack]); -yeccpars2(302, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(303, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail_literal, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(304, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 298, [304 | __Ss], [__T | __Stack]); -yeccpars2(304, '|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 301, [304 | __Ss], [__T | __Stack]); -yeccpars2(304, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 299, [304 | __Ss], [__T | __Stack]); -yeccpars2(304, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(305, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_cons{hd = __2, tl = __3}, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(tail_literal, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(306, __Cat, __Ss, [__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [], - __Nss = lists:nthtail(1, __Ss), - yeccpars2(yeccgoto(module_export, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(307, ',', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 311, [307 | __Ss], [__T | __Stack]); -yeccpars2(307, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1], - yeccpars2(yeccgoto(exported_names, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(308, ']', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 310, [308 | __Ss], [__T | __Stack]); -yeccpars2(308, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(309, __Cat, __Ss, [__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __1, - yeccpars2(yeccgoto(exported_name, hd(__Ss)), __Cat, __Ss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(310, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = __2, - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(module_export, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(311, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [311 | __Ss], [__T | __Stack]); -yeccpars2(311, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(312, __Cat, __Ss, [__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = [__1|__3], - __Nss = lists:nthtail(2, __Ss), - yeccpars2(yeccgoto(exported_names, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(313, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 314, [313 | __Ss], [__T | __Stack]); -yeccpars2(313, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(314, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 5, [314 | __Ss], [__T | __Stack]); -yeccpars2(314, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(315, 'attributes', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 7, [315 | __Ss], [__T | __Stack]); -yeccpars2(315, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(316, '(', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 9, [316 | __Ss], [__T | __Stack]); -yeccpars2(316, 'atom', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 11, [316 | __Ss], [__T | __Stack]); -yeccpars2(316, __Cat, __Ss, __Stack, __T, __Ts, __Tzr) -> - __Val = [], - yeccpars2(13, __Cat, [316 | __Ss], [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(317, 'end', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 318, [317 | __Ss], [__T | __Stack]); -yeccpars2(317, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(318, '-|', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 319, [318 | __Ss], [__T | __Stack]); -yeccpars2(318, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(319, '[', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 126, [319 | __Ss], [__T | __Stack]); -yeccpars2(319, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(320, ')', __Ss, __Stack, __T, __Ts, __Tzr) -> - yeccpars1(__Ts, __Tzr, 321, [320 | __Ss], [__T | __Stack]); -yeccpars2(320, _, _, _, __T, _, _) -> - yeccerror(__T); -yeccpars2(321, __Cat, __Ss, [__10,__9,__8,__7,__6,__5,__4,__3,__2,__1|__Stack], __T, __Ts, __Tzr) -> - __Val = #c_module{anno = __9, name = tok_val(__3), exports = __4, attrs = __5, defs = __6}, - __Nss = lists:nthtail(9, __Ss), - yeccpars2(yeccgoto(module_definition, hd(__Nss)), __Cat, __Nss, [__Val | __Stack], __T, __Ts, __Tzr); -yeccpars2(__Other, _, _, _, _, _, _) -> - exit({parser, __Other, missing_state_in_action_table}). - -yeccgoto(anno_clause, 65) -> - 100; -yeccgoto(anno_clause, 100) -> - 100; -yeccgoto(anno_clause, 222) -> - 100; -yeccgoto(anno_clauses, 65) -> - 101; -yeccgoto(anno_clauses, 100) -> - 169; -yeccgoto(anno_clauses, 222) -> - 223; -yeccgoto(anno_expression, 33) -> - 38; -yeccgoto(anno_expression, 36) -> - 75; -yeccgoto(anno_expression, 37) -> - 231; -yeccgoto(anno_expression, 40) -> - 229; -yeccgoto(anno_expression, 44) -> - 225; -yeccgoto(anno_expression, 46) -> - 221; -yeccgoto(anno_expression, 48) -> - 220; -yeccgoto(anno_expression, 52) -> - 218; -yeccgoto(anno_expression, 70) -> - 81; -yeccgoto(anno_expression, 74) -> - 75; -yeccgoto(anno_expression, 79) -> - 75; -yeccgoto(anno_expression, 86) -> - 87; -yeccgoto(anno_expression, 90) -> - 91; -yeccgoto(anno_expression, 99) -> - 170; -yeccgoto(anno_expression, 164) -> - 165; -yeccgoto(anno_expression, 166) -> - 167; -yeccgoto(anno_expression, 171) -> - 172; -yeccgoto(anno_expression, 203) -> - 75; -yeccgoto(anno_expression, 211) -> - 212; -yeccgoto(anno_expression, 214) -> - 215; -yeccgoto(anno_expression, 216) -> - 217; -yeccgoto(anno_expression, 218) -> - 219; -yeccgoto(anno_expression, 226) -> - 227; -yeccgoto(anno_expression, 232) -> - 238; -yeccgoto(anno_expression, 235) -> - 236; -yeccgoto(anno_expression, 257) -> - 258; -yeccgoto(anno_expression, 260) -> - 75; -yeccgoto(anno_expression, 265) -> - 266; -yeccgoto(anno_expressions, 36) -> - 241; -yeccgoto(anno_expressions, 74) -> - 76; -yeccgoto(anno_expressions, 79) -> - 80; -yeccgoto(anno_expressions, 203) -> - 206; -yeccgoto(anno_expressions, 260) -> - 261; -yeccgoto(anno_fun, 20) -> - 22; -yeccgoto(anno_function_name, 8) -> - 10; -yeccgoto(anno_function_name, 12) -> - 10; -yeccgoto(anno_function_name, 60) -> - 10; -yeccgoto(anno_function_name, 316) -> - 10; -yeccgoto(anno_pattern, 65) -> - 102; -yeccgoto(anno_pattern, 96) -> - 102; -yeccgoto(anno_pattern, 97) -> - 116; -yeccgoto(anno_pattern, 98) -> - 173; -yeccgoto(anno_pattern, 100) -> - 102; -yeccgoto(anno_pattern, 114) -> - 116; -yeccgoto(anno_pattern, 120) -> - 116; -yeccgoto(anno_pattern, 162) -> - 163; -yeccgoto(anno_pattern, 174) -> - 180; -yeccgoto(anno_pattern, 177) -> - 178; -yeccgoto(anno_pattern, 200) -> - 201; -yeccgoto(anno_pattern, 222) -> - 102; -yeccgoto(anno_patterns, 97) -> - 183; -yeccgoto(anno_patterns, 114) -> - 117; -yeccgoto(anno_patterns, 120) -> - 121; -yeccgoto(anno_variable, 25) -> - 28; -yeccgoto(anno_variable, 58) -> - 84; -yeccgoto(anno_variable, 65) -> - 103; -yeccgoto(anno_variable, 82) -> - 84; -yeccgoto(anno_variable, 83) -> - 28; -yeccgoto(anno_variable, 88) -> - 84; -yeccgoto(anno_variable, 96) -> - 103; -yeccgoto(anno_variable, 97) -> - 103; -yeccgoto(anno_variable, 98) -> - 103; -yeccgoto(anno_variable, 100) -> - 103; -yeccgoto(anno_variable, 114) -> - 103; -yeccgoto(anno_variable, 115) -> - 122; -yeccgoto(anno_variable, 120) -> - 103; -yeccgoto(anno_variable, 162) -> - 103; -yeccgoto(anno_variable, 174) -> - 103; -yeccgoto(anno_variable, 177) -> - 103; -yeccgoto(anno_variable, 200) -> - 103; -yeccgoto(anno_variable, 222) -> - 103; -yeccgoto(anno_variable, 263) -> - 28; -yeccgoto(anno_variables, 25) -> - 29; -yeccgoto(anno_variables, 83) -> - 93; -yeccgoto(anno_variables, 263) -> - 264; -yeccgoto(annotation, 125) -> - 127; -yeccgoto(annotation, 159) -> - 160; -yeccgoto(annotation, 187) -> - 188; -yeccgoto(annotation, 244) -> - 245; -yeccgoto(annotation, 269) -> - 270; -yeccgoto(annotation, 273) -> - 274; -yeccgoto(annotation, 319) -> - 320; -yeccgoto(application_expr, 33) -> - 39; -yeccgoto(application_expr, 35) -> - 39; -yeccgoto(application_expr, 36) -> - 39; -yeccgoto(application_expr, 37) -> - 39; -yeccgoto(application_expr, 40) -> - 39; -yeccgoto(application_expr, 44) -> - 39; -yeccgoto(application_expr, 46) -> - 39; -yeccgoto(application_expr, 48) -> - 39; -yeccgoto(application_expr, 52) -> - 39; -yeccgoto(application_expr, 70) -> - 39; -yeccgoto(application_expr, 74) -> - 39; -yeccgoto(application_expr, 79) -> - 39; -yeccgoto(application_expr, 86) -> - 39; -yeccgoto(application_expr, 90) -> - 39; -yeccgoto(application_expr, 99) -> - 39; -yeccgoto(application_expr, 164) -> - 39; -yeccgoto(application_expr, 166) -> - 39; -yeccgoto(application_expr, 171) -> - 39; -yeccgoto(application_expr, 203) -> - 39; -yeccgoto(application_expr, 211) -> - 39; -yeccgoto(application_expr, 214) -> - 39; -yeccgoto(application_expr, 216) -> - 39; -yeccgoto(application_expr, 218) -> - 39; -yeccgoto(application_expr, 226) -> - 39; -yeccgoto(application_expr, 232) -> - 39; -yeccgoto(application_expr, 235) -> - 39; -yeccgoto(application_expr, 257) -> - 39; -yeccgoto(application_expr, 260) -> - 39; -yeccgoto(application_expr, 265) -> - 39; -yeccgoto(arg_list, 202) -> - 204; -yeccgoto(arg_list, 208) -> - 209; -yeccgoto(arg_list, 227) -> - 228; -yeccgoto(arg_list, 229) -> - 230; -yeccgoto(atomic_constant, 126) -> - 132; -yeccgoto(atomic_constant, 129) -> - 132; -yeccgoto(atomic_constant, 142) -> - 132; -yeccgoto(atomic_constant, 147) -> - 132; -yeccgoto(atomic_constant, 151) -> - 132; -yeccgoto(atomic_constant, 154) -> - 132; -yeccgoto(atomic_literal, 33) -> - 42; -yeccgoto(atomic_literal, 35) -> - 42; -yeccgoto(atomic_literal, 36) -> - 42; -yeccgoto(atomic_literal, 37) -> - 42; -yeccgoto(atomic_literal, 40) -> - 42; -yeccgoto(atomic_literal, 44) -> - 42; -yeccgoto(atomic_literal, 46) -> - 42; -yeccgoto(atomic_literal, 48) -> - 42; -yeccgoto(atomic_literal, 52) -> - 42; -yeccgoto(atomic_literal, 65) -> - 105; -yeccgoto(atomic_literal, 70) -> - 42; -yeccgoto(atomic_literal, 74) -> - 42; -yeccgoto(atomic_literal, 79) -> - 42; -yeccgoto(atomic_literal, 86) -> - 42; -yeccgoto(atomic_literal, 90) -> - 42; -yeccgoto(atomic_literal, 96) -> - 105; -yeccgoto(atomic_literal, 97) -> - 105; -yeccgoto(atomic_literal, 98) -> - 105; -yeccgoto(atomic_literal, 99) -> - 42; -yeccgoto(atomic_literal, 100) -> - 105; -yeccgoto(atomic_literal, 114) -> - 105; -yeccgoto(atomic_literal, 115) -> - 105; -yeccgoto(atomic_literal, 120) -> - 105; -yeccgoto(atomic_literal, 162) -> - 105; -yeccgoto(atomic_literal, 164) -> - 42; -yeccgoto(atomic_literal, 166) -> - 42; -yeccgoto(atomic_literal, 171) -> - 42; -yeccgoto(atomic_literal, 174) -> - 105; -yeccgoto(atomic_literal, 177) -> - 105; -yeccgoto(atomic_literal, 200) -> - 105; -yeccgoto(atomic_literal, 203) -> - 42; -yeccgoto(atomic_literal, 211) -> - 42; -yeccgoto(atomic_literal, 214) -> - 42; -yeccgoto(atomic_literal, 216) -> - 42; -yeccgoto(atomic_literal, 218) -> - 42; -yeccgoto(atomic_literal, 222) -> - 105; -yeccgoto(atomic_literal, 226) -> - 42; -yeccgoto(atomic_literal, 232) -> - 42; -yeccgoto(atomic_literal, 235) -> - 42; -yeccgoto(atomic_literal, 257) -> - 42; -yeccgoto(atomic_literal, 260) -> - 42; -yeccgoto(atomic_literal, 265) -> - 42; -yeccgoto(atomic_literal, 284) -> - 286; -yeccgoto(atomic_literal, 285) -> - 286; -yeccgoto(atomic_literal, 290) -> - 286; -yeccgoto(atomic_literal, 295) -> - 286; -yeccgoto(atomic_literal, 298) -> - 286; -yeccgoto(atomic_literal, 301) -> - 286; -yeccgoto(atomic_pattern, 65) -> - 106; -yeccgoto(atomic_pattern, 96) -> - 106; -yeccgoto(atomic_pattern, 97) -> - 106; -yeccgoto(atomic_pattern, 98) -> - 106; -yeccgoto(atomic_pattern, 100) -> - 106; -yeccgoto(atomic_pattern, 114) -> - 106; -yeccgoto(atomic_pattern, 115) -> - 106; -yeccgoto(atomic_pattern, 120) -> - 106; -yeccgoto(atomic_pattern, 162) -> - 106; -yeccgoto(atomic_pattern, 174) -> - 106; -yeccgoto(atomic_pattern, 177) -> - 106; -yeccgoto(atomic_pattern, 200) -> - 106; -yeccgoto(atomic_pattern, 222) -> - 106; -yeccgoto(attribute, 276) -> - 279; -yeccgoto(attribute, 282) -> - 279; -yeccgoto(attribute_list, 276) -> - 280; -yeccgoto(attribute_list, 282) -> - 283; -yeccgoto(binary, 33) -> - 43; -yeccgoto(binary, 35) -> - 43; -yeccgoto(binary, 36) -> - 43; -yeccgoto(binary, 37) -> - 43; -yeccgoto(binary, 40) -> - 43; -yeccgoto(binary, 44) -> - 43; -yeccgoto(binary, 46) -> - 43; -yeccgoto(binary, 48) -> - 43; -yeccgoto(binary, 52) -> - 43; -yeccgoto(binary, 70) -> - 43; -yeccgoto(binary, 74) -> - 43; -yeccgoto(binary, 79) -> - 43; -yeccgoto(binary, 86) -> - 43; -yeccgoto(binary, 90) -> - 43; -yeccgoto(binary, 99) -> - 43; -yeccgoto(binary, 164) -> - 43; -yeccgoto(binary, 166) -> - 43; -yeccgoto(binary, 171) -> - 43; -yeccgoto(binary, 203) -> - 43; -yeccgoto(binary, 211) -> - 43; -yeccgoto(binary, 214) -> - 43; -yeccgoto(binary, 216) -> - 43; -yeccgoto(binary, 218) -> - 43; -yeccgoto(binary, 226) -> - 43; -yeccgoto(binary, 232) -> - 43; -yeccgoto(binary, 235) -> - 43; -yeccgoto(binary, 257) -> - 43; -yeccgoto(binary, 260) -> - 43; -yeccgoto(binary, 265) -> - 43; -yeccgoto(binary_pattern, 65) -> - 107; -yeccgoto(binary_pattern, 96) -> - 107; -yeccgoto(binary_pattern, 97) -> - 107; -yeccgoto(binary_pattern, 98) -> - 107; -yeccgoto(binary_pattern, 100) -> - 107; -yeccgoto(binary_pattern, 114) -> - 107; -yeccgoto(binary_pattern, 115) -> - 107; -yeccgoto(binary_pattern, 120) -> - 107; -yeccgoto(binary_pattern, 162) -> - 107; -yeccgoto(binary_pattern, 174) -> - 107; -yeccgoto(binary_pattern, 177) -> - 107; -yeccgoto(binary_pattern, 200) -> - 107; -yeccgoto(binary_pattern, 222) -> - 107; -yeccgoto(call_expr, 33) -> - 45; -yeccgoto(call_expr, 35) -> - 45; -yeccgoto(call_expr, 36) -> - 45; -yeccgoto(call_expr, 37) -> - 45; -yeccgoto(call_expr, 40) -> - 45; -yeccgoto(call_expr, 44) -> - 45; -yeccgoto(call_expr, 46) -> - 45; -yeccgoto(call_expr, 48) -> - 45; -yeccgoto(call_expr, 52) -> - 45; -yeccgoto(call_expr, 70) -> - 45; -yeccgoto(call_expr, 74) -> - 45; -yeccgoto(call_expr, 79) -> - 45; -yeccgoto(call_expr, 86) -> - 45; -yeccgoto(call_expr, 90) -> - 45; -yeccgoto(call_expr, 99) -> - 45; -yeccgoto(call_expr, 164) -> - 45; -yeccgoto(call_expr, 166) -> - 45; -yeccgoto(call_expr, 171) -> - 45; -yeccgoto(call_expr, 203) -> - 45; -yeccgoto(call_expr, 211) -> - 45; -yeccgoto(call_expr, 214) -> - 45; -yeccgoto(call_expr, 216) -> - 45; -yeccgoto(call_expr, 218) -> - 45; -yeccgoto(call_expr, 226) -> - 45; -yeccgoto(call_expr, 232) -> - 45; -yeccgoto(call_expr, 235) -> - 45; -yeccgoto(call_expr, 257) -> - 45; -yeccgoto(call_expr, 260) -> - 45; -yeccgoto(call_expr, 265) -> - 45; -yeccgoto(case_expr, 33) -> - 47; -yeccgoto(case_expr, 35) -> - 47; -yeccgoto(case_expr, 36) -> - 47; -yeccgoto(case_expr, 37) -> - 47; -yeccgoto(case_expr, 40) -> - 47; -yeccgoto(case_expr, 44) -> - 47; -yeccgoto(case_expr, 46) -> - 47; -yeccgoto(case_expr, 48) -> - 47; -yeccgoto(case_expr, 52) -> - 47; -yeccgoto(case_expr, 70) -> - 47; -yeccgoto(case_expr, 74) -> - 47; -yeccgoto(case_expr, 79) -> - 47; -yeccgoto(case_expr, 86) -> - 47; -yeccgoto(case_expr, 90) -> - 47; -yeccgoto(case_expr, 99) -> - 47; -yeccgoto(case_expr, 164) -> - 47; -yeccgoto(case_expr, 166) -> - 47; -yeccgoto(case_expr, 171) -> - 47; -yeccgoto(case_expr, 203) -> - 47; -yeccgoto(case_expr, 211) -> - 47; -yeccgoto(case_expr, 214) -> - 47; -yeccgoto(case_expr, 216) -> - 47; -yeccgoto(case_expr, 218) -> - 47; -yeccgoto(case_expr, 226) -> - 47; -yeccgoto(case_expr, 232) -> - 47; -yeccgoto(case_expr, 235) -> - 47; -yeccgoto(case_expr, 257) -> - 47; -yeccgoto(case_expr, 260) -> - 47; -yeccgoto(case_expr, 265) -> - 47; -yeccgoto(catch_expr, 33) -> - 49; -yeccgoto(catch_expr, 35) -> - 49; -yeccgoto(catch_expr, 36) -> - 49; -yeccgoto(catch_expr, 37) -> - 49; -yeccgoto(catch_expr, 40) -> - 49; -yeccgoto(catch_expr, 44) -> - 49; -yeccgoto(catch_expr, 46) -> - 49; -yeccgoto(catch_expr, 48) -> - 49; -yeccgoto(catch_expr, 52) -> - 49; -yeccgoto(catch_expr, 70) -> - 49; -yeccgoto(catch_expr, 74) -> - 49; -yeccgoto(catch_expr, 79) -> - 49; -yeccgoto(catch_expr, 86) -> - 49; -yeccgoto(catch_expr, 90) -> - 49; -yeccgoto(catch_expr, 99) -> - 49; -yeccgoto(catch_expr, 164) -> - 49; -yeccgoto(catch_expr, 166) -> - 49; -yeccgoto(catch_expr, 171) -> - 49; -yeccgoto(catch_expr, 203) -> - 49; -yeccgoto(catch_expr, 211) -> - 49; -yeccgoto(catch_expr, 214) -> - 49; -yeccgoto(catch_expr, 216) -> - 49; -yeccgoto(catch_expr, 218) -> - 49; -yeccgoto(catch_expr, 226) -> - 49; -yeccgoto(catch_expr, 232) -> - 49; -yeccgoto(catch_expr, 235) -> - 49; -yeccgoto(catch_expr, 257) -> - 49; -yeccgoto(catch_expr, 260) -> - 49; -yeccgoto(catch_expr, 265) -> - 49; -yeccgoto(clause, 65) -> - 108; -yeccgoto(clause, 96) -> - 185; -yeccgoto(clause, 100) -> - 108; -yeccgoto(clause, 222) -> - 108; -yeccgoto(clause_pattern, 65) -> - 109; -yeccgoto(clause_pattern, 96) -> - 109; -yeccgoto(clause_pattern, 100) -> - 109; -yeccgoto(clause_pattern, 222) -> - 109; -yeccgoto(cons, 33) -> - 51; -yeccgoto(cons, 35) -> - 51; -yeccgoto(cons, 36) -> - 51; -yeccgoto(cons, 37) -> - 51; -yeccgoto(cons, 40) -> - 51; -yeccgoto(cons, 44) -> - 51; -yeccgoto(cons, 46) -> - 51; -yeccgoto(cons, 48) -> - 51; -yeccgoto(cons, 52) -> - 51; -yeccgoto(cons, 70) -> - 51; -yeccgoto(cons, 74) -> - 51; -yeccgoto(cons, 79) -> - 51; -yeccgoto(cons, 86) -> - 51; -yeccgoto(cons, 90) -> - 51; -yeccgoto(cons, 99) -> - 51; -yeccgoto(cons, 164) -> - 51; -yeccgoto(cons, 166) -> - 51; -yeccgoto(cons, 171) -> - 51; -yeccgoto(cons, 203) -> - 51; -yeccgoto(cons, 211) -> - 51; -yeccgoto(cons, 214) -> - 51; -yeccgoto(cons, 216) -> - 51; -yeccgoto(cons, 218) -> - 51; -yeccgoto(cons, 226) -> - 51; -yeccgoto(cons, 232) -> - 51; -yeccgoto(cons, 235) -> - 51; -yeccgoto(cons, 257) -> - 51; -yeccgoto(cons, 260) -> - 51; -yeccgoto(cons, 265) -> - 51; -yeccgoto(cons_constant, 126) -> - 134; -yeccgoto(cons_constant, 129) -> - 134; -yeccgoto(cons_constant, 142) -> - 134; -yeccgoto(cons_constant, 147) -> - 134; -yeccgoto(cons_constant, 151) -> - 134; -yeccgoto(cons_constant, 154) -> - 134; -yeccgoto(cons_literal, 284) -> - 287; -yeccgoto(cons_literal, 285) -> - 287; -yeccgoto(cons_literal, 290) -> - 287; -yeccgoto(cons_literal, 295) -> - 287; -yeccgoto(cons_literal, 298) -> - 287; -yeccgoto(cons_literal, 301) -> - 287; -yeccgoto(cons_pattern, 65) -> - 110; -yeccgoto(cons_pattern, 96) -> - 110; -yeccgoto(cons_pattern, 97) -> - 110; -yeccgoto(cons_pattern, 98) -> - 110; -yeccgoto(cons_pattern, 100) -> - 110; -yeccgoto(cons_pattern, 114) -> - 110; -yeccgoto(cons_pattern, 115) -> - 110; -yeccgoto(cons_pattern, 120) -> - 110; -yeccgoto(cons_pattern, 162) -> - 110; -yeccgoto(cons_pattern, 174) -> - 110; -yeccgoto(cons_pattern, 177) -> - 110; -yeccgoto(cons_pattern, 200) -> - 110; -yeccgoto(cons_pattern, 222) -> - 110; -yeccgoto(constant, 126) -> - 135; -yeccgoto(constant, 129) -> - 150; -yeccgoto(constant, 142) -> - 135; -yeccgoto(constant, 147) -> - 135; -yeccgoto(constant, 151) -> - 157; -yeccgoto(constant, 154) -> - 155; -yeccgoto(constants, 126) -> - 136; -yeccgoto(constants, 142) -> - 143; -yeccgoto(constants, 147) -> - 148; -yeccgoto(exported_name, 5) -> - 307; -yeccgoto(exported_name, 311) -> - 307; -yeccgoto(exported_names, 5) -> - 308; -yeccgoto(exported_names, 311) -> - 312; -yeccgoto(expression, 33) -> - 53; -yeccgoto(expression, 35) -> - 243; -yeccgoto(expression, 36) -> - 53; -yeccgoto(expression, 37) -> - 53; -yeccgoto(expression, 40) -> - 53; -yeccgoto(expression, 44) -> - 53; -yeccgoto(expression, 46) -> - 53; -yeccgoto(expression, 48) -> - 53; -yeccgoto(expression, 52) -> - 53; -yeccgoto(expression, 70) -> - 53; -yeccgoto(expression, 74) -> - 53; -yeccgoto(expression, 79) -> - 53; -yeccgoto(expression, 86) -> - 53; -yeccgoto(expression, 90) -> - 53; -yeccgoto(expression, 99) -> - 53; -yeccgoto(expression, 164) -> - 53; -yeccgoto(expression, 166) -> - 53; -yeccgoto(expression, 171) -> - 53; -yeccgoto(expression, 203) -> - 53; -yeccgoto(expression, 211) -> - 53; -yeccgoto(expression, 214) -> - 53; -yeccgoto(expression, 216) -> - 53; -yeccgoto(expression, 218) -> - 53; -yeccgoto(expression, 226) -> - 53; -yeccgoto(expression, 232) -> - 53; -yeccgoto(expression, 235) -> - 53; -yeccgoto(expression, 257) -> - 53; -yeccgoto(expression, 260) -> - 53; -yeccgoto(expression, 265) -> - 53; -yeccgoto(fun_expr, 20) -> - 24; -yeccgoto(fun_expr, 21) -> - 268; -yeccgoto(fun_expr, 33) -> - 55; -yeccgoto(fun_expr, 35) -> - 55; -yeccgoto(fun_expr, 36) -> - 55; -yeccgoto(fun_expr, 37) -> - 55; -yeccgoto(fun_expr, 40) -> - 55; -yeccgoto(fun_expr, 44) -> - 55; -yeccgoto(fun_expr, 46) -> - 55; -yeccgoto(fun_expr, 48) -> - 55; -yeccgoto(fun_expr, 52) -> - 55; -yeccgoto(fun_expr, 70) -> - 55; -yeccgoto(fun_expr, 74) -> - 55; -yeccgoto(fun_expr, 79) -> - 55; -yeccgoto(fun_expr, 86) -> - 55; -yeccgoto(fun_expr, 90) -> - 55; -yeccgoto(fun_expr, 99) -> - 55; -yeccgoto(fun_expr, 164) -> - 55; -yeccgoto(fun_expr, 166) -> - 55; -yeccgoto(fun_expr, 171) -> - 55; -yeccgoto(fun_expr, 203) -> - 55; -yeccgoto(fun_expr, 211) -> - 55; -yeccgoto(fun_expr, 214) -> - 55; -yeccgoto(fun_expr, 216) -> - 55; -yeccgoto(fun_expr, 218) -> - 55; -yeccgoto(fun_expr, 226) -> - 55; -yeccgoto(fun_expr, 232) -> - 55; -yeccgoto(fun_expr, 235) -> - 55; -yeccgoto(fun_expr, 257) -> - 55; -yeccgoto(fun_expr, 260) -> - 55; -yeccgoto(fun_expr, 265) -> - 55; -yeccgoto(function_definition, 8) -> - 12; -yeccgoto(function_definition, 12) -> - 12; -yeccgoto(function_definition, 60) -> - 12; -yeccgoto(function_definition, 316) -> - 12; -yeccgoto(function_definitions, 8) -> - 13; -yeccgoto(function_definitions, 12) -> - 17; -yeccgoto(function_definitions, 60) -> - 210; -yeccgoto(function_definitions, 316) -> - 13; -yeccgoto(function_name, 5) -> - 309; -yeccgoto(function_name, 8) -> - 14; -yeccgoto(function_name, 9) -> - 272; -yeccgoto(function_name, 12) -> - 14; -yeccgoto(function_name, 33) -> - 56; -yeccgoto(function_name, 35) -> - 56; -yeccgoto(function_name, 36) -> - 56; -yeccgoto(function_name, 37) -> - 56; -yeccgoto(function_name, 40) -> - 56; -yeccgoto(function_name, 44) -> - 56; -yeccgoto(function_name, 46) -> - 56; -yeccgoto(function_name, 48) -> - 56; -yeccgoto(function_name, 52) -> - 56; -yeccgoto(function_name, 60) -> - 14; -yeccgoto(function_name, 70) -> - 56; -yeccgoto(function_name, 74) -> - 56; -yeccgoto(function_name, 79) -> - 56; -yeccgoto(function_name, 86) -> - 56; -yeccgoto(function_name, 90) -> - 56; -yeccgoto(function_name, 99) -> - 56; -yeccgoto(function_name, 164) -> - 56; -yeccgoto(function_name, 166) -> - 56; -yeccgoto(function_name, 171) -> - 56; -yeccgoto(function_name, 203) -> - 56; -yeccgoto(function_name, 211) -> - 56; -yeccgoto(function_name, 214) -> - 56; -yeccgoto(function_name, 216) -> - 56; -yeccgoto(function_name, 218) -> - 56; -yeccgoto(function_name, 226) -> - 56; -yeccgoto(function_name, 232) -> - 56; -yeccgoto(function_name, 235) -> - 56; -yeccgoto(function_name, 257) -> - 56; -yeccgoto(function_name, 260) -> - 56; -yeccgoto(function_name, 265) -> - 56; -yeccgoto(function_name, 311) -> - 309; -yeccgoto(function_name, 316) -> - 14; -yeccgoto(let_expr, 33) -> - 59; -yeccgoto(let_expr, 35) -> - 59; -yeccgoto(let_expr, 36) -> - 59; -yeccgoto(let_expr, 37) -> - 59; -yeccgoto(let_expr, 40) -> - 59; -yeccgoto(let_expr, 44) -> - 59; -yeccgoto(let_expr, 46) -> - 59; -yeccgoto(let_expr, 48) -> - 59; -yeccgoto(let_expr, 52) -> - 59; -yeccgoto(let_expr, 70) -> - 59; -yeccgoto(let_expr, 74) -> - 59; -yeccgoto(let_expr, 79) -> - 59; -yeccgoto(let_expr, 86) -> - 59; -yeccgoto(let_expr, 90) -> - 59; -yeccgoto(let_expr, 99) -> - 59; -yeccgoto(let_expr, 164) -> - 59; -yeccgoto(let_expr, 166) -> - 59; -yeccgoto(let_expr, 171) -> - 59; -yeccgoto(let_expr, 203) -> - 59; -yeccgoto(let_expr, 211) -> - 59; -yeccgoto(let_expr, 214) -> - 59; -yeccgoto(let_expr, 216) -> - 59; -yeccgoto(let_expr, 218) -> - 59; -yeccgoto(let_expr, 226) -> - 59; -yeccgoto(let_expr, 232) -> - 59; -yeccgoto(let_expr, 235) -> - 59; -yeccgoto(let_expr, 257) -> - 59; -yeccgoto(let_expr, 260) -> - 59; -yeccgoto(let_expr, 265) -> - 59; -yeccgoto(let_vars, 58) -> - 213; -yeccgoto(let_vars, 82) -> - 85; -yeccgoto(let_vars, 88) -> - 89; -yeccgoto(letrec_expr, 33) -> - 61; -yeccgoto(letrec_expr, 35) -> - 61; -yeccgoto(letrec_expr, 36) -> - 61; -yeccgoto(letrec_expr, 37) -> - 61; -yeccgoto(letrec_expr, 40) -> - 61; -yeccgoto(letrec_expr, 44) -> - 61; -yeccgoto(letrec_expr, 46) -> - 61; -yeccgoto(letrec_expr, 48) -> - 61; -yeccgoto(letrec_expr, 52) -> - 61; -yeccgoto(letrec_expr, 70) -> - 61; -yeccgoto(letrec_expr, 74) -> - 61; -yeccgoto(letrec_expr, 79) -> - 61; -yeccgoto(letrec_expr, 86) -> - 61; -yeccgoto(letrec_expr, 90) -> - 61; -yeccgoto(letrec_expr, 99) -> - 61; -yeccgoto(letrec_expr, 164) -> - 61; -yeccgoto(letrec_expr, 166) -> - 61; -yeccgoto(letrec_expr, 171) -> - 61; -yeccgoto(letrec_expr, 203) -> - 61; -yeccgoto(letrec_expr, 211) -> - 61; -yeccgoto(letrec_expr, 214) -> - 61; -yeccgoto(letrec_expr, 216) -> - 61; -yeccgoto(letrec_expr, 218) -> - 61; -yeccgoto(letrec_expr, 226) -> - 61; -yeccgoto(letrec_expr, 232) -> - 61; -yeccgoto(letrec_expr, 235) -> - 61; -yeccgoto(letrec_expr, 257) -> - 61; -yeccgoto(letrec_expr, 260) -> - 61; -yeccgoto(letrec_expr, 265) -> - 61; -yeccgoto(literal, 284) -> - 288; -yeccgoto(literal, 285) -> - 297; -yeccgoto(literal, 290) -> - 291; -yeccgoto(literal, 295) -> - 291; -yeccgoto(literal, 298) -> - 304; -yeccgoto(literal, 301) -> - 302; -yeccgoto(literals, 290) -> - 292; -yeccgoto(literals, 295) -> - 296; -yeccgoto(module_attribute, 6) -> - 8; -yeccgoto(module_attribute, 315) -> - 316; -yeccgoto(module_definition, 0) -> - 3; -yeccgoto(module_defs, 8) -> - 15; -yeccgoto(module_defs, 316) -> - 317; -yeccgoto(module_export, 4) -> - 6; -yeccgoto(module_export, 314) -> - 315; -yeccgoto(nil, 33) -> - 62; -yeccgoto(nil, 35) -> - 62; -yeccgoto(nil, 36) -> - 62; -yeccgoto(nil, 37) -> - 62; -yeccgoto(nil, 40) -> - 62; -yeccgoto(nil, 44) -> - 62; -yeccgoto(nil, 46) -> - 62; -yeccgoto(nil, 48) -> - 62; -yeccgoto(nil, 52) -> - 62; -yeccgoto(nil, 65) -> - 62; -yeccgoto(nil, 70) -> - 62; -yeccgoto(nil, 74) -> - 62; -yeccgoto(nil, 79) -> - 62; -yeccgoto(nil, 86) -> - 62; -yeccgoto(nil, 90) -> - 62; -yeccgoto(nil, 96) -> - 62; -yeccgoto(nil, 97) -> - 62; -yeccgoto(nil, 98) -> - 62; -yeccgoto(nil, 99) -> - 62; -yeccgoto(nil, 100) -> - 62; -yeccgoto(nil, 114) -> - 62; -yeccgoto(nil, 115) -> - 62; -yeccgoto(nil, 120) -> - 62; -yeccgoto(nil, 126) -> - 139; -yeccgoto(nil, 129) -> - 139; -yeccgoto(nil, 142) -> - 139; -yeccgoto(nil, 147) -> - 139; -yeccgoto(nil, 151) -> - 139; -yeccgoto(nil, 154) -> - 139; -yeccgoto(nil, 162) -> - 62; -yeccgoto(nil, 164) -> - 62; -yeccgoto(nil, 166) -> - 62; -yeccgoto(nil, 171) -> - 62; -yeccgoto(nil, 174) -> - 62; -yeccgoto(nil, 177) -> - 62; -yeccgoto(nil, 200) -> - 62; -yeccgoto(nil, 203) -> - 62; -yeccgoto(nil, 211) -> - 62; -yeccgoto(nil, 214) -> - 62; -yeccgoto(nil, 216) -> - 62; -yeccgoto(nil, 218) -> - 62; -yeccgoto(nil, 222) -> - 62; -yeccgoto(nil, 226) -> - 62; -yeccgoto(nil, 232) -> - 62; -yeccgoto(nil, 235) -> - 62; -yeccgoto(nil, 257) -> - 62; -yeccgoto(nil, 260) -> - 62; -yeccgoto(nil, 265) -> - 62; -yeccgoto(nil, 284) -> - 62; -yeccgoto(nil, 285) -> - 62; -yeccgoto(nil, 290) -> - 62; -yeccgoto(nil, 295) -> - 62; -yeccgoto(nil, 298) -> - 62; -yeccgoto(nil, 301) -> - 62; -yeccgoto(other_pattern, 65) -> - 111; -yeccgoto(other_pattern, 96) -> - 186; -yeccgoto(other_pattern, 97) -> - 111; -yeccgoto(other_pattern, 98) -> - 111; -yeccgoto(other_pattern, 100) -> - 111; -yeccgoto(other_pattern, 114) -> - 111; -yeccgoto(other_pattern, 115) -> - 123; -yeccgoto(other_pattern, 120) -> - 111; -yeccgoto(other_pattern, 162) -> - 111; -yeccgoto(other_pattern, 174) -> - 111; -yeccgoto(other_pattern, 177) -> - 111; -yeccgoto(other_pattern, 200) -> - 111; -yeccgoto(other_pattern, 222) -> - 111; -yeccgoto(primop_expr, 33) -> - 64; -yeccgoto(primop_expr, 35) -> - 64; -yeccgoto(primop_expr, 36) -> - 64; -yeccgoto(primop_expr, 37) -> - 64; -yeccgoto(primop_expr, 40) -> - 64; -yeccgoto(primop_expr, 44) -> - 64; -yeccgoto(primop_expr, 46) -> - 64; -yeccgoto(primop_expr, 48) -> - 64; -yeccgoto(primop_expr, 52) -> - 64; -yeccgoto(primop_expr, 70) -> - 64; -yeccgoto(primop_expr, 74) -> - 64; -yeccgoto(primop_expr, 79) -> - 64; -yeccgoto(primop_expr, 86) -> - 64; -yeccgoto(primop_expr, 90) -> - 64; -yeccgoto(primop_expr, 99) -> - 64; -yeccgoto(primop_expr, 164) -> - 64; -yeccgoto(primop_expr, 166) -> - 64; -yeccgoto(primop_expr, 171) -> - 64; -yeccgoto(primop_expr, 203) -> - 64; -yeccgoto(primop_expr, 211) -> - 64; -yeccgoto(primop_expr, 214) -> - 64; -yeccgoto(primop_expr, 216) -> - 64; -yeccgoto(primop_expr, 218) -> - 64; -yeccgoto(primop_expr, 226) -> - 64; -yeccgoto(primop_expr, 232) -> - 64; -yeccgoto(primop_expr, 235) -> - 64; -yeccgoto(primop_expr, 257) -> - 64; -yeccgoto(primop_expr, 260) -> - 64; -yeccgoto(primop_expr, 265) -> - 64; -yeccgoto(receive_expr, 33) -> - 66; -yeccgoto(receive_expr, 35) -> - 66; -yeccgoto(receive_expr, 36) -> - 66; -yeccgoto(receive_expr, 37) -> - 66; -yeccgoto(receive_expr, 40) -> - 66; -yeccgoto(receive_expr, 44) -> - 66; -yeccgoto(receive_expr, 46) -> - 66; -yeccgoto(receive_expr, 48) -> - 66; -yeccgoto(receive_expr, 52) -> - 66; -yeccgoto(receive_expr, 70) -> - 66; -yeccgoto(receive_expr, 74) -> - 66; -yeccgoto(receive_expr, 79) -> - 66; -yeccgoto(receive_expr, 86) -> - 66; -yeccgoto(receive_expr, 90) -> - 66; -yeccgoto(receive_expr, 99) -> - 66; -yeccgoto(receive_expr, 164) -> - 66; -yeccgoto(receive_expr, 166) -> - 66; -yeccgoto(receive_expr, 171) -> - 66; -yeccgoto(receive_expr, 203) -> - 66; -yeccgoto(receive_expr, 211) -> - 66; -yeccgoto(receive_expr, 214) -> - 66; -yeccgoto(receive_expr, 216) -> - 66; -yeccgoto(receive_expr, 218) -> - 66; -yeccgoto(receive_expr, 226) -> - 66; -yeccgoto(receive_expr, 232) -> - 66; -yeccgoto(receive_expr, 235) -> - 66; -yeccgoto(receive_expr, 257) -> - 66; -yeccgoto(receive_expr, 260) -> - 66; -yeccgoto(receive_expr, 265) -> - 66; -yeccgoto(segment, 247) -> - 249; -yeccgoto(segment, 255) -> - 249; -yeccgoto(segment_pattern, 190) -> - 192; -yeccgoto(segment_pattern, 198) -> - 192; -yeccgoto(segment_patterns, 190) -> - 193; -yeccgoto(segment_patterns, 198) -> - 199; -yeccgoto(segments, 247) -> - 250; -yeccgoto(segments, 255) -> - 256; -yeccgoto(sequence, 33) -> - 67; -yeccgoto(sequence, 35) -> - 67; -yeccgoto(sequence, 36) -> - 67; -yeccgoto(sequence, 37) -> - 67; -yeccgoto(sequence, 40) -> - 67; -yeccgoto(sequence, 44) -> - 67; -yeccgoto(sequence, 46) -> - 67; -yeccgoto(sequence, 48) -> - 67; -yeccgoto(sequence, 52) -> - 67; -yeccgoto(sequence, 70) -> - 67; -yeccgoto(sequence, 74) -> - 67; -yeccgoto(sequence, 79) -> - 67; -yeccgoto(sequence, 86) -> - 67; -yeccgoto(sequence, 90) -> - 67; -yeccgoto(sequence, 99) -> - 67; -yeccgoto(sequence, 164) -> - 67; -yeccgoto(sequence, 166) -> - 67; -yeccgoto(sequence, 171) -> - 67; -yeccgoto(sequence, 203) -> - 67; -yeccgoto(sequence, 211) -> - 67; -yeccgoto(sequence, 214) -> - 67; -yeccgoto(sequence, 216) -> - 67; -yeccgoto(sequence, 218) -> - 67; -yeccgoto(sequence, 226) -> - 67; -yeccgoto(sequence, 232) -> - 67; -yeccgoto(sequence, 235) -> - 67; -yeccgoto(sequence, 257) -> - 67; -yeccgoto(sequence, 260) -> - 67; -yeccgoto(sequence, 265) -> - 67; -yeccgoto(single_expression, 33) -> - 68; -yeccgoto(single_expression, 35) -> - 68; -yeccgoto(single_expression, 36) -> - 68; -yeccgoto(single_expression, 37) -> - 68; -yeccgoto(single_expression, 40) -> - 68; -yeccgoto(single_expression, 44) -> - 68; -yeccgoto(single_expression, 46) -> - 68; -yeccgoto(single_expression, 48) -> - 68; -yeccgoto(single_expression, 52) -> - 68; -yeccgoto(single_expression, 70) -> - 68; -yeccgoto(single_expression, 74) -> - 68; -yeccgoto(single_expression, 79) -> - 68; -yeccgoto(single_expression, 86) -> - 68; -yeccgoto(single_expression, 90) -> - 68; -yeccgoto(single_expression, 99) -> - 68; -yeccgoto(single_expression, 164) -> - 68; -yeccgoto(single_expression, 166) -> - 68; -yeccgoto(single_expression, 171) -> - 68; -yeccgoto(single_expression, 203) -> - 68; -yeccgoto(single_expression, 211) -> - 68; -yeccgoto(single_expression, 214) -> - 68; -yeccgoto(single_expression, 216) -> - 68; -yeccgoto(single_expression, 218) -> - 68; -yeccgoto(single_expression, 226) -> - 68; -yeccgoto(single_expression, 232) -> - 68; -yeccgoto(single_expression, 235) -> - 68; -yeccgoto(single_expression, 257) -> - 68; -yeccgoto(single_expression, 260) -> - 68; -yeccgoto(single_expression, 265) -> - 68; -yeccgoto(tail, 231) -> - 234; -yeccgoto(tail, 238) -> - 239; -yeccgoto(tail_constant, 150) -> - 153; -yeccgoto(tail_constant, 157) -> - 158; -yeccgoto(tail_literal, 297) -> - 300; -yeccgoto(tail_literal, 304) -> - 305; -yeccgoto(tail_pattern, 173) -> - 176; -yeccgoto(tail_pattern, 180) -> - 181; -yeccgoto(timeout, 65) -> - 112; -yeccgoto(timeout, 101) -> - 168; -yeccgoto(try_expr, 33) -> - 71; -yeccgoto(try_expr, 35) -> - 71; -yeccgoto(try_expr, 36) -> - 71; -yeccgoto(try_expr, 37) -> - 71; -yeccgoto(try_expr, 40) -> - 71; -yeccgoto(try_expr, 44) -> - 71; -yeccgoto(try_expr, 46) -> - 71; -yeccgoto(try_expr, 48) -> - 71; -yeccgoto(try_expr, 52) -> - 71; -yeccgoto(try_expr, 70) -> - 71; -yeccgoto(try_expr, 74) -> - 71; -yeccgoto(try_expr, 79) -> - 71; -yeccgoto(try_expr, 86) -> - 71; -yeccgoto(try_expr, 90) -> - 71; -yeccgoto(try_expr, 99) -> - 71; -yeccgoto(try_expr, 164) -> - 71; -yeccgoto(try_expr, 166) -> - 71; -yeccgoto(try_expr, 171) -> - 71; -yeccgoto(try_expr, 203) -> - 71; -yeccgoto(try_expr, 211) -> - 71; -yeccgoto(try_expr, 214) -> - 71; -yeccgoto(try_expr, 216) -> - 71; -yeccgoto(try_expr, 218) -> - 71; -yeccgoto(try_expr, 226) -> - 71; -yeccgoto(try_expr, 232) -> - 71; -yeccgoto(try_expr, 235) -> - 71; -yeccgoto(try_expr, 257) -> - 71; -yeccgoto(try_expr, 260) -> - 71; -yeccgoto(try_expr, 265) -> - 71; -yeccgoto(tuple, 33) -> - 72; -yeccgoto(tuple, 35) -> - 72; -yeccgoto(tuple, 36) -> - 72; -yeccgoto(tuple, 37) -> - 72; -yeccgoto(tuple, 40) -> - 72; -yeccgoto(tuple, 44) -> - 72; -yeccgoto(tuple, 46) -> - 72; -yeccgoto(tuple, 48) -> - 72; -yeccgoto(tuple, 52) -> - 72; -yeccgoto(tuple, 70) -> - 72; -yeccgoto(tuple, 74) -> - 72; -yeccgoto(tuple, 79) -> - 72; -yeccgoto(tuple, 86) -> - 72; -yeccgoto(tuple, 90) -> - 72; -yeccgoto(tuple, 99) -> - 72; -yeccgoto(tuple, 164) -> - 72; -yeccgoto(tuple, 166) -> - 72; -yeccgoto(tuple, 171) -> - 72; -yeccgoto(tuple, 203) -> - 72; -yeccgoto(tuple, 211) -> - 72; -yeccgoto(tuple, 214) -> - 72; -yeccgoto(tuple, 216) -> - 72; -yeccgoto(tuple, 218) -> - 72; -yeccgoto(tuple, 226) -> - 72; -yeccgoto(tuple, 232) -> - 72; -yeccgoto(tuple, 235) -> - 72; -yeccgoto(tuple, 257) -> - 72; -yeccgoto(tuple, 260) -> - 72; -yeccgoto(tuple, 265) -> - 72; -yeccgoto(tuple_constant, 126) -> - 141; -yeccgoto(tuple_constant, 129) -> - 141; -yeccgoto(tuple_constant, 142) -> - 141; -yeccgoto(tuple_constant, 147) -> - 141; -yeccgoto(tuple_constant, 151) -> - 141; -yeccgoto(tuple_constant, 154) -> - 141; -yeccgoto(tuple_literal, 284) -> - 289; -yeccgoto(tuple_literal, 285) -> - 289; -yeccgoto(tuple_literal, 290) -> - 289; -yeccgoto(tuple_literal, 295) -> - 289; -yeccgoto(tuple_literal, 298) -> - 289; -yeccgoto(tuple_literal, 301) -> - 289; -yeccgoto(tuple_pattern, 65) -> - 113; -yeccgoto(tuple_pattern, 96) -> - 113; -yeccgoto(tuple_pattern, 97) -> - 113; -yeccgoto(tuple_pattern, 98) -> - 113; -yeccgoto(tuple_pattern, 100) -> - 113; -yeccgoto(tuple_pattern, 114) -> - 113; -yeccgoto(tuple_pattern, 115) -> - 113; -yeccgoto(tuple_pattern, 120) -> - 113; -yeccgoto(tuple_pattern, 162) -> - 113; -yeccgoto(tuple_pattern, 174) -> - 113; -yeccgoto(tuple_pattern, 177) -> - 113; -yeccgoto(tuple_pattern, 200) -> - 113; -yeccgoto(tuple_pattern, 222) -> - 113; -yeccgoto(variable, 25) -> - 31; -yeccgoto(variable, 26) -> - 267; -yeccgoto(variable, 33) -> - 73; -yeccgoto(variable, 35) -> - 73; -yeccgoto(variable, 36) -> - 73; -yeccgoto(variable, 37) -> - 73; -yeccgoto(variable, 40) -> - 73; -yeccgoto(variable, 44) -> - 73; -yeccgoto(variable, 46) -> - 73; -yeccgoto(variable, 48) -> - 73; -yeccgoto(variable, 52) -> - 73; -yeccgoto(variable, 58) -> - 31; -yeccgoto(variable, 65) -> - 31; -yeccgoto(variable, 70) -> - 73; -yeccgoto(variable, 74) -> - 73; -yeccgoto(variable, 79) -> - 73; -yeccgoto(variable, 82) -> - 31; -yeccgoto(variable, 83) -> - 31; -yeccgoto(variable, 86) -> - 73; -yeccgoto(variable, 88) -> - 31; -yeccgoto(variable, 90) -> - 73; -yeccgoto(variable, 96) -> - 124; -yeccgoto(variable, 97) -> - 31; -yeccgoto(variable, 98) -> - 31; -yeccgoto(variable, 99) -> - 73; -yeccgoto(variable, 100) -> - 31; -yeccgoto(variable, 114) -> - 31; -yeccgoto(variable, 115) -> - 124; -yeccgoto(variable, 120) -> - 31; -yeccgoto(variable, 162) -> - 31; -yeccgoto(variable, 164) -> - 73; -yeccgoto(variable, 166) -> - 73; -yeccgoto(variable, 171) -> - 73; -yeccgoto(variable, 174) -> - 31; -yeccgoto(variable, 177) -> - 31; -yeccgoto(variable, 200) -> - 31; -yeccgoto(variable, 203) -> - 73; -yeccgoto(variable, 211) -> - 73; -yeccgoto(variable, 214) -> - 73; -yeccgoto(variable, 216) -> - 73; -yeccgoto(variable, 218) -> - 73; -yeccgoto(variable, 222) -> - 31; -yeccgoto(variable, 226) -> - 73; -yeccgoto(variable, 232) -> - 73; -yeccgoto(variable, 235) -> - 73; -yeccgoto(variable, 257) -> - 73; -yeccgoto(variable, 260) -> - 73; -yeccgoto(variable, 263) -> - 31; -yeccgoto(variable, 265) -> - 73; -yeccgoto(__Symbol, __State) -> - exit({__Symbol, __State, missing_in_goto_table}). - - diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_parse.hrl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_parse.hrl deleted file mode 100644 index aaf913a15a..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_parse.hrl +++ /dev/null @@ -1,111 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: core_parse.hrl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% -%% Purpose : Core Erlang syntax trees as records. - -%% It would be nice to incorporate some generic functions as well but -%% this could make including this file difficult. - -%% Note: the annotation list is *always* the first record field. -%% Thus it is possible to define the macros: -%% -define(get_ann(X), element(2, X)). -%% -define(set_ann(X, Y), setelement(2, X, Y)). - --record(c_int, {anno=[], val}). % val :: integer() - --record(c_float, {anno=[], val}). % val :: float() - --record(c_atom, {anno=[], val}). % val :: atom() - --record(c_char, {anno=[], val}). % val :: char() - --record(c_string, {anno=[], val}). % val :: string() - --record(c_nil, {anno=[]}). - --record(c_binary, {anno=[], segments}). % segments :: [#ce_bitstr{}] - --record(c_bitstr, {anno=[],val, % val :: Tree, - size, % size :: Tree, - unit, % unit :: integer(), - type, % type :: atom(), - flags}). % flags :: [atom()], - --record(c_cons, {anno=[], hd, % hd :: Tree, - tl}). % tl :: Tree - --record(c_tuple, {anno=[], es}). % es :: [Tree] - --record(c_var, {anno=[], name}). % name :: integer() | atom() - --record(c_fname, {anno=[], id, % id :: atom(), - arity}). % arity :: integer() - --record(c_values, {anno=[], es}). % es :: [Tree] - --record(c_fun, {anno=[], vars, % vars :: [Tree], - body}). % body :: Tree - --record(c_seq, {anno=[], arg, % arg :: Tree, - body}). % body :: Tree - --record(c_let, {anno=[], vars, % vars :: [Tree], - arg, % arg :: Tree, - body}). % body :: Tree - --record(c_letrec, {anno=[], defs, % defs :: [#ce_def{}], - body}). % body :: Tree - --record(c_def, {anno=[], name, % name :: Tree, - val}). % val :: Tree, - --record(c_case, {anno=[], arg, % arg :: Tree, - clauses}). % clauses :: [Tree] - --record(c_clause, {anno=[], pats, % pats :: [Tree], - guard, % guard :: Tree, - body}). % body :: Tree - --record(c_alias, {anno=[], var, % var :: Tree, - pat}). % pat :: Tree - --record(c_receive, {anno=[], clauses, % clauses :: [Tree], - timeout, % timeout :: Tree, - action}). % action :: Tree - --record(c_apply, {anno=[], op, % op :: Tree, - args}). % args :: [Tree] - --record(c_call, {anno=[], module, % module :: Tree, - name, % name :: Tree, - args}). % args :: [Tree] - --record(c_primop, {anno=[], name, % name :: Tree, - args}). % args :: [Tree] - --record(c_try, {anno=[], arg, % arg :: Tree, - vars, % vars :: [Tree], - body, % body :: Tree - evars, % evars :: [Tree], - handler}). % handler :: Tree - --record(c_catch, {anno=[], body}). % body :: Tree - --record(c_module, {anno=[], name, % name :: Tree, - exports, % exports :: [Tree], - attrs, % attrs :: [#ce_def{}], - defs}). % defs :: [#ce_def{}] diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_pp.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_pp.erl deleted file mode 100644 index 147a0dba6c..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_pp.erl +++ /dev/null @@ -1,430 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: core_pp.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% -%% Purpose : Core Erlang (naive) prettyprinter - --module(core_pp). - --export([format/1]). - --include("core_parse.hrl"). - -%% ====================================================================== %% -%% format(Node) -> Text -%% Node = coreErlang() -%% Text = string() | [Text] -%% -%% Prettyprint-formats (naively) an abstract Core Erlang syntax -%% tree. - --record(ctxt, {class = term, - indent = 0, - item_indent = 2, - body_indent = 4, - tab_width = 8, - line = 0}). - -format(Node) -> case catch format(Node, #ctxt{}) of - {'EXIT',_} -> io_lib:format("~p",[Node]); - Other -> Other - end. - -maybe_anno(Node, Fun, Ctxt) -> - As = core_lib:get_anno(Node), - case get_line(As) of - none -> - maybe_anno(Node, Fun, Ctxt, As); - Line -> - if Line > Ctxt#ctxt.line -> - [io_lib:format("%% Line ~w",[Line]), - nl_indent(Ctxt), - maybe_anno(Node, Fun, Ctxt#ctxt{line = Line}, As) - ]; - true -> - maybe_anno(Node, Fun, Ctxt, As) - end - end. - -maybe_anno(Node, Fun, Ctxt, As) -> - case strip_line(As) of - [] -> - Fun(Node, Ctxt); - List -> - Ctxt1 = add_indent(Ctxt, 2), - Ctxt2 = add_indent(Ctxt1, 3), - ["( ", - Fun(Node, Ctxt1), - nl_indent(Ctxt1), - "-| ",format_1(core_lib:make_literal(List), Ctxt2)," )" - ] - end. - -strip_line([A | As]) when integer(A) -> - strip_line(As); -strip_line([A | As]) -> - [A | strip_line(As)]; -strip_line([]) -> - []. - -get_line([L | _As]) when integer(L) -> - L; -get_line([_ | As]) -> - get_line(As); -get_line([]) -> - none. - -format(Node, Ctxt) -> - maybe_anno(Node, fun format_1/2, Ctxt). - -format_1(#c_char{val=C}, _) -> io_lib:write_char(C); -format_1(#c_int{val=I}, _) -> integer_to_list(I); -format_1(#c_float{val=F}, _) -> float_to_list(F); -format_1(#c_atom{val=A}, _) -> core_atom(A); -format_1(#c_nil{}, _) -> "[]"; -format_1(#c_string{val=S}, _) -> io_lib:write_string(S); -format_1(#c_var{name=V}, _) -> - %% Internal variable names may be: - %% - atoms representing proper Erlang variable names, or - %% any atoms that may be printed without single-quoting - %% - nonnegative integers. - %% It is important that when printing variables, no two names - %% should ever map to the same string. - if atom(V) -> - S = atom_to_list(V), - case S of - [C | _] when C >= $A, C =< $Z -> - %% Ordinary uppercase-prefixed names are - %% printed just as they are. - S; - [$_ | _] -> - %% Already "_"-prefixed names are prefixed - %% with "_X", e.g. '_foo' => '_X_foo', to - %% avoid generating things like "____foo" upon - %% repeated writing and reading of code. - %% ("_X_X_X_foo" is better.) - [$_, $X | S]; - _ -> - %% Plain atoms are prefixed with a single "_". - %% E.g. foo => "_foo". - [$_ | S] - end; - integer(V) -> - %% Integers are also simply prefixed with "_". - [$_ | integer_to_list(V)] - end; -format_1(#c_binary{segments=Segs}, Ctxt) -> - ["#{", - format_vseq(Segs, "", ",", add_indent(Ctxt, 2), - fun format_bitstr/2), - "}#" - ]; -format_1(#c_tuple{es=Es}, Ctxt) -> - [${, - format_hseq(Es, ",", add_indent(Ctxt, 1), fun format/2), - $} - ]; -format_1(#c_cons{hd=H,tl=T}, Ctxt) -> - Txt = ["["|format(H, add_indent(Ctxt, 1))], - [Txt|format_list_tail(T, add_indent(Ctxt, width(Txt, Ctxt)))]; -format_1(#c_values{es=Es}, Ctxt) -> - format_values(Es, Ctxt); -format_1(#c_alias{var=V,pat=P}, Ctxt) -> - Txt = [format(V, Ctxt)|" = "], - [Txt|format(P, add_indent(Ctxt, width(Txt, Ctxt)))]; -format_1(#c_let{vars=Vs,arg=A,body=B}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.body_indent), - ["let ", - format_values(Vs, add_indent(Ctxt, 4)), - " =", - nl_indent(Ctxt1), - format(A, Ctxt1), - nl_indent(Ctxt), - "in " - | format(B, add_indent(Ctxt, 4)) - ]; -format_1(#c_letrec{defs=Fs,body=B}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.body_indent), - ["letrec", - nl_indent(Ctxt1), - format_funcs(Fs, Ctxt1), - nl_indent(Ctxt), - "in " - | format(B, add_indent(Ctxt, 4)) - ]; -format_1(#c_seq{arg=A,body=B}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, 4), - ["do ", - format(A, Ctxt1), - nl_indent(Ctxt1) - | format(B, Ctxt1) - ]; -format_1(#c_case{arg=A,clauses=Cs}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.item_indent), - ["case ", - format(A, add_indent(Ctxt, 5)), - " of", - nl_indent(Ctxt1), - format_clauses(Cs, Ctxt1), - nl_indent(Ctxt) - | "end" - ]; -format_1(#c_receive{clauses=Cs,timeout=T,action=A}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.item_indent), - ["receive", - nl_indent(Ctxt1), - format_clauses(Cs, Ctxt1), - nl_indent(Ctxt), - "after ", - format(T, add_indent(Ctxt, 6)), - " ->", - nl_indent(Ctxt1), - format(A, Ctxt1) - ]; -format_1(#c_fname{id=I,arity=A}, _) -> - [core_atom(I),$/,integer_to_list(A)]; -format_1(#c_fun{vars=Vs,body=B}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.body_indent), - ["fun (", - format_hseq(Vs, ",", add_indent(Ctxt, 5), fun format/2), - ") ->", - nl_indent(Ctxt1) - | format(B, Ctxt1) - ]; -format_1(#c_apply{op=O,args=As}, Ctxt0) -> - Ctxt1 = add_indent(Ctxt0, 6), %"apply " - Op = format(O, Ctxt1), - Ctxt2 = add_indent(Ctxt0, 4), - ["apply ",Op, - nl_indent(Ctxt2), - $(,format_hseq(As, ", ", add_indent(Ctxt2, 1), fun format/2),$) - ]; -format_1(#c_call{module=M,name=N,args=As}, Ctxt0) -> - Ctxt1 = add_indent(Ctxt0, 5), %"call " - Mod = format(M, Ctxt1), - Ctxt2 = add_indent(Ctxt1, width(Mod, Ctxt1)+1), - Name = format(N, Ctxt2), - Ctxt3 = add_indent(Ctxt0, 4), - ["call ",Mod,":",Name, - nl_indent(Ctxt3), - $(,format_hseq(As, ", ", add_indent(Ctxt3, 1), fun format/2),$) - ]; -format_1(#c_primop{name=N,args=As}, Ctxt0) -> - Ctxt1 = add_indent(Ctxt0, 7), %"primop " - Name = format(N, Ctxt1), - Ctxt2 = add_indent(Ctxt0, 4), - ["primop ",Name, - nl_indent(Ctxt2), - $(,format_hseq(As, ", ", add_indent(Ctxt2, 1), fun format/2),$) - ]; -format_1(#c_catch{body=B}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.body_indent), - ["catch", - nl_indent(Ctxt1), - format(B, Ctxt1) - ]; -format_1(#c_try{arg=E,vars=Vs,body=B,evars=Evs,handler=H}, Ctxt) -> - Ctxt1 = add_indent(Ctxt, Ctxt#ctxt.body_indent), - ["try", - nl_indent(Ctxt1), - format(E, Ctxt1), - nl_indent(Ctxt), - "of ", - format_values(Vs, add_indent(Ctxt, 3)), - " ->", - nl_indent(Ctxt1), - format(B, Ctxt1), - nl_indent(Ctxt), - "catch ", - format_values(Evs, add_indent(Ctxt, 6)), - " ->", - nl_indent(Ctxt1) - | format(H, Ctxt1) - ]; -format_1(#c_def{name=N,val=V}, Ctxt) -> - Ctxt1 = add_indent(set_class(Ctxt, expr), Ctxt#ctxt.body_indent), - [format(N, Ctxt), - " =", - nl_indent(Ctxt1) - | format(V, Ctxt1) - ]; -format_1(#c_module{name=N,exports=Es,attrs=As,defs=Ds}, Ctxt) -> - Mod = ["module ", format(N, Ctxt)], - [Mod," [", - format_vseq(Es, - "", ",", - add_indent(set_class(Ctxt, term), width(Mod, Ctxt)+2), - fun format/2), - "]", - nl_indent(Ctxt), - " attributes [", - format_vseq(As, - "", ",", - add_indent(set_class(Ctxt, def), 16), - fun format/2), - "]", - nl_indent(Ctxt), - format_funcs(Ds, Ctxt), - nl_indent(Ctxt) - | "end" - ]; -format_1(Type, _) -> - ["** Unsupported type: ", - io_lib:write(Type) - | " **" - ]. - -format_funcs(Fs, Ctxt) -> - format_vseq(Fs, - "", "", - set_class(Ctxt, def), - fun format/2). - -format_values(Vs, Ctxt) -> - [$<, - format_hseq(Vs, ",", add_indent(Ctxt, 1), fun format/2), - $>]. - -format_bitstr(#c_bitstr{val=V,size=S,unit=U,type=T,flags=Fs}, Ctxt0) -> - Vs = [S, U, T, Fs], - Ctxt1 = add_indent(Ctxt0, 2), - Val = format(V, Ctxt1), - Ctxt2 = add_indent(Ctxt1, width(Val, Ctxt1) + 2), - ["#<", Val, ">(", format_hseq(Vs,",", Ctxt2, fun format/2), $)]. - -format_clauses(Cs, Ctxt) -> - format_vseq(Cs, "", "", set_class(Ctxt, clause), - fun format_clause/2). - -format_clause(Node, Ctxt) -> - maybe_anno(Node, fun format_clause_1/2, Ctxt). - -format_clause_1(#c_clause{pats=Ps,guard=G,body=B}, Ctxt) -> - Ptxt = format_values(Ps, Ctxt), - Ctxt2 = add_indent(Ctxt, Ctxt#ctxt.body_indent), - [Ptxt, - " when ", - format_guard(G, add_indent(set_class(Ctxt, expr), - width(Ptxt, Ctxt) + 6)), - " ->", - nl_indent(Ctxt2) - | format(B, set_class(Ctxt2, expr)) - ]. - -format_guard(Node, Ctxt) -> - maybe_anno(Node, fun format_guard_1/2, Ctxt). - -format_guard_1(#c_call{module=M,name=N,args=As}, Ctxt0) -> - Ctxt1 = add_indent(Ctxt0, 5), %"call " - Mod = format(M, Ctxt1), - Ctxt2 = add_indent(Ctxt1, width(Mod, Ctxt1)+1), - Name = format(N, Ctxt2), - Ctxt3 = add_indent(Ctxt0, 4), - ["call ",Mod,":",Name, - nl_indent(Ctxt3), - $(,format_vseq(As, "",",", add_indent(Ctxt3, 1), fun format_guard/2),$) - ]; -format_guard_1(E, Ctxt) -> format_1(E, Ctxt). %Anno already done - -%% format_hseq([Thing], Separator, Context, Fun) -> Txt. -%% Format a sequence horizontally on the same line with Separator between. - -format_hseq([H], _, Ctxt, Fun) -> - Fun(H, Ctxt); -format_hseq([H|T], Sep, Ctxt, Fun) -> - Txt = [Fun(H, Ctxt)|Sep], - Ctxt1 = add_indent(Ctxt, width(Txt, Ctxt)), - [Txt|format_hseq(T, Sep, Ctxt1, Fun)]; -format_hseq([], _, _, _) -> "". - -%% format_vseq([Thing], LinePrefix, LineSuffix, Context, Fun) -> Txt. -%% Format a sequence vertically in indented lines adding LinePrefix -%% to the beginning of each line and LineSuffix to the end of each -%% line. No prefix on the first line or suffix on the last line. - -format_vseq([H], _Pre, _Suf, Ctxt, Fun) -> - Fun(H, Ctxt); -format_vseq([H|T], Pre, Suf, Ctxt, Fun) -> - [Fun(H, Ctxt),Suf,nl_indent(Ctxt),Pre| - format_vseq(T, Pre, Suf, Ctxt, Fun)]; -format_vseq([], _, _, _, _) -> "". - -format_list_tail(#c_nil{anno=[]}, _) -> "]"; -format_list_tail(#c_cons{anno=[],hd=H,tl=T}, Ctxt) -> - Txt = [$,|format(H, Ctxt)], - Ctxt1 = add_indent(Ctxt, width(Txt, Ctxt)), - [Txt|format_list_tail(T, Ctxt1)]; -format_list_tail(Tail, Ctxt) -> - ["|",format(Tail, add_indent(Ctxt, 1)),"]"]. - -indent(Ctxt) -> indent(Ctxt#ctxt.indent, Ctxt). - -indent(N, _) when N =< 0 -> ""; -indent(N, Ctxt) -> - T = Ctxt#ctxt.tab_width, - string:chars($\t, N div T, string:chars($\s, N rem T)). - -nl_indent(Ctxt) -> [$\n|indent(Ctxt)]. - - -unindent(T, Ctxt) -> - unindent(T, Ctxt#ctxt.indent, Ctxt, []). - -unindent(T, N, _, C) when N =< 0 -> - [T|C]; -unindent([$\s|T], N, Ctxt, C) -> - unindent(T, N - 1, Ctxt, C); -unindent([$\t|T], N, Ctxt, C) -> - Tab = Ctxt#ctxt.tab_width, - if N >= Tab -> - unindent(T, N - Tab, Ctxt, C); - true -> - unindent([string:chars($\s, Tab - N)|T], 0, Ctxt, C) - end; -unindent([L|T], N, Ctxt, C) when list(L) -> - unindent(L, N, Ctxt, [T|C]); -unindent([H|T], _, _, C) -> - [H|[T|C]]; -unindent([], N, Ctxt, [H|T]) -> - unindent(H, N, Ctxt, T); -unindent([], _, _, []) -> []. - - -width(Txt, Ctxt) -> - case catch width(Txt, 0, Ctxt, []) of - {'EXIT',_} -> exit({bad_text,Txt}); - Other -> Other - end. - -width([$\t|T], A, Ctxt, C) -> - width(T, A + Ctxt#ctxt.tab_width, Ctxt, C); -width([$\n|T], _, Ctxt, C) -> - width(unindent([T|C], Ctxt), Ctxt); -width([H|T], A, Ctxt, C) when list(H) -> - width(H, A, Ctxt, [T|C]); -width([_|T], A, Ctxt, C) -> - width(T, A + 1, Ctxt, C); -width([], A, Ctxt, [H|T]) -> - width(H, A, Ctxt, T); -width([], A, _, []) -> A. - -add_indent(Ctxt, Dx) -> - Ctxt#ctxt{indent = Ctxt#ctxt.indent + Dx}. - -set_class(Ctxt, Class) -> - Ctxt#ctxt{class = Class}. - -core_atom(A) -> io_lib:write_string(atom_to_list(A), $'). diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_scan.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_scan.erl deleted file mode 100644 index f53c3c1631..0000000000 --- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/core_scan.erl +++ /dev/null @@ -1,495 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id: core_scan.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $ -%% -%% Purpose: Scanner for Core Erlang. - -%% For handling ISO 8859-1 (Latin-1) we use the following type -%% information: -%% -%% 000 - 037 NUL - US control -%% 040 - 057 SPC - / punctuation -%% 060 - 071 0 - 9 digit -%% 072 - 100 : - @ punctuation -%% 101 - 132 A - Z uppercase -%% 133 - 140 [ - ` punctuation -%% 141 - 172 a - z lowercase -%% 173 - 176 { - ~ punctuation -%% 177 DEL control -%% 200 - 237 control -%% 240 - 277 NBSP - ¿ punctuation -%% 300 - 326 À - Ö uppercase -%% 327 × punctuation -%% 330 - 336 Ø - Þ uppercase -%% 337 - 366 ß - ö lowercase -%% 367 ÷ punctuation -%% 370 - 377 ø - ÿ lowercase -%% -%% Many punctuation characters region have special meaning. Must -%% watch using × \327, bvery close to x \170 - --module(core_scan). - --export([string/1,string/2,tokens/3,format_error/1]). - --import(lists, [reverse/1]). - -%% tokens(Continuation, CharList, StartPos) -> -%% {done, {ok, [Tok], EndPos}, Rest} | -%% {done, {error,{ErrorPos,core_scan,What}, EndPos}, Rest} | -%% {more, Continuation'} -%% This is the main function into the re-entrant scanner. It calls the -%% re-entrant pre-scanner until this says done, then calls scan/1 on -%% the result. -%% -%% The continuation has the form: -%% {RestChars,CharsSoFar,CurrentPos,StartPos} - -tokens([], Chars, Pos) -> %First call - tokens({[],[],Pos,Pos}, Chars, Pos); -tokens({Chars,SoFar0,Cp,Sp}, MoreChars, _) -> - In = Chars ++ MoreChars, - case pre_scan(In, SoFar0, Cp) of - {done,_,[],Ep} -> %Found nothing - {done,{eof,Ep},[]}; - {done,_,SoFar1,Ep} -> %Got complete tokens - Res = case scan(reverse(SoFar1), Sp) of - {ok,Toks} -> {ok,Toks,Ep}; - {error,E} -> {error,E,Ep} - end, - {done,Res,[]}; - {more,Rest,SoFar1,Cp1} -> %Missing end token - {more,{Rest,SoFar1,Cp1,Sp}}; - Other -> %An error has occurred - {done,Other,[]} - end. - -%% string([Char]) -> -%% string([Char], StartPos) -> -%% {ok, [Tok], EndPos} | -%% {error,{Pos,core_scan,What}, EndPos} - -string(Cs) -> string(Cs, 1). - -string(Cs, Sp) -> - %% Add an 'eof' to always get correct handling. - case string_pre_scan(Cs, [], Sp) of - {done,_,SoFar,Ep} -> %Got tokens - case scan(reverse(SoFar), Sp) of - {ok,Toks} -> {ok,Toks,Ep}; - {error,E} -> {error,E,Ep} - end; - Other -> Other %An error has occurred - end. - -%% string_pre_scan(Cs, SoFar0, StartPos) -> -%% {done,Rest,SoFar,EndPos} | {error,E,EndPos}. - -string_pre_scan(Cs, SoFar0, Sp) -> - case pre_scan(Cs, SoFar0, Sp) of - {done,Rest,SoFar1,Ep} -> %Got complete tokens - {done,Rest,SoFar1,Ep}; - {more,Rest,SoFar1,Ep} -> %Missing end token - string_pre_scan(Rest ++ eof, SoFar1, Ep); - Other -> Other %An error has occurred - end. - -%% format_error(Error) -%% Return a string describing the error. - -format_error({string,Quote,Head}) -> - ["unterminated " ++ string_thing(Quote) ++ - " starting with " ++ io_lib:write_string(Head,Quote)]; -format_error({illegal,Type}) -> io_lib:fwrite("illegal ~w", [Type]); -format_error(char) -> "unterminated character"; -format_error(scan) -> "premature end"; -format_error({base,Base}) -> io_lib:fwrite("illegal base '~w'", [Base]); -format_error(float) -> "bad float"; -format_error(Other) -> io_lib:write(Other). - -string_thing($') -> "atom"; -string_thing($") -> "string". - -%% Re-entrant pre-scanner. -%% -%% If the input list of characters is insufficient to build a term the -%% scanner returns a request for more characters and a continuation to be -%% used when trying to build a term with more characters. To indicate -%% end-of-file the input character list should be replaced with 'eof' -%% as an empty list has meaning. -%% -%% When more characters are need inside a comment, string or quoted -%% atom, which can become rather long, instead of pushing the -%% characters read so far back onto RestChars to be reread, a special -%% reentry token is returned indicating the middle of a construct. -%% The token is the start character as an atom, '%', '"' and '\''. - -%% pre_scan([Char], SoFar, StartPos) -> -%% {done,RestChars,ScannedChars,NewPos} | -%% {more,RestChars,ScannedChars,NewPos} | -%% {error,{ErrorPos,core_scan,Description},NewPos}. -%% Main pre-scan function. It has been split into 2 functions because of -%% efficiency, with a good indexing compiler it would be unnecessary. - -pre_scan([C|Cs], SoFar, Pos) -> - pre_scan(C, Cs, SoFar, Pos); -pre_scan([], SoFar, Pos) -> - {more,[],SoFar,Pos}; -pre_scan(eof, SoFar, Pos) -> - {done,eof,SoFar,Pos}. - -%% pre_scan(Char, [Char], SoFar, Pos) - -pre_scan($$, Cs0, SoFar0, Pos) -> - case pre_char(Cs0, [$$|SoFar0]) of - {Cs,SoFar} -> - pre_scan(Cs, SoFar, Pos); - more -> - {more,[$$|Cs0],SoFar0, Pos}; - error -> - pre_error(char, Pos, Pos) - end; -pre_scan($', Cs, SoFar, Pos) -> - pre_string(Cs, $', '\'', Pos, [$'|SoFar], Pos); -pre_scan({'\'',Sp}, Cs, SoFar, Pos) -> %Re-entering quoted atom - pre_string(Cs, $', '\'', Sp, SoFar, Pos); -pre_scan($", Cs, SoFar, Pos) -> - pre_string(Cs, $", '"', Pos, [$"|SoFar], Pos); -pre_scan({'"',Sp}, Cs, SoFar, Pos) -> %Re-entering string - pre_string(Cs, $", '"', Sp, SoFar, Pos); -pre_scan($%, Cs, SoFar, Pos) -> - pre_comment(Cs, SoFar, Pos); -pre_scan('%', Cs, SoFar, Pos) -> %Re-entering comment - pre_comment(Cs, SoFar, Pos); -pre_scan($\n, Cs, SoFar, Pos) -> - pre_scan(Cs, [$\n|SoFar], Pos+1); -pre_scan(C, Cs, SoFar, Pos) -> - pre_scan(Cs, [C|SoFar], Pos). - -%% pre_string([Char], Quote, Reent, StartPos, SoFar, Pos) - -pre_string([Q|Cs], Q, _, _, SoFar, Pos) -> - pre_scan(Cs, [Q|SoFar], Pos); -pre_string([$\n|Cs], Q, Reent, Sp, SoFar, Pos) -> - pre_string(Cs, Q, Reent, Sp, [$\n|SoFar], Pos+1); -pre_string([$\\|Cs0], Q, Reent, Sp, SoFar0, Pos) -> - case pre_escape(Cs0, SoFar0) of - {Cs,SoFar} -> - pre_string(Cs, Q, Reent, Sp, SoFar, Pos); - more -> - {more,[{Reent,Sp},$\\|Cs0],SoFar0,Pos}; - error -> - pre_string_error(Q, Sp, SoFar0, Pos) - end; -pre_string([C|Cs], Q, Reent, Sp, SoFar, Pos) -> - pre_string(Cs, Q, Reent, Sp, [C|SoFar], Pos); -pre_string([], _, Reent, Sp, SoFar, Pos) -> - {more,[{Reent,Sp}],SoFar,Pos}; -pre_string(eof, Q, _, Sp, SoFar, Pos) -> - pre_string_error(Q, Sp, SoFar, Pos). - -pre_string_error(Q, Sp, SoFar, Pos) -> - S = reverse(string:substr(SoFar, 1, string:chr(SoFar, Q)-1)), - pre_error({string,Q,string:substr(S, 1, 16)}, Sp, Pos). - -pre_char([C|Cs], SoFar) -> pre_char(C, Cs, SoFar); -pre_char([], _) -> more; -pre_char(eof, _) -> error. - -pre_char($\\, Cs, SoFar) -> - pre_escape(Cs, SoFar); -pre_char(C, Cs, SoFar) -> - {Cs,[C|SoFar]}. - -pre_escape([$^|Cs0], SoFar) -> - case Cs0 of - [C3|Cs] -> - {Cs,[C3,$^,$\\|SoFar]}; - [] -> more; - eof -> error - end; -pre_escape([C|Cs], SoFar) -> - {Cs,[C,$\\|SoFar]}; -pre_escape([], _) -> more; -pre_escape(eof, _) -> error. - -%% pre_comment([Char], SoFar, Pos) -%% Comments are replaced by one SPACE. - -pre_comment([$\n|Cs], SoFar, Pos) -> - pre_scan(Cs, [$\n,$\s|SoFar], Pos+1); %Terminate comment -pre_comment([_|Cs], SoFar, Pos) -> - pre_comment(Cs, SoFar, Pos); -pre_comment([], SoFar, Pos) -> - {more,['%'],SoFar,Pos}; -pre_comment(eof, Sofar, Pos) -> - pre_scan(eof, [$\s|Sofar], Pos). - -pre_error(E, Epos, Pos) -> - {error,{Epos,core_scan,E}, Pos}. - -%% scan(CharList, StartPos) -%% This takes a list of characters and tries to tokenise them. -%% -%% The token list is built in reverse order (in a stack) to save appending -%% and then reversed when all the tokens have been collected. Most tokens -%% are built in the same way. -%% -%% Returns: -%% {ok,[Tok]} -%% {error,{ErrorPos,core_scan,What}} - -scan(Cs, Pos) -> - scan1(Cs, [], Pos). - -%% scan1(Characters, TokenStack, Position) -%% Scan a list of characters into tokens. - -scan1([$\n|Cs], Toks, Pos) -> %Skip newline - scan1(Cs, Toks, Pos+1); -scan1([C|Cs], Toks, Pos) when C >= $\000, C =< $\s -> %Skip control chars - scan1(Cs, Toks, Pos); -scan1([C|Cs], Toks, Pos) when C >= $\200, C =< $\240 -> - scan1(Cs, Toks, Pos); -scan1([C|Cs], Toks, Pos) when C >= $a, C =< $z -> %Keywords - scan_key_word(C, Cs, Toks, Pos); -scan1([C|Cs], Toks, Pos) when C >= $ß, C =< $ÿ, C /= $÷ -> - scan_key_word(C, Cs, Toks, Pos); -scan1([C|Cs], Toks, Pos) when C >= $A, C =< $Z -> %Variables - scan_variable(C, Cs, Toks, Pos); -scan1([C|Cs], Toks, Pos) when C >= $À, C =< $Þ, C /= $× -> - scan_variable(C, Cs, Toks, Pos); -scan1([C|Cs], Toks, Pos) when C >= $0, C =< $9 -> %Numbers - scan_number(C, Cs, Toks, Pos); -scan1([$-,C|Cs], Toks, Pos) when C >= $0, C =< $9 -> %Signed numbers - scan_signed_number($-, C, Cs, Toks, Pos); -scan1([$+,C|Cs], Toks, Pos) when C >= $0, C =< $9 -> %Signed numbers - scan_signed_number($+, C, Cs, Toks, Pos); -scan1([$_|Cs], Toks, Pos) -> %_ variables - scan_variable($_, Cs, Toks, Pos); -scan1([$$|Cs0], Toks, Pos) -> %Character constant - {C,Cs,Pos1} = scan_char(Cs0, Pos), - scan1(Cs, [{char,Pos,C}|Toks], Pos1); -scan1([$'|Cs0], Toks, Pos) -> %Atom (always quoted) - {S,Cs1,Pos1} = scan_string(Cs0, $', Pos), - case catch list_to_atom(S) of - A when atom(A) -> - scan1(Cs1, [{atom,Pos,A}|Toks], Pos1); - _Error -> scan_error({illegal,atom}, Pos) - end; -scan1([$"|Cs0], Toks, Pos) -> %String - {S,Cs1,Pos1} = scan_string(Cs0, $", Pos), - scan1(Cs1, [{string,Pos,S}|Toks], Pos1); -%% Punctuation characters and operators, first recognise multiples. -scan1("->" ++ Cs, Toks, Pos) -> - scan1(Cs, [{'->',Pos}|Toks], Pos); -scan1("-|" ++ Cs, Toks, Pos) -> - scan1(Cs, [{'-|',Pos}|Toks], Pos); -scan1([C|Cs], Toks, Pos) -> %Punctuation character - P = list_to_atom([C]), - scan1(Cs, [{P,Pos}|Toks], Pos); -scan1([], Toks0, _) -> - Toks = reverse(Toks0), - {ok,Toks}. - -%% scan_key_word(FirstChar, CharList, Tokens, Pos) -%% scan_variable(FirstChar, CharList, Tokens, Pos) - -scan_key_word(C, Cs0, Toks, Pos) -> - {Wcs,Cs} = scan_name(Cs0, []), - case catch list_to_atom([C|reverse(Wcs)]) of - Name when atom(Name) -> - scan1(Cs, [{Name,Pos}|Toks], Pos); - _Error -> scan_error({illegal,atom}, Pos) - end. - -scan_variable(C, Cs0, Toks, Pos) -> - {Wcs,Cs} = scan_name(Cs0, []), - case catch list_to_atom([C|reverse(Wcs)]) of - Name when atom(Name) -> - scan1(Cs, [{var,Pos,Name}|Toks], Pos); - _Error -> scan_error({illegal,var}, Pos) - end. - -%% scan_name(Cs) -> lists:splitwith(fun (C) -> name_char(C) end, Cs). - -scan_name([C|Cs], Ncs) -> - case name_char(C) of - true -> scan_name(Cs, [C|Ncs]); - false -> {Ncs,[C|Cs]} %Must rebuild here, sigh! - end; -scan_name([], Ncs) -> - {Ncs,[]}. - -name_char(C) when C >= $a, C =< $z -> true; -name_char(C) when C >= $ß, C =< $ÿ, C /= $÷ -> true; -name_char(C) when C >= $A, C =< $Z -> true; -name_char(C) when C >= $À, C =< $Þ, C /= $× -> true; -name_char(C) when C >= $0, C =< $9 -> true; -name_char($_) -> true; -name_char($@) -> true; -name_char(_) -> false. - -%% scan_string(CharList, QuoteChar, Pos) -> {StringChars,RestChars,NewPos}. - -scan_string(Cs, Q, Pos) -> - scan_string(Cs, [], Q, Pos). - -scan_string([Q|Cs], Scs, Q, Pos) -> - {reverse(Scs),Cs,Pos}; -scan_string([$\n|Cs], Scs, Q, Pos) -> - scan_string(Cs, [$\n|Scs], Q, Pos+1); -scan_string([$\\|Cs0], Scs, Q, Pos) -> - {C,Cs,Pos1} = scan_escape(Cs0, Pos), - scan_string(Cs, [C|Scs], Q, Pos1); -scan_string([C|Cs], Scs, Q, Pos) -> - scan_string(Cs, [C|Scs], Q, Pos). - -%% scan_char(Chars, Pos) -> {Char,RestChars,NewPos}. -%% Read a single character from a character constant. The pre-scan -%% phase has checked for errors here. - -scan_char([$\\|Cs], Pos) -> - scan_escape(Cs, Pos); -scan_char([$\n|Cs], Pos) -> %Newline - {$\n,Cs,Pos+1}; -scan_char([C|Cs], Pos) -> - {C,Cs,Pos}. - -scan_escape([O1,O2,O3|Cs], Pos) when %\<1-3> octal digits - O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7, O3 >= $0, O3 =< $7 -> - Val = (O1*8 + O2)*8 + O3 - 73*$0, - {Val,Cs,Pos}; -scan_escape([O1,O2|Cs], Pos) when - O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7 -> - Val = (O1*8 + O2) - 9*$0, - {Val,Cs,Pos}; -scan_escape([O1|Cs], Pos) when - O1 >= $0, O1 =< $7 -> - {O1 - $0,Cs,Pos}; -scan_escape([$^,C|Cs], Pos) -> %\^X -> CTL-X - Val = C band 31, - {Val,Cs,Pos}; -%scan_escape([$\n,C1|Cs],Pos) -> -% {C1,Cs,Pos+1}; -%scan_escape([C,C1|Cs],Pos) when C >= $\000, C =< $\s -> -% {C1,Cs,Pos}; -scan_escape([$\n|Cs],Pos) -> - {$\n,Cs,Pos+1}; -scan_escape([C0|Cs],Pos) -> - C = escape_char(C0), - {C,Cs,Pos}. - -escape_char($n) -> $\n; %\n = LF -escape_char($r) -> $\r; %\r = CR -escape_char($t) -> $\t; %\t = TAB -escape_char($v) -> $\v; %\v = VT -escape_char($b) -> $\b; %\b = BS -escape_char($f) -> $\f; %\f = FF -escape_char($e) -> $\e; %\e = ESC -escape_char($s) -> $\s; %\s = SPC -escape_char($d) -> $\d; %\d = DEL -escape_char(C) -> C. - -%% scan_number(Char, CharList, TokenStack, Pos) -%% We can handle simple radix notation: -%%true
if the environment is empty, otherwise
-%% false
.
-
-is_empty([{map, Dict} | Es]) ->
- N = dict:size(Dict),
- if N /= 0 -> false;
- Es == [] -> true;
- true -> is_empty(Es)
- end;
-is_empty([{rec, Dict, _} | Es]) ->
- N = dict:size(Dict),
- if N /= 0 -> false;
- Es == [] -> true;
- true -> is_empty(Es)
- end.
-
-
-%% =====================================================================
-%% @spec size(Env::environment()) -> integer()
-%%
-%% @doc Returns the number of entries in an environment.
-
-%% (The name 'size' cannot be used in local calls, since there exists a
-%% built-in function with the same name.)
-
-size(Env) ->
- env_size(Env).
-
-env_size([{map, Dict}]) ->
- dict:size(Dict);
-env_size([{map, Dict} | Env]) ->
- dict:size(Dict) + env_size(Env);
-env_size([{rec, Dict, _Dict0} | Env]) ->
- dict:size(Dict) + env_size(Env).
-
-
-%% =====================================================================
-%% @spec is_defined(Key, Env) -> boolean()
-%%
-%% Key = term()
-%% Env = environment()
-%%
-%% @doc Returns true
if Key
is bound in the
-%% environment, otherwise false
.
-
-is_defined(Key, [{map, Dict} | Env]) ->
- case dict:is_key(Key, Dict) of
- true ->
- true;
- false when Env == [] ->
- false;
- false ->
- is_defined(Key, Env)
- end;
-is_defined(Key, [{rec, Dict, _Dict0} | Env]) ->
- case dict:is_key(Key, Dict) of
- true ->
- true;
- false ->
- is_defined(Key, Env)
- end.
-
-
-%% =====================================================================
-%% @spec keys(Env::environment()) -> [term()]
-%%
-%% @doc Returns the ordered list of all keys in the environment.
-
-keys(Env) ->
- lists:sort(keys(Env, [])).
-
-keys([{map, Dict}], S) ->
- dict:fetch_keys(Dict) ++ S;
-keys([{map, Dict} | Env], S) ->
- keys(Env, dict:fetch_keys(Dict) ++ S);
-keys([{rec, Dict, _Dict0} | Env], S) ->
- keys(Env, dict:fetch_keys(Dict) ++ S).
-
-
-%% =====================================================================
-%% @spec to_list(Env) -> [{Key, Value}]
-%%
-%% Env = environment()
-%% Key = term()
-%% Value = term()
-%%
-%% @doc Returns an ordered list of {Key, Value}
pairs for
-%% all keys in Env
. Value
is the same as that
-%% returned by {@link get/2}.
-
-to_list(Env) ->
- lists:sort(to_list(Env, [])).
-
-to_list([{map, Dict}], S) ->
- dict:to_list(Dict) ++ S;
-to_list([{map, Dict} | Env], S) ->
- to_list(Env, dict:to_list(Dict) ++ S);
-to_list([{rec, Dict, _Dict0} | Env], S) ->
- to_list(Env, dict:to_list(Dict) ++ S).
-
-
-%% =====================================================================
-%% @spec bind(Key, Value, Env) -> environment()
-%%
-%% Key = term()
-%% Value = term()
-%% Env = environment()
-%%
-%% @doc Make a nonrecursive entry. This binds Key
to
-%% Value
. If the key already existed in the environment,
-%% the old entry is replaced.
-
-%% Note that deletion is done to free old bindings so they can be
-%% garbage collected.
-
-bind(Key, Value, [{map, Dict}]) ->
- [{map, dict:store(Key, Value, Dict)}];
-bind(Key, Value, [{map, Dict} | Env]) ->
- [{map, dict:store(Key, Value, Dict)} | delete_any(Key, Env)];
-bind(Key, Value, Env) ->
- [{map, dict:store(Key, Value, dict:new())} | delete_any(Key, Env)].
-
-
-%% =====================================================================
-%% @spec bind_list(Keys, Values, Env) -> environment()
-%%
-%% Keys = [term()]
-%% Values = [term()]
-%% Env = environment()
-%%
-%% @doc Make N nonrecursive entries. This binds each key in
-%% Keys
to the corresponding value in
-%% Values
. If some key already existed in the environment,
-%% the previous entry is replaced. If Keys
does not have
-%% the same length as Values
, an exception is generated.
-
-bind_list(Ks, Vs, [{map, Dict}]) ->
- [{map, store_list(Ks, Vs, Dict)}];
-bind_list(Ks, Vs, [{map, Dict} | Env]) ->
- [{map, store_list(Ks, Vs, Dict)} | delete_list(Ks, Env)];
-bind_list(Ks, Vs, Env) ->
- [{map, store_list(Ks, Vs, dict:new())} | delete_list(Ks, Env)].
-
-store_list([K | Ks], [V | Vs], Dict) ->
- store_list(Ks, Vs, dict:store(K, V, Dict));
-store_list([], _, Dict) ->
- Dict.
-
-delete_list([K | Ks], Env) ->
- delete_list(Ks, delete_any(K, Env));
-delete_list([], Env) ->
- Env.
-
-%% By not calling `delete' unless we have to, we avoid unnecessary
-%% rewriting of the data.
-
-delete_any(Key, Env) ->
- case is_defined(Key, Env) of
- true ->
- delete(Key, Env);
- false ->
- Env
- end.
-
-%% =====================================================================
-%% @spec delete(Key, Env) -> environment()
-%%
-%% Key = term()
-%% Env = environment()
-%%
-%% @doc Delete an entry. This removes Key
from the
-%% environment.
-
-delete(Key, [{map, Dict} = E | Env]) ->
- case dict:is_key(Key, Dict) of
- true ->
- [{map, dict:erase(Key, Dict)} | Env];
- false ->
- delete_1(Key, Env, E)
- end;
-delete(Key, [{rec, Dict, Dict0} = E | Env]) ->
- case dict:is_key(Key, Dict) of
- true ->
- %% The Dict0 component must be preserved as it is until all
- %% keys in Dict have been deleted.
- Dict1 = dict:erase(Key, Dict),
- case dict:size(Dict1) of
- 0 ->
- Env; % the whole {rec,...} is now garbage
- _ ->
- [{rec, Dict1, Dict0} | Env]
- end;
- false ->
- [E | delete(Key, Env)]
- end.
-
-%% This is just like above, except we pass on the preceding 'map'
-%% mapping in the list to enable merging when removing 'rec' mappings.
-
-delete_1(Key, [{rec, Dict, Dict0} = E | Env], E1) ->
- case dict:is_key(Key, Dict) of
- true ->
- Dict1 = dict:erase(Key, Dict),
- case dict:size(Dict1) of
- 0 ->
- concat(E1, Env);
- _ ->
- [E1, {rec, Dict1, Dict0} | Env]
- end;
- false ->
- [E1, E | delete(Key, Env)]
- end.
-
-concat({map, D1}, [{map, D2} | Env]) ->
- [dict:merge(fun (_K, V1, _V2) -> V1 end, D1, D2) | Env];
-concat(E1, Env) ->
- [E1 | Env].
-
-
-%% =====================================================================
-%% @spec bind_recursive(Keys, Values, Fun, Env) -> NewEnv
-%%
-%% Keys = [term()]
-%% Values = [term()]
-%% Fun = (Value, Env) -> term()
-%% Env = environment()
-%% NewEnv = environment()
-%%
-%% @doc Make N recursive entries. This binds each key in
-%% Keys
to the value of Fun(Value, NewEnv)
for
-%% the corresponding Value
. If Keys
does not
-%% have the same length as Values
, an exception is
-%% generated. If some key already existed in the environment, the old
-%% entry is replaced.
-%%
-%% Note: the function Fun
is evaluated each time one of
-%% the stored keys is looked up, but only then.
Examples: -%%
-%% NewEnv = bind_recursive([foo, bar], [1, 2], -%% fun (V, E) -> V end, -%% Env)-%% -%% This does nothing interesting;
get(foo, NewEnv)
yields
-%% 1
and get(bar, NewEnv)
yields
-%% 2
, but there is more overhead than if the {@link
-%% bind_list/3} function had been used.
-%%
-%% -%% NewEnv = bind_recursive([foo, bar], [1, 2], -%% fun (V, E) -> {V, E} end, -%% Env)-%% -%% Here, however,
get(foo, NewEnv)
will yield {1,
-%% NewEnv}
and get(bar, NewEnv)
will yield {2,
-%% NewEnv}
, i.e., the environment NewEnv
contains
-%% recursive bindings.
-
-bind_recursive([], [], _, Env) ->
- Env;
-bind_recursive(Ks, Vs, F, Env) ->
- F1 = fun (V) ->
- fun (Dict) -> F(V, [{rec, Dict, Dict} | Env]) end
- end,
- Dict = bind_recursive_1(Ks, Vs, F1, dict:new()),
- [{rec, Dict, Dict} | Env].
-
-bind_recursive_1([K | Ks], [V | Vs], F, Dict) ->
- bind_recursive_1(Ks, Vs, F, dict:store(K, F(V), Dict));
-bind_recursive_1([], [], _, Dict) ->
- Dict.
-
-
-%% =====================================================================
-%% @spec lookup(Key, Env) -> error | {ok, Value}
-%%
-%% Key = term()
-%% Env = environment()
-%% Value = term()
-%%
-%% @doc Returns {ok, Value}
if Key
is bound to
-%% Value
in Env
, and error
-%% otherwise.
-
-lookup(Key, [{map, Dict} | Env]) ->
- case dict:find(Key, Dict) of
- {ok, _}=Value ->
- Value;
- error when Env == [] ->
- error;
- error ->
- lookup(Key, Env)
- end;
-lookup(Key, [{rec, Dict, Dict0} | Env]) ->
- case dict:find(Key, Dict) of
- {ok, F} ->
- {ok, F(Dict0)};
- error ->
- lookup(Key, Env)
- end.
-
-
-%% =====================================================================
-%% @spec get(Key, Env) -> Value
-%%
-%% Key = term()
-%% Env = environment()
-%% Value = term()
-%%
-%% @doc Returns the value that Key
is bound to in
-%% Env
. Throws {undefined, Key}
if the key
-%% does not exist in Env
.
-
-get(Key, Env) ->
- case lookup(Key, Env) of
- {ok, Value} -> Value;
- error -> throw({undefined, Key})
- end.
-
-
-%% =====================================================================
-%% The key-generating algorithm could possibly be further improved. The
-%% important thing to keep in mind is, that when we need a new key, we
-%% are generally in mid-traversal of a syntax tree, and existing names
-%% in the tree may be closely grouped and evenly distributed or even
-%% forming a compact range (often having been generated by a "gensym",
-%% or by this very algorithm itself). This means that if we generate an
-%% identifier whose value is too close to those already seen (i.e.,
-%% which are in the environment), it is very probable that we will
-%% shadow a not-yet-seen identifier further down in the tree, the result
-%% being that we induce another later renaming, and end up renaming most
-%% of the identifiers, completely contrary to our intention. We need to
-%% generate new identifiers in a way that avoids such systematic
-%% collisions.
-%%
-%% One way of getting a new key to try when the previous attempt failed
-%% is of course to e.g. add one to the last tried value. However, in
-%% general it's a bad idea to try adjacent identifiers: the percentage
-%% of retries will typically increase a lot, so you may lose big on the
-%% extra lookups while gaining only a little from the quicker
-%% computation.
-%%
-%% We want an initial range that is large enough for most typical cases.
-%% If we start with, say, a range of 10, we might quickly use up most of
-%% the values in the range 1-10 (or 1-100) for new top-level variables -
-%% but as we start traversing the syntax tree, it is quite likely that
-%% exactly those variables will be encountered again (this depends on
-%% how the names in the tree were created), and will then need to be
-%% renamed. If we instead begin with a larger range, it is less likely
-%% that any top-level names that we introduce will shadow names that we
-%% will find in the tree. Of course we cannot know how large is large
-%% enough: for any initial range, there is some syntax tree that uses
-%% all the values in that range, and thus any top-level names introduced
-%% will shadow names in the tree. The point is to avoid this happening
-%% all the time - a range of about 1000 seems enough for most programs.
-%%
-%% The following values have been shown to work well:
-
--define(MINIMUM_RANGE, 1000).
--define(START_RANGE_FACTOR, 50).
--define(MAX_RETRIES, 2). % retries before enlarging range
--define(ENLARGE_FACTOR, 10). % range enlargment factor
-
--ifdef(DEBUG).
-%% If you want to use these process dictionary counters, make sure to
-%% initialise them to zero before you call any of the key-generating
-%% functions.
-%%
-%% new_key_calls total number of calls
-%% new_key_retries failed key generation attempts
-%% new_key_max maximum generated integer value
-%%
--define(measure_calls(),
- put(new_key_calls, 1 + get(new_key_calls))).
--define(measure_max_key(N),
- case N > get(new_key_max) of
- true ->
- put(new_key_max, N);
- false ->
- ok
- end).
--define(measure_retries(N),
- put(new_key_retries, get(new_key_retries) + N)).
--else.
--define(measure_calls(), ok).
--define(measure_max_key(N), ok).
--define(measure_retries(N), ok).
--endif.
-
-
-%% =====================================================================
-%% @spec new_key(Env::environment()) -> integer()
-%%
-%% @doc Returns an integer which is not already used as key in the
-%% environment. New integers are generated using an algorithm which
-%% tries to keep the values randomly distributed within a reasonably
-%% small range relative to the number of entries in the environment.
-%%
-%% This function uses the Erlang standard library module
-%% random
to generate new keys.
Note that only the new key is returned; the environment itself is -%% not updated by this function.
- -new_key(Env) -> - new_key(fun (X) -> X end, Env). - - -%% ===================================================================== -%% @spec new_key(Function, Env) -> term() -%% -%% Function = (integer()) -> term() -%% Env = environment() -%% -%% @doc Returns a term which is not already used as key in the -%% environment. The term is generated by applyingFunction
-%% to an integer generated as in {@link new_key/1}.
-%%
-%% Note that only the generated term is returned; the environment -%% itself is not updated by this function.
- -new_key(F, Env) -> - ?measure_calls(), - R = start_range(Env), -%%% io:fwrite("Start range: ~w.\n", [R]), - new_key(R, F, Env). - -new_key(R, F, Env) -> - new_key(generate(R, R), R, 0, F, Env). - -new_key(N, R, T, F, Env) when T < ?MAX_RETRIES -> - A = F(N), - case is_defined(A, Env) of - true -> -%%% io:fwrite("CLASH: ~w.\n", [A]), - new_key(generate(N, R), R, T + 1, F, Env); - false -> - ?measure_max_key(N), - ?measure_retries(T), -%%% io:fwrite("New: ~w.\n", [N]), - A - end; -new_key(N, R, _T, F, Env) -> - %% Too many retries - enlarge the range and start over. - ?measure_retries((_T + 1)), - R1 = trunc(R * ?ENLARGE_FACTOR), -%%% io:fwrite("**NEW RANGE**: ~w.\n", [R1]), - new_key(generate(N, R1), R1, 0, F, Env). - -start_range(Env) -> - max(env_size(Env) * ?START_RANGE_FACTOR, ?MINIMUM_RANGE). - -max(X, Y) when X > Y -> X; -max(_, Y) -> Y. - -%% The previous key might or might not be used to compute the next key -%% to be tried. It is currently not used. -%% -%% In order to avoid causing cascading renamings, it is important that -%% this function does not generate values in order, but -%% (pseudo-)randomly distributed over the range. - -generate(_N, Range) -> - random:uniform(Range). % works well - - -%% ===================================================================== -%% @spec new_keys(N, Env) -> [integer()] -%% -%% N = integer() -%% Env = environment() -%% -%% @doc Returns a list ofN
distinct integers that are not
-%% already used as keys in the environment. See {@link new_key/1} for
-%% details.
-
-new_keys(N, Env) when integer(N) ->
- new_keys(N, fun (X) -> X end, Env).
-
-
-%% =====================================================================
-%% @spec new_keys(N, Function, Env) -> [term()]
-%%
-%% N = integer()
-%% Function = (integer()) -> term()
-%% Env = environment()
-%%
-%% @doc Returns a list of N
distinct terms that are not
-%% already used as keys in the environment. See {@link new_key/3} for
-%% details.
-
-new_keys(N, F, Env) when integer(N) ->
- R = start_range(Env),
- new_keys(N, [], R, F, Env).
-
-new_keys(N, Ks, R, F, Env) when N > 0 ->
- Key = new_key(R, F, Env),
- Env1 = bind(Key, true, Env), % dummy binding
- new_keys(N - 1, [Key | Ks], R, F, Env1);
-new_keys(0, Ks, _, _, _) ->
- Ks.
diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_expand_pmod.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_expand_pmod.erl
deleted file mode 100644
index c5052b0e51..0000000000
--- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_expand_pmod.erl
+++ /dev/null
@@ -1,425 +0,0 @@
-%% ``The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved via the world wide web at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
-%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
-%% AB. All Rights Reserved.''
-%%
-%% $Id: sys_expand_pmod.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $
-%%
--module(sys_expand_pmod).
-
-%% Expand function definition forms of parameterized module. We assume
-%% all record definitions, imports, queries, etc., have been expanded
-%% away. Any calls on the form 'foo(...)' must be calls to local
-%% functions. Auto-generated functions (module_info,...) have not yet
-%% been added to the function definitions, but are listed in 'defined'
-%% and 'exports'. The 'new/N' function is neither added to the
-%% definitions nor to the 'exports'/'defines' lists yet.
-
--export([forms/4]).
-
--record(pmod, {parameters, exports, defined, predef}).
-
-%% TODO: more abstract handling of predefined/static functions.
-
-forms(Fs0, Ps, Es0, Ds0) ->
- PreDef = [{module_info,0},{module_info,1}],
- forms(Fs0, Ps, Es0, Ds0, PreDef).
-
-forms(Fs0, Ps, Es0, Ds0, PreDef) ->
- St0 = #pmod{parameters=Ps,exports=Es0,defined=Ds0, predef=PreDef},
- {Fs1, St1} = forms(Fs0, St0),
- Es1 = update_function_names(Es0, St1),
- Ds1 = update_function_names(Ds0, St1),
- Fs2 = update_forms(Fs1, St1),
- {Fs2,Es1,Ds1}.
-
-%% This is extremely simplistic for now; all functions get an extra
-%% parameter, whether they need it or not, except for static functions.
-
-update_function_names(Es, St) ->
- [update_function_name(E, St) || E <- Es].
-
-update_function_name(E={F,A}, St) ->
- case ordsets:is_element(E, St#pmod.predef) of
- true -> E;
- false -> {F, A + 1}
- end.
-
-update_forms([{function,L,N,A,Cs}|Fs],St) ->
- [{function,L,N,A+1,Cs}|update_forms(Fs,St)];
-update_forms([F|Fs],St) ->
- [F|update_forms(Fs,St)];
-update_forms([],_St) ->
- [].
-
-%% Process the program forms.
-
-forms([F0|Fs0],St0) ->
- {F1,St1} = form(F0,St0),
- {Fs1,St2} = forms(Fs0,St1),
- {[F1|Fs1],St2};
-forms([], St0) ->
- {[], St0}.
-
-%% Only function definitions are of interest here. State is not updated.
-form({function,Line,Name0,Arity0,Clauses0},St) ->
- {Name,Arity,Clauses} = function(Name0, Arity0, Clauses0, St),
- {{function,Line,Name,Arity,Clauses},St};
-%% Pass anything else through
-form(F,St) -> {F,St}.
-
-function(Name, Arity, Clauses0, St) ->
- Clauses1 = clauses(Clauses0,St),
- {Name,Arity,Clauses1}.
-
-clauses([C|Cs],St) ->
- {clause,L,H,G,B} = clause(C,St),
- T = {tuple,L,[{var,L,V} || V <- ['_'|St#pmod.parameters]]},
- [{clause,L,H++[{match,L,T,{var,L,'THIS'}}],G,B}|clauses(Cs,St)];
-clauses([],_St) -> [].
-
-clause({clause,Line,H0,G0,B0},St) ->
- H1 = head(H0,St),
- G1 = guard(G0,St),
- B1 = exprs(B0,St),
- {clause,Line,H1,G1,B1}.
-
-head(Ps,St) -> patterns(Ps,St).
-
-patterns([P0|Ps],St) ->
- P1 = pattern(P0,St),
- [P1|patterns(Ps,St)];
-patterns([],_St) -> [].
-
-string_to_conses([], _Line, Tail) ->
- Tail;
-string_to_conses([E|Rest], Line, Tail) ->
- {cons, Line, {integer, Line, E}, string_to_conses(Rest, Line, Tail)}.
-
-pattern({var,Line,V},_St) -> {var,Line,V};
-pattern({match,Line,L0,R0},St) ->
- L1 = pattern(L0,St),
- R1 = pattern(R0,St),
- {match,Line,L1,R1};
-pattern({integer,Line,I},_St) -> {integer,Line,I};
-pattern({char,Line,C},_St) -> {char,Line,C};
-pattern({float,Line,F},_St) -> {float,Line,F};
-pattern({atom,Line,A},_St) -> {atom,Line,A};
-pattern({string,Line,S},_St) -> {string,Line,S};
-pattern({nil,Line},_St) -> {nil,Line};
-pattern({cons,Line,H0,T0},St) ->
- H1 = pattern(H0,St),
- T1 = pattern(T0,St),
- {cons,Line,H1,T1};
-pattern({tuple,Line,Ps0},St) ->
- Ps1 = pattern_list(Ps0,St),
- {tuple,Line,Ps1};
-pattern({bin,Line,Fs},St) ->
- Fs2 = pattern_grp(Fs,St),
- {bin,Line,Fs2};
-pattern({op,_Line,'++',{nil,_},R},St) ->
- pattern(R,St);
-pattern({op,_Line,'++',{cons,Li,{char,C2,I},T},R},St) ->
- pattern({cons,Li,{char,C2,I},{op,Li,'++',T,R}},St);
-pattern({op,_Line,'++',{cons,Li,{integer,L2,I},T},R},St) ->
- pattern({cons,Li,{integer,L2,I},{op,Li,'++',T,R}},St);
-pattern({op,_Line,'++',{string,Li,L},R},St) ->
- pattern(string_to_conses(L, Li, R),St);
-pattern({op,Line,Op,A},_St) ->
- {op,Line,Op,A};
-pattern({op,Line,Op,L,R},_St) ->
- {op,Line,Op,L,R}.
-
-pattern_grp([{bin_element,L1,E1,S1,T1} | Fs],St) ->
- S2 = case S1 of
- default ->
- default;
- _ ->
- expr(S1,St)
- end,
- T2 = case T1 of
- default ->
- default;
- _ ->
- bit_types(T1)
- end,
- [{bin_element,L1,expr(E1,St),S2,T2} | pattern_grp(Fs,St)];
-pattern_grp([],_St) ->
- [].
-
-bit_types([]) ->
- [];
-bit_types([Atom | Rest]) when atom(Atom) ->
- [Atom | bit_types(Rest)];
-bit_types([{Atom, Integer} | Rest]) when atom(Atom), integer(Integer) ->
- [{Atom, Integer} | bit_types(Rest)].
-
-pattern_list([P0|Ps],St) ->
- P1 = pattern(P0,St),
- [P1|pattern_list(Ps,St)];
-pattern_list([],_St) -> [].
-
-guard([G0|Gs],St) when list(G0) ->
- [guard0(G0,St) | guard(Gs,St)];
-guard(L,St) ->
- guard0(L,St).
-
-guard0([G0|Gs],St) ->
- G1 = guard_test(G0,St),
- [G1|guard0(Gs,St)];
-guard0([],_St) -> [].
-
-guard_test(Expr={call,Line,{atom,La,F},As0},St) ->
- case erl_internal:type_test(F, length(As0)) of
- true ->
- As1 = gexpr_list(As0,St),
- {call,Line,{atom,La,F},As1};
- _ ->
- gexpr(Expr,St)
- end;
-guard_test(Any,St) ->
- gexpr(Any,St).
-
-gexpr({var,L,V},_St) ->
- {var,L,V};
-% %% alternative implementation of accessing module parameters
-% case index(V,St#pmod.parameters) of
-% N when N > 0 ->
-% {call,L,{remote,L,{atom,L,erlang},{atom,L,element}},
-% [{integer,L,N+1},{var,L,'THIS'}]};
-% _ ->
-% {var,L,V}
-% end;
-gexpr({integer,Line,I},_St) -> {integer,Line,I};
-gexpr({char,Line,C},_St) -> {char,Line,C};
-gexpr({float,Line,F},_St) -> {float,Line,F};
-gexpr({atom,Line,A},_St) -> {atom,Line,A};
-gexpr({string,Line,S},_St) -> {string,Line,S};
-gexpr({nil,Line},_St) -> {nil,Line};
-gexpr({cons,Line,H0,T0},St) ->
- H1 = gexpr(H0,St),
- T1 = gexpr(T0,St),
- {cons,Line,H1,T1};
-gexpr({tuple,Line,Es0},St) ->
- Es1 = gexpr_list(Es0,St),
- {tuple,Line,Es1};
-gexpr({call,Line,{atom,La,F},As0},St) ->
- case erl_internal:guard_bif(F, length(As0)) of
- true -> As1 = gexpr_list(As0,St),
- {call,Line,{atom,La,F},As1}
- end;
-% Pre-expansion generated calls to erlang:is_record/3 must also be handled
-gexpr({call,Line,{remote,La,{atom,Lb,erlang},{atom,Lc,is_record}},As0},St)
- when length(As0) == 3 ->
- As1 = gexpr_list(As0,St),
- {call,Line,{remote,La,{atom,Lb,erlang},{atom,Lc,is_record}},As1};
-% Guard bif's can be remote, but only in the module erlang...
-gexpr({call,Line,{remote,La,{atom,Lb,erlang},{atom,Lc,F}},As0},St) ->
- case erl_internal:guard_bif(F, length(As0)) or
- erl_internal:arith_op(F, length(As0)) or
- erl_internal:comp_op(F, length(As0)) or
- erl_internal:bool_op(F, length(As0)) of
- true -> As1 = gexpr_list(As0,St),
- {call,Line,{remote,La,{atom,Lb,erlang},{atom,Lc,F}},As1}
- end;
-% Unfortunately, writing calls as {M,F}(...) is also allowed.
-gexpr({call,Line,{tuple,La,[{atom,Lb,erlang},{atom,Lc,F}]},As0},St) ->
- case erl_internal:guard_bif(F, length(As0)) or
- erl_internal:arith_op(F, length(As0)) or
- erl_internal:comp_op(F, length(As0)) or
- erl_internal:bool_op(F, length(As0)) of
- true -> As1 = gexpr_list(As0,St),
- {call,Line,{tuple,La,[{atom,Lb,erlang},{atom,Lc,F}]},As1}
- end;
-gexpr({bin,Line,Fs},St) ->
- Fs2 = pattern_grp(Fs,St),
- {bin,Line,Fs2};
-gexpr({op,Line,Op,A0},St) ->
- case erl_internal:arith_op(Op, 1) or
- erl_internal:bool_op(Op, 1) of
- true -> A1 = gexpr(A0,St),
- {op,Line,Op,A1}
- end;
-gexpr({op,Line,Op,L0,R0},St) ->
- case erl_internal:arith_op(Op, 2) or
- erl_internal:bool_op(Op, 2) or
- erl_internal:comp_op(Op, 2) of
- true ->
- L1 = gexpr(L0,St),
- R1 = gexpr(R0,St),
- {op,Line,Op,L1,R1}
- end.
-
-gexpr_list([E0|Es],St) ->
- E1 = gexpr(E0,St),
- [E1|gexpr_list(Es,St)];
-gexpr_list([],_St) -> [].
-
-exprs([E0|Es],St) ->
- E1 = expr(E0,St),
- [E1|exprs(Es,St)];
-exprs([],_St) -> [].
-
-expr({var,L,V},_St) ->
- {var,L,V};
-% case index(V,St#pmod.parameters) of
-% N when N > 0 ->
-% {call,L,{remote,L,{atom,L,erlang},{atom,L,element}},
-% [{integer,L,N+1},{var,L,'THIS'}]};
-% _ ->
-% {var,L,V}
-% end;
-expr({integer,Line,I},_St) -> {integer,Line,I};
-expr({float,Line,F},_St) -> {float,Line,F};
-expr({atom,Line,A},_St) -> {atom,Line,A};
-expr({string,Line,S},_St) -> {string,Line,S};
-expr({char,Line,C},_St) -> {char,Line,C};
-expr({nil,Line},_St) -> {nil,Line};
-expr({cons,Line,H0,T0},St) ->
- H1 = expr(H0,St),
- T1 = expr(T0,St),
- {cons,Line,H1,T1};
-expr({lc,Line,E0,Qs0},St) ->
- Qs1 = lc_quals(Qs0,St),
- E1 = expr(E0,St),
- {lc,Line,E1,Qs1};
-expr({tuple,Line,Es0},St) ->
- Es1 = expr_list(Es0,St),
- {tuple,Line,Es1};
-expr({block,Line,Es0},St) ->
- Es1 = exprs(Es0,St),
- {block,Line,Es1};
-expr({'if',Line,Cs0},St) ->
- Cs1 = icr_clauses(Cs0,St),
- {'if',Line,Cs1};
-expr({'case',Line,E0,Cs0},St) ->
- E1 = expr(E0,St),
- Cs1 = icr_clauses(Cs0,St),
- {'case',Line,E1,Cs1};
-expr({'receive',Line,Cs0},St) ->
- Cs1 = icr_clauses(Cs0,St),
- {'receive',Line,Cs1};
-expr({'receive',Line,Cs0,To0,ToEs0},St) ->
- To1 = expr(To0,St),
- ToEs1 = exprs(ToEs0,St),
- Cs1 = icr_clauses(Cs0,St),
- {'receive',Line,Cs1,To1,ToEs1};
-expr({'try',Line,Es0,Scs0,Ccs0,As0},St) ->
- Es1 = exprs(Es0,St),
- Scs1 = icr_clauses(Scs0,St),
- Ccs1 = icr_clauses(Ccs0,St),
- As1 = exprs(As0,St),
- {'try',Line,Es1,Scs1,Ccs1,As1};
-expr({'fun',Line,Body,Info},St) ->
- case Body of
- {clauses,Cs0} ->
- Cs1 = fun_clauses(Cs0,St),
- {'fun',Line,{clauses,Cs1},Info};
- {function,F,A} ->
- {F1,A1} = update_function_name({F,A},St),
- if A1 == A ->
- {'fun',Line,{function,F,A},Info};
- true ->
- %% Must rewrite local fun-name to a fun that does a
- %% call with the extra THIS parameter.
- As = make_vars(A, Line),
- As1 = As ++ [{var,Line,'THIS'}],
- Call = {call,Line,{atom,Line,F1},As1},
- Cs = [{clause,Line,As,[],[Call]}],
- {'fun',Line,{clauses,Cs},Info}
- end;
- {function,M,F,A} -> %This is an error in lint!
- {'fun',Line,{function,M,F,A},Info}
- end;
-expr({call,Lc,{atom,_,new}=Name,As0},#pmod{parameters=Ps}=St)
- when length(As0) =:= length(Ps) ->
- %% The new() function does not take a 'THIS' argument (it's static).
- As1 = expr_list(As0,St),
- {call,Lc,Name,As1};
-expr({call,Lc,{atom,_,module_info}=Name,As0},St)
- when length(As0) == 0; length(As0) == 1 ->
- %% The module_info/0 and module_info/1 functions are also static.
- As1 = expr_list(As0,St),
- {call,Lc,Name,As1};
-expr({call,Lc,{atom,Lf,F},As0},St) ->
- %% Local function call - needs THIS parameter.
- As1 = expr_list(As0,St),
- {call,Lc,{atom,Lf,F},As1 ++ [{var,0,'THIS'}]};
-expr({call,Line,F0,As0},St) ->
- %% Other function call
- F1 = expr(F0,St),
- As1 = expr_list(As0,St),
- {call,Line,F1,As1};
-expr({'catch',Line,E0},St) ->
- E1 = expr(E0,St),
- {'catch',Line,E1};
-expr({match,Line,P0,E0},St) ->
- E1 = expr(E0,St),
- P1 = pattern(P0,St),
- {match,Line,P1,E1};
-expr({bin,Line,Fs},St) ->
- Fs2 = pattern_grp(Fs,St),
- {bin,Line,Fs2};
-expr({op,Line,Op,A0},St) ->
- A1 = expr(A0,St),
- {op,Line,Op,A1};
-expr({op,Line,Op,L0,R0},St) ->
- L1 = expr(L0,St),
- R1 = expr(R0,St),
- {op,Line,Op,L1,R1};
-%% The following are not allowed to occur anywhere!
-expr({remote,Line,M0,F0},St) ->
- M1 = expr(M0,St),
- F1 = expr(F0,St),
- {remote,Line,M1,F1}.
-
-expr_list([E0|Es],St) ->
- E1 = expr(E0,St),
- [E1|expr_list(Es,St)];
-expr_list([],_St) -> [].
-
-icr_clauses([C0|Cs],St) ->
- C1 = clause(C0,St),
- [C1|icr_clauses(Cs,St)];
-icr_clauses([],_St) -> [].
-
-lc_quals([{generate,Line,P0,E0}|Qs],St) ->
- E1 = expr(E0,St),
- P1 = pattern(P0,St),
- [{generate,Line,P1,E1}|lc_quals(Qs,St)];
-lc_quals([E0|Qs],St) ->
- E1 = expr(E0,St),
- [E1|lc_quals(Qs,St)];
-lc_quals([],_St) -> [].
-
-fun_clauses([C0|Cs],St) ->
- C1 = clause(C0,St),
- [C1|fun_clauses(Cs,St)];
-fun_clauses([],_St) -> [].
-
-% %% Return index from 1 upwards, or 0 if not in the list.
-%
-% index(X,Ys) -> index(X,Ys,1).
-%
-% index(X,[X|Ys],A) -> A;
-% index(X,[Y|Ys],A) -> index(X,Ys,A+1);
-% index(X,[],A) -> 0.
-
-make_vars(N, L) ->
- make_vars(1, N, L).
-
-make_vars(N, M, L) when N =< M ->
- V = list_to_atom("X"++integer_to_list(N)),
- [{var,L,V} | make_vars(N + 1, M, L)];
-make_vars(_, _, _) ->
- [].
diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_pre_attributes.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_pre_attributes.erl
deleted file mode 100644
index 6e68611c66..0000000000
--- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_pre_attributes.erl
+++ /dev/null
@@ -1,212 +0,0 @@
-%% ``The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved via the world wide web at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
-%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
-%% AB. All Rights Reserved.''
-%%
-%% $Id: sys_pre_attributes.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $
-%%
-%% Purpose : Transform Erlang compiler attributes
-
--module(sys_pre_attributes).
-
--export([parse_transform/2]).
-
--define(OPTION_TAG, attributes).
-
--record(state, {forms,
- pre_ops = [],
- post_ops = [],
- options}).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Inserts, deletes and replaces Erlang compiler attributes.
-%%
-%% Valid options are:
-%%
-%% {attribute, insert, AttrName, NewAttrVal}
-%% {attribute, replace, AttrName, NewAttrVal} % replace first occurrence
-%% {attribute, delete, AttrName}
-%%
-%% The transformation is performed in two passes:
-%%
-%% pre_transform
-%% -------------
-%% Searches for attributes in the list of Forms in order to
-%% delete or replace them. 'delete' will delete all occurrences
-%% of attributes with the given name. 'replace' will replace the
-%% first occurrence of the attribute. This pass is will only be
-%% performed if there are replace or delete operations stated
-%% as options.
-%%
-%% post_transform
-%% -------------
-%% Looks up the module attribute and inserts the new attributes
-%% directly after. This pass will only be performed if there are
-%% any attributes left to be inserted after pre_transform. The left
-%% overs will be those replace operations that not has been performed
-%% due to that the pre_transform pass did not find the attribute plus
-%% all insert operations.
-
-parse_transform(Forms, Options) ->
- S = #state{forms = Forms, options = Options},
- S2 = init_transform(S),
- report_verbose("Pre options: ~p~n", [S2#state.pre_ops], S2),
- report_verbose("Post options: ~p~n", [S2#state.post_ops], S2),
- S3 = pre_transform(S2),
- S4 = post_transform(S3),
- S4#state.forms.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Computes the lists of pre_ops and post_ops that are
-%% used in the real transformation.
-init_transform(S) ->
- case S#state.options of
- Options when list(Options) ->
- init_transform(Options, S);
- Option ->
- init_transform([Option], S)
- end.
-
-init_transform([{attribute, insert, Name, Val} | Tail], S) ->
- Op = {insert, Name, Val},
- PostOps = [Op | S#state.post_ops],
- init_transform(Tail, S#state{post_ops = PostOps});
-init_transform([{attribute, replace, Name, Val} | Tail], S) ->
- Op = {replace, Name, Val},
- PreOps = [Op | S#state.pre_ops],
- PostOps = [Op | S#state.post_ops],
- init_transform(Tail, S#state{pre_ops = PreOps, post_ops = PostOps});
-init_transform([{attribute, delete, Name} | Tail], S) ->
- Op = {delete, Name},
- PreOps = [Op | S#state.pre_ops],
- init_transform(Tail, S#state{pre_ops = PreOps});
-init_transform([], S) ->
- S;
-init_transform([_ | T], S) ->
- init_transform(T, S);
-init_transform(BadOpt, S) ->
- report_error("Illegal option (ignored): ~p~n", [BadOpt], S),
- S.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Handle delete and perhaps replace
-
-pre_transform(S) when S#state.pre_ops == [] ->
- S;
-pre_transform(S) ->
- pre_transform(S#state.forms, [], S).
-
-pre_transform([H | T], Acc, S) ->
- case H of
- {attribute, Line, Name, Val} ->
- case lists:keysearch(Name, 2, S#state.pre_ops) of
- false ->
- pre_transform(T, [H | Acc], S);
-
- {value, {replace, Name, NewVal}} ->
- report_warning("Replace attribute ~p: ~p -> ~p~n",
- [Name, Val, NewVal],
- S),
- New = {attribute, Line, Name, NewVal},
- Pre = lists:keydelete(Name, 2, S#state.pre_ops),
- Post = lists:keydelete(Name, 2, S#state.post_ops),
- S2 = S#state{pre_ops = Pre, post_ops = Post},
- if
- Pre == [] ->
- %% No need to search the rest of the Forms
- Forms = lists:reverse(Acc, [New | T]),
- S2#state{forms = Forms};
- true ->
- pre_transform(T, [New | Acc], S2)
- end;
-
- {value, {delete, Name}} ->
- report_warning("Delete attribute ~p: ~p~n",
- [Name, Val],
- S),
- pre_transform(T, Acc, S)
- end;
- _Any ->
- pre_transform(T, [H | Acc], S)
- end;
-pre_transform([], Acc, S) ->
- S#state{forms = lists:reverse(Acc)}.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Handle insert and perhaps replace
-
-post_transform(S) when S#state.post_ops == [] ->
- S;
-post_transform(S) ->
- post_transform(S#state.forms, [], S).
-
-post_transform([H | T], Acc, S) ->
- case H of
- {attribute, Line, module, Val} ->
- Acc2 = lists:reverse([{attribute, Line, module, Val} | Acc]),
- Forms = Acc2 ++ attrs(S#state.post_ops, Line, S) ++ T,
- S#state{forms = Forms, post_ops = []};
- _Any ->
- post_transform(T, [H | Acc], S)
- end;
-post_transform([], Acc, S) ->
- S#state{forms = lists:reverse(Acc)}.
-
-attrs([{replace, Name, NewVal} | T], Line, S) ->
- report_verbose("Insert attribute ~p: ~p~n", [Name, NewVal], S),
- [{attribute, Line, Name, NewVal} | attrs(T, Line, S)];
-attrs([{insert, Name, NewVal} | T], Line, S) ->
- report_verbose("Insert attribute ~p: ~p~n", [Name, NewVal], S),
- [{attribute, Line, Name, NewVal} | attrs(T, Line, S)];
-attrs([], _, _) ->
- [].
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Report functions.
-%%
-%% Errors messages are controlled with the 'report_errors' compiler option
-%% Warning messages are controlled with the 'report_warnings' compiler option
-%% Verbose messages are controlled with the 'verbose' compiler option
-
-report_error(Format, Args, S) ->
- case is_error(S) of
- true ->
- io:format("~p: * ERROR * " ++ Format, [?MODULE | Args]);
- false ->
- ok
- end.
-
-report_warning(Format, Args, S) ->
- case is_warning(S) of
- true ->
- io:format("~p: * WARNING * " ++ Format, [?MODULE | Args]);
- false ->
- ok
- end.
-
-report_verbose(Format, Args, S) ->
- case is_verbose(S) of
- true ->
- io:format("~p: " ++ Format, [?MODULE | Args]);
- false ->
- ok
- end.
-
-is_error(S) ->
- lists:member(report_errors, S#state.options) or is_verbose(S).
-
-is_warning(S) ->
- lists:member(report_warnings, S#state.options) or is_verbose(S).
-
-is_verbose(S) ->
- lists:member(verbose, S#state.options).
diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_pre_expand.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_pre_expand.erl
deleted file mode 100644
index 5e7c1c8bbd..0000000000
--- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/sys_pre_expand.erl
+++ /dev/null
@@ -1,1026 +0,0 @@
-%% ``The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved via the world wide web at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
-%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
-%% AB. All Rights Reserved.''
-%%
-%% $Id: sys_pre_expand.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $
-%%
-%% Purpose : Expand some source Erlang constructions. This is part of the
-%% pre-processing phase.
-
-%% N.B. Although structs (tagged tuples) are not yet allowed in the
-%% language there is code included in pattern/2 and expr/3 (commented out)
-%% that handles them by transforming them to tuples.
-
--module(sys_pre_expand).
-
-%% Main entry point.
--export([module/2]).
-
--import(ordsets, [from_list/1,add_element/2,
- union/1,union/2,intersection/1,intersection/2,subtract/2]).
--import(lists, [member/2,map/2,foldl/3,foldr/3,sort/1,reverse/1,duplicate/2]).
-
--include("../my_include/erl_bits.hrl").
-
--record(expand, {module=[], %Module name
- parameters=undefined, %Module parameters
- package="", %Module package
- exports=[], %Exports
- imports=[], %Imports
- mod_imports, %Module Imports
- compile=[], %Compile flags
- records=dict:new(), %Record definitions
- attributes=[], %Attributes
- defined=[], %Defined functions
- vcount=0, %Variable counter
- func=[], %Current function
- arity=[], %Arity for current function
- fcount=0, %Local fun count
- fun_index=0, %Global index for funs
- bitdefault,
- bittypes
- }).
-
-%% module(Forms, CompileOptions)
-%% {ModuleName,Exports,TransformedForms}
-%% Expand the forms in one module. N.B.: the lists of predefined
-%% exports and imports are really ordsets!
-
-module(Fs, Opts) ->
- %% Set pre-defined exported functions.
- PreExp = [{module_info,0},{module_info,1}],
-
- %% Set pre-defined module imports.
- PreModImp = [{erlang,erlang},{packages,packages}],
-
- %% Build initial expand record.
- St0 = #expand{exports=PreExp,
- mod_imports=dict:from_list(PreModImp),
- compile=Opts,
- defined=PreExp,
- bitdefault = erl_bits:system_bitdefault(),
- bittypes = erl_bits:system_bittypes()
- },
- %% Expand the functions.
- {Tfs,St1} = forms(Fs, foldl(fun define_function/2, St0, Fs)),
- {Efs,St2} = expand_pmod(Tfs, St1),
- %% Get the correct list of exported functions.
- Exports = case member(export_all, St2#expand.compile) of
- true -> St2#expand.defined;
- false -> St2#expand.exports
- end,
- %% Generate all functions from stored info.
- {Ats,St3} = module_attrs(St2#expand{exports = Exports}),
- {Mfs,St4} = module_predef_funcs(St3),
- {St4#expand.module, St4#expand.exports, Ats ++ Efs ++ Mfs,
- St4#expand.compile}.
-
-expand_pmod(Fs0, St) ->
- case St#expand.parameters of
- undefined ->
- {Fs0,St};
- Ps ->
- {Fs1,Xs,Ds} = sys_expand_pmod:forms(Fs0, Ps,
- St#expand.exports,
- St#expand.defined),
- A = length(Ps),
- Vs = [{var,0,V} || V <- Ps],
- N = {atom,0,St#expand.module},
- B = [{tuple,0,[N|Vs]}],
- F = {function,0,new,A,[{clause,0,Vs,[],B}]},
- As = St#expand.attributes,
- {[F|Fs1],St#expand{exports=add_element({new,A}, Xs),
- defined=add_element({new,A}, Ds),
- attributes = [{abstract, true} | As]}}
- end.
-
-%% -type define_function(Form, State) -> State.
-%% Add function to defined if form a function.
-
-define_function({function,_,N,A,_Cs}, St) ->
- St#expand{defined=add_element({N,A}, St#expand.defined)};
-define_function(_, St) -> St.
-
-module_attrs(St) ->
- {[{attribute,0,Name,Val} || {Name,Val} <- St#expand.attributes],St}.
-
-module_predef_funcs(St) ->
- PreDef = [{module_info,0},{module_info,1}],
- PreExp = PreDef,
- {[{function,0,module_info,0,
- [{clause,0,[],[],
- [{call,0,{remote,0,{atom,0,erlang},{atom,0,get_module_info}},
- [{atom,0,St#expand.module}]}]}]},
- {function,0,module_info,1,
- [{clause,0,[{var,0,'X'}],[],
- [{call,0,{remote,0,{atom,0,erlang},{atom,0,get_module_info}},
- [{atom,0,St#expand.module},{var,0,'X'}]}]}]}],
- St#expand{defined=union(from_list(PreDef), St#expand.defined),
- exports=union(from_list(PreExp), St#expand.exports)}}.
-
-%% forms(Forms, State) ->
-%% {TransformedForms,State'}
-%% Process the forms. Attributes are lost and just affect the state.
-%% Ignore uninteresting forms like eof and type.
-
-forms([{attribute,_,Name,Val}|Fs0], St0) ->
- St1 = attribute(Name, Val, St0),
- forms(Fs0, St1);
-forms([{function,L,N,A,Cs}|Fs0], St0) ->
- {Ff,St1} = function(L, N, A, Cs, St0),
- {Fs,St2} = forms(Fs0, St1),
- {[Ff|Fs],St2};
-forms([_|Fs], St) -> forms(Fs, St);
-forms([], St) -> {[],St}.
-
-%% -type attribute(Attribute, Value, State) ->
-%% State.
-%% Process an attribute, this just affects the state.
-
-attribute(module, {Module, As}, St) ->
- M = package_to_string(Module),
- St#expand{module=list_to_atom(M),
- package = packages:strip_last(M),
- parameters=As};
-attribute(module, Module, St) ->
- M = package_to_string(Module),
- St#expand{module=list_to_atom(M),
- package = packages:strip_last(M)};
-attribute(export, Es, St) ->
- St#expand{exports=union(from_list(Es), St#expand.exports)};
-attribute(import, Is, St) ->
- import(Is, St);
-attribute(compile, C, St) when list(C) ->
- St#expand{compile=St#expand.compile ++ C};
-attribute(compile, C, St) ->
- St#expand{compile=St#expand.compile ++ [C]};
-attribute(record, {Name,Defs}, St) ->
- St#expand{records=dict:store(Name, normalise_fields(Defs),
- St#expand.records)};
-attribute(file, _File, St) -> St; %This is ignored
-attribute(Name, Val, St) when list(Val) ->
- St#expand{attributes=St#expand.attributes ++ [{Name,Val}]};
-attribute(Name, Val, St) ->
- St#expand{attributes=St#expand.attributes ++ [{Name,[Val]}]}.
-
-function(L, N, A, Cs0, St0) ->
- {Cs,St} = clauses(Cs0, St0#expand{func=N,arity=A,fcount=0}),
- {{function,L,N,A,Cs},St}.
-
-%% -type clauses([Clause], State) ->
-%% {[TransformedClause],State}.
-%% Expand function clauses.
-
-clauses([{clause,Line,H0,G0,B0}|Cs0], St0) ->
- {H,Hvs,_Hus,St1} = head(H0, St0),
- {G,Gvs,_Gus,St2} = guard(G0, Hvs, St1),
- {B,_Bvs,_Bus,St3} = exprs(B0, union(Hvs, Gvs), St2),
- {Cs,St4} = clauses(Cs0, St3),
- {[{clause,Line,H,G,B}|Cs],St4};
-clauses([], St) -> {[],St}.
-
-%% head(HeadPatterns, State) ->
-%% {TransformedPatterns,Variables,UsedVariables,State'}
-
-head(As, St) -> pattern_list(As, St).
-
-%% pattern(Pattern, State) ->
-%% {TransformedPattern,Variables,UsedVariables,State'}
-%% BITS: added used variables for bit patterns with varaible length
-%%
-
-pattern({var,_,'_'}=Var, St) -> %Ignore anonymous variable.
- {Var,[],[],St};
-pattern({var,_,V}=Var, St) ->
- {Var,[V],[],St};
-pattern({char,_,_}=Char, St) ->
- {Char,[],[],St};
-pattern({integer,_,_}=Int, St) ->
- {Int,[],[],St};
-pattern({float,_,_}=Float, St) ->
- {Float,[],[],St};
-pattern({atom,_,_}=Atom, St) ->
- {Atom,[],[],St};
-pattern({string,_,_}=String, St) ->
- {String,[],[],St};
-pattern({nil,_}=Nil, St) ->
- {Nil,[],[],St};
-pattern({cons,Line,H,T}, St0) ->
- {TH,THvs,Hus,St1} = pattern(H, St0),
- {TT,TTvs,Tus,St2} = pattern(T, St1),
- {{cons,Line,TH,TT},union(THvs, TTvs),union(Hus,Tus),St2};
-pattern({tuple,Line,Ps}, St0) ->
- {TPs,TPsvs,Tus,St1} = pattern_list(Ps, St0),
- {{tuple,Line,TPs},TPsvs,Tus,St1};
-%%pattern({struct,Line,Tag,Ps}, St0) ->
-%% {TPs,TPsvs,St1} = pattern_list(Ps, St0),
-%% {{tuple,Line,[{atom,Line,Tag}|TPs]},TPsvs,St1};
-pattern({record_field,_,_,_}=M, St) ->
- {expand_package(M, St), [], [], St}; % must be a package name
-pattern({record_index,Line,Name,Field}, St) ->
- {index_expr(Line, Field, Name, record_fields(Name, St)),[],[],St};
-pattern({record,Line,Name,Pfs}, St0) ->
- Fs = record_fields(Name, St0),
- {TMs,TMsvs,Us,St1} = pattern_list(pattern_fields(Fs, Pfs), St0),
- {{tuple,Line,[{atom,Line,Name}|TMs]},TMsvs,Us,St1};
-pattern({bin,Line,Es0}, St0) ->
- {Es1,Esvs,Esus,St1} = pattern_bin(Es0, St0),
- {{bin,Line,Es1},Esvs,Esus,St1};
-pattern({op,_,'++',{nil,_},R}, St) ->
- pattern(R, St);
-pattern({op,_,'++',{cons,Li,H,T},R}, St) ->
- pattern({cons,Li,H,{op,Li,'++',T,R}}, St);
-pattern({op,_,'++',{string,Li,L},R}, St) ->
- pattern(string_to_conses(Li, L, R), St);
-pattern({match,Line,Pat1, Pat2}, St0) ->
- {TH,Hvt,Hus,St1} = pattern(Pat2, St0),
- {TT,Tvt,Tus,St2} = pattern(Pat1, St1),
- {{match,Line,TT,TH}, union(Hvt,Tvt), union(Hus,Tus), St2};
-%% Compile-time pattern expressions, including unary operators.
-pattern({op,Line,Op,A}, St) ->
- { erl_eval:partial_eval({op,Line,Op,A}), [], [], St};
-pattern({op,Line,Op,L,R}, St) ->
- { erl_eval:partial_eval({op,Line,Op,L,R}), [], [], St}.
-
-pattern_list([P0|Ps0], St0) ->
- {P,Pvs,Pus,St1} = pattern(P0, St0),
- {Ps,Psvs,Psus,St2} = pattern_list(Ps0, St1),
- {[P|Ps],union(Pvs, Psvs),union(Pus, Psus),St2};
-pattern_list([], St) -> {[],[],[],St}.
-
-%% guard(Guard, VisibleVariables, State) ->
-%% {TransformedGuard,NewVariables,UsedVariables,State'}
-%% Transform a list of guard tests. We KNOW that this has been checked
-%% and what the guards test are. Use expr for transforming the guard
-%% expressions.
-
-guard([G0|Gs0], Vs, St0) ->
- {G,Hvs,Hus,St1} = guard_tests(G0, Vs, St0),
- {Gs,Tvs,Tus,St2} = guard(Gs0, Vs, St1),
- {[G|Gs],union(Hvs, Tvs),union(Hus, Tus),St2};
-guard([], _, St) -> {[],[],[],St}.
-
-guard_tests([Gt0|Gts0], Vs, St0) ->
- {Gt1,Gvs,Gus,St1} = guard_test(Gt0, Vs, St0),
- {Gts1,Gsvs,Gsus,St2} = guard_tests(Gts0, union(Gvs, Vs), St1),
- {[Gt1|Gts1],union(Gvs, Gsvs),union(Gus, Gsus),St2};
-guard_tests([], _, St) -> {[],[],[],St}.
-
-guard_test({call,Line,{atom,_,record},[A,{atom,_,Name}]}, Vs, St) ->
- record_test_in_guard(Line, A, Name, Vs, St);
-guard_test({call,Line,{atom,Lt,Tname},As}, Vs, St) ->
- %% XXX This is ugly. We can remove this workaround if/when
- %% we'll allow 'andalso' in guards. For now, we must have
- %% different code in guards and in bodies.
- Test = {remote,Lt,
- {atom,Lt,erlang},
- {atom,Lt,normalise_test(Tname, length(As))}},
- put(sys_pre_expand_in_guard, yes),
- R = expr({call,Line,Test,As}, Vs, St),
- erase(sys_pre_expand_in_guard),
- R;
-guard_test(Test, Vs, St) ->
- %% XXX See the previous clause.
- put(sys_pre_expand_in_guard, yes),
- R = expr(Test, Vs, St),
- erase(sys_pre_expand_in_guard),
- R.
-
-%% record_test(Line, Term, Name, Vs, St) -> TransformedExpr
-%% Generate code for is_record/1.
-
-record_test(Line, Term, Name, Vs, St) ->
- case get(sys_pre_expand_in_guard) of
- undefined ->
- record_test_in_body(Line, Term, Name, Vs, St);
- yes ->
- record_test_in_guard(Line, Term, Name, Vs, St)
- end.
-
-record_test_in_guard(Line, Term, Name, Vs, St) ->
- %% Notes: (1) To keep is_record/3 properly atomic (e.g. when inverted
- %% using 'not'), we cannot convert it to an instruction
- %% sequence here. It must remain a single call.
- %% (2) Later passes assume that the last argument (the size)
- %% is a literal.
- %% (3) We don't want calls to erlang:is_record/3 (in the source code)
- %% confused we the internal instruction. (Reason: (2) above +
- %% code bloat.)
- %% (4) Xref may be run on the abstract code, so the name in the
- %% abstract code must be erlang:is_record/3.
- %% (5) To achive both (3) and (4) at the same time, set the name
- %% here to erlang:is_record/3, but mark it as compiler-generated.
- %% The v3_core pass will change the name to erlang:internal_is_record/3.
- Fs = record_fields(Name, St),
- expr({call,-Line,{remote,-Line,{atom,-Line,erlang},{atom,-Line,is_record}},
- [Term,{atom,Line,Name},{integer,Line,length(Fs)+1}]},
- Vs, St).
-
-record_test_in_body(Line, Expr, Name, Vs, St0) ->
- %% As Expr may have side effects, we must evaluate it
- %% first and bind the value to a new variable.
- %% We must use also handle the case that Expr does not
- %% evaluate to a tuple properly.
- Fs = record_fields(Name, St0),
- {Var,St} = new_var(Line, St0),
-
- expr({block,Line,
- [{match,Line,Var,Expr},
- {op,Line,
- 'andalso',
- {call,Line,{atom,Line,is_tuple},[Var]},
- {op,Line,'andalso',
- {op,Line,'=:=',
- {call,Line,{atom,Line,size},[Var]},
- {integer,Line,length(Fs)+1}},
- {op,Line,'=:=',
- {call,Line,{atom,Line,element},[{integer,Line,1},Var]},
- {atom,Line,Name}}}}]}, Vs, St).
-
-normalise_test(atom, 1) -> is_atom;
-normalise_test(binary, 1) -> is_binary;
-normalise_test(constant, 1) -> is_constant;
-normalise_test(float, 1) -> is_float;
-normalise_test(function, 1) -> is_function;
-normalise_test(integer, 1) -> is_integer;
-normalise_test(list, 1) -> is_list;
-normalise_test(number, 1) -> is_number;
-normalise_test(pid, 1) -> is_pid;
-normalise_test(port, 1) -> is_port;
-normalise_test(reference, 1) -> is_reference;
-normalise_test(tuple, 1) -> is_tuple;
-normalise_test(Name, _) -> Name.
-
-%% exprs(Expressions, VisibleVariables, State) ->
-%% {TransformedExprs,NewVariables,UsedVariables,State'}
-
-exprs([E0|Es0], Vs, St0) ->
- {E,Evs,Eus,St1} = expr(E0, Vs, St0),
- {Es,Esvs,Esus,St2} = exprs(Es0, union(Evs, Vs), St1),
- {[E|Es],union(Evs, Esvs),union(Eus, Esus),St2};
-exprs([], _, St) -> {[],[],[],St}.
-
-%% expr(Expression, VisibleVariables, State) ->
-%% {TransformedExpression,NewVariables,UsedVariables,State'}
-
-expr({var,_,V}=Var, _Vs, St) ->
- {Var,[],[V],St};
-expr({char,_,_}=Char, _Vs, St) ->
- {Char,[],[],St};
-expr({integer,_,_}=Int, _Vs, St) ->
- {Int,[],[],St};
-expr({float,_,_}=Float, _Vs, St) ->
- {Float,[],[],St};
-expr({atom,_,_}=Atom, _Vs, St) ->
- {Atom,[],[],St};
-expr({string,_,_}=String, _Vs, St) ->
- {String,[],[],St};
-expr({nil,_}=Nil, _Vs, St) ->
- {Nil,[],[],St};
-expr({cons,Line,H0,T0}, Vs, St0) ->
- {H,Hvs,Hus,St1} = expr(H0, Vs, St0),
- {T,Tvs,Tus,St2} = expr(T0, Vs, St1),
- {{cons,Line,H,T},union(Hvs, Tvs),union(Hus, Tus),St2};
-expr({lc,Line,E0,Qs0}, Vs, St0) ->
- {E1,Qs1,_,Lvs,Lus,St1} = lc_tq(Line, E0, Qs0, {nil,Line}, Vs, St0),
- {{lc,Line,E1,Qs1},Lvs,Lus,St1};
-expr({tuple,Line,Es0}, Vs, St0) ->
- {Es1,Esvs,Esus,St1} = expr_list(Es0, Vs, St0),
- {{tuple,Line,Es1},Esvs,Esus,St1};
-%%expr({struct,Line,Tag,Es0}, Vs, St0) ->
-%% {Es1,Esvs,Esus,St1} = expr_list(Es0, Vs, St0),
-%% {{tuple,Line,[{atom,Line,Tag}|Es1]},Esvs,Esus,St1};
-expr({record_field,_,_,_}=M, _Vs, St) ->
- {expand_package(M, St), [], [], St}; % must be a package name
-expr({record_index,Line,Name,F}, Vs, St) ->
- I = index_expr(Line, F, Name, record_fields(Name, St)),
- expr(I, Vs, St);
-expr({record,Line,Name,Is}, Vs, St) ->
- expr({tuple,Line,[{atom,Line,Name}|
- record_inits(record_fields(Name, St), Is)]},
- Vs, St);
-expr({record_field,Line,R,Name,F}, Vs, St) ->
- I = index_expr(Line, F, Name, record_fields(Name, St)),
- expr({call,Line,{atom,Line,element},[I,R]}, Vs, St);
-expr({record,_,R,Name,Us}, Vs, St0) ->
- {Ue,St1} = record_update(R, Name, record_fields(Name, St0), Us, St0),
- expr(Ue, Vs, St1);
-expr({bin,Line,Es0}, Vs, St0) ->
- {Es1,Esvs,Esus,St1} = expr_bin(Es0, Vs, St0),
- {{bin,Line,Es1},Esvs,Esus,St1};
-expr({block,Line,Es0}, Vs, St0) ->
- {Es,Esvs,Esus,St1} = exprs(Es0, Vs, St0),
- {{block,Line,Es},Esvs,Esus,St1};
-expr({'if',Line,Cs0}, Vs, St0) ->
- {Cs,Csvss,Csuss,St1} = icr_clauses(Cs0, Vs, St0),
- All = new_in_all(Vs, Csvss),
- {{'if',Line,Cs},All,union(Csuss),St1};
-expr({'case',Line,E0,Cs0}, Vs, St0) ->
- {E,Evs,Eus,St1} = expr(E0, Vs, St0),
- {Cs,Csvss,Csuss,St2} = icr_clauses(Cs0, union(Evs, Vs), St1),
- All = new_in_all(Vs, Csvss),
- {{'case',Line,E,Cs},union(Evs, All),union([Eus|Csuss]),St2};
-expr({'cond',Line,Cs}, Vs, St0) ->
- {V,St1} = new_var(Line,St0),
- expr(cond_clauses(Cs,V), Vs, St1);
-expr({'receive',Line,Cs0}, Vs, St0) ->
- {Cs,Csvss,Csuss,St1} = icr_clauses(Cs0, Vs, St0),
- All = new_in_all(Vs, Csvss),
- {{'receive',Line,Cs},All,union(Csuss),St1};
-expr({'receive',Line,Cs0,To0,ToEs0}, Vs, St0) ->
- {To,Tovs,Tous,St1} = expr(To0, Vs, St0),
- {ToEs,ToEsvs,_ToEsus,St2} = exprs(ToEs0, Vs, St1),
- {Cs,Csvss,Csuss,St3} = icr_clauses(Cs0, Vs, St2),
- All = new_in_all(Vs, [ToEsvs|Csvss]),
- {{'receive',Line,Cs,To,ToEs},union(Tovs, All),union([Tous|Csuss]),St3};
-expr({'fun',Line,Body}, Vs, St) ->
- fun_tq(Line, Body, Vs, St);
-%%% expr({call,_,{atom,La,this_module},[]}, _Vs, St) ->
-%%% {{atom,La,St#expand.module}, [], [], St};
-%%% expr({call,_,{atom,La,this_package},[]}, _Vs, St) ->
-%%% {{atom,La,list_to_atom(St#expand.package)}, [], [], St};
-%%% expr({call,_,{atom,La,this_package},[{atom,_,Name}]}, _Vs, St) ->
-%%% M = packages:concat(St#expand.package,Name),
-%%% {{atom,La,list_to_atom(M)}, [], [], St};
-%%% expr({call,Line,{atom,La,this_package},[A]}, Vs, St) ->
-%%% M = {call,Line,{remote,La,{atom,La,packages},{atom,La,concat}},
-%%% [{string,La,St#expand.package}, A]},
-%%% expr({call,Line,{atom,Line,list_to_atom},[M]}, Vs, St);
-expr({call,Line,{atom,_,is_record},[A,{atom,_,Name}]}, Vs, St) ->
- record_test(Line, A, Name, Vs, St);
-expr({call,Line,{remote,_,{atom,_,erlang},{atom,_,is_record}},
- [A,{atom,_,Name}]}, Vs, St) ->
- record_test(Line, A, Name, Vs, St);
-expr({call,Line,{atom,La,N},As0}, Vs, St0) ->
- {As,Asvs,Asus,St1} = expr_list(As0, Vs, St0),
- Ar = length(As),
- case erl_internal:bif(N, Ar) of
- true ->
- {{call,Line,{remote,La,{atom,La,erlang},{atom,La,N}},As},
- Asvs,Asus,St1};
- false ->
- case imported(N, Ar, St1) of
- {yes,Mod} ->
- {{call,Line,{remote,La,{atom,La,Mod},{atom,La,N}},As},
- Asvs,Asus,St1};
- no ->
- case {N,Ar} of
- {record_info,2} ->
- record_info_call(Line, As, St1);
- _ ->
- {{call,Line,{atom,La,N},As},Asvs,Asus,St1}
- end
- end
- end;
-expr({call,Line,{record_field,_,_,_}=M,As0}, Vs, St0) ->
- expr({call,Line,expand_package(M, St0),As0}, Vs, St0);
-expr({call,Line,{remote,Lr,M,F},As0}, Vs, St0) ->
- M1 = expand_package(M, St0),
- {[M2,F1|As1],Asvs,Asus,St1} = expr_list([M1,F|As0], Vs, St0),
- {{call,Line,{remote,Lr,M2,F1},As1},Asvs,Asus,St1};
-expr({call,Line,{tuple,_,[{atom,_,_}=M,{atom,_,_}=F]},As}, Vs, St) ->
- %% Rewrite {Mod,Function}(Args...) to Mod:Function(Args...).
- expr({call,Line,{remote,Line,M,F},As}, Vs, St);
-expr({call,Line,F,As0}, Vs, St0) ->
- {[Fun1|As1],Asvs,Asus,St1} = expr_list([F|As0], Vs, St0),
- {{call,Line,Fun1,As1},Asvs,Asus,St1};
-expr({'try',Line,Es0,Scs0,Ccs0,As0}, Vs, St0) ->
- {Es1,Esvs,Esus,St1} = exprs(Es0, Vs, St0),
- Cvs = union(Esvs, Vs),
- {Scs1,Scsvss,Scsuss,St2} = icr_clauses(Scs0, Cvs, St1),
- {Ccs1,Ccsvss,Ccsuss,St3} = icr_clauses(Ccs0, Cvs, St2),
- Csvss = Scsvss ++ Ccsvss,
- Csuss = Scsuss ++ Ccsuss,
- All = new_in_all(Vs, Csvss),
- {As1,Asvs,Asus,St4} = exprs(As0, Cvs, St3),
- {{'try',Line,Es1,Scs1,Ccs1,As1}, union([Asvs,Esvs,All]),
- union([Esus,Asus|Csuss]), St4};
-expr({'catch',Line,E0}, Vs, St0) ->
- %% Catch exports no new variables.
- {E,_Evs,Eus,St1} = expr(E0, Vs, St0),
- {{'catch',Line,E},[],Eus,St1};
-expr({match,Line,P0,E0}, Vs, St0) ->
- {E,Evs,Eus,St1} = expr(E0, Vs, St0),
- {P,Pvs,Pus,St2} = pattern(P0, St1),
- {{match,Line,P,E},
- union(subtract(Pvs, Vs), Evs),
- union(intersection(Pvs, Vs), union(Eus,Pus)),St2};
-expr({op,L,'andalso',E1,E2}, Vs, St0) ->
- {V,St1} = new_var(L,St0),
- E = make_bool_switch(L,E1,V,
- make_bool_switch(L,E2,V,{atom,L,true},
- {atom,L,false}),
- {atom,L,false}),
- expr(E, Vs, St1);
-expr({op,L,'orelse',E1,E2}, Vs, St0) ->
- {V,St1} = new_var(L,St0),
- E = make_bool_switch(L,E1,V,{atom,L,true},
- make_bool_switch(L,E2,V,{atom,L,true},
- {atom,L,false})),
- expr(E, Vs, St1);
-expr({op,Line,'++',{lc,Ll,E0,Qs0},M0}, Vs, St0) ->
- {E1,Qs1,M1,Lvs,Lus,St1} = lc_tq(Ll, E0, Qs0, M0, Vs, St0),
- {{op,Line,'++',{lc,Ll,E1,Qs1},M1},Lvs,Lus,St1};
-expr({op,_,'++',{string,L1,S1},{string,_,S2}}, _Vs, St) ->
- {{string,L1,S1 ++ S2},[],[],St};
-expr({op,Ll,'++',{string,L1,S1}=Str,R0}, Vs, St0) ->
- {R1,Rvs,Rus,St1} = expr(R0, Vs, St0),
- E = case R1 of
- {string,_,S2} -> {string,L1,S1 ++ S2};
- _Other when length(S1) < 8 -> string_to_conses(L1, S1, R1);
- _Other -> {op,Ll,'++',Str,R1}
- end,
- {E,Rvs,Rus,St1};
-expr({op,Ll,'++',{cons,Lc,H,T},L2}, Vs, St) ->
- expr({cons,Ll,H,{op,Lc,'++',T,L2}}, Vs, St);
-expr({op,_,'++',{nil,_},L2}, Vs, St) ->
- expr(L2, Vs, St);
-expr({op,Line,Op,A0}, Vs, St0) ->
- {A,Avs,Aus,St1} = expr(A0, Vs, St0),
- {{op,Line,Op,A},Avs,Aus,St1};
-expr({op,Line,Op,L0,R0}, Vs, St0) ->
- {L,Lvs,Lus,St1} = expr(L0, Vs, St0),
- {R,Rvs,Rus,St2} = expr(R0, Vs, St1),
- {{op,Line,Op,L,R},union(Lvs, Rvs),union(Lus, Rus),St2}.
-
-expr_list([E0|Es0], Vs, St0) ->
- {E,Evs,Eus,St1} = expr(E0, Vs, St0),
- {Es,Esvs,Esus,St2} = expr_list(Es0, Vs, St1),
- {[E|Es],union(Evs, Esvs),union(Eus, Esus),St2};
-expr_list([], _, St) ->
- {[],[],[],St}.
-
-%% icr_clauses([Clause], [VisibleVariable], State) ->
-%% {[TransformedClause],[[NewVariable]],[[UsedVariable]],State'}
-%% Be very careful here to return the variables that are really used
-%% and really new.
-
-icr_clauses([], _, St) ->
- {[],[[]],[],St};
-icr_clauses(Clauses, Vs, St) ->
- icr_clauses2(Clauses, Vs, St).
-
-icr_clauses2([{clause,Line,H0,G0,B0}|Cs0], Vs, St0) ->
- {H,Hvs,Hus,St1} = head(H0, St0), %Hvs is really used!
- {G,Gvs,Gus,St2} = guard(G0, union(Hvs, Vs), St1),
- {B,Bvs,Bus,St3} = exprs(B0, union([Vs,Hvs,Gvs]), St2),
- New = subtract(union([Hvs,Gvs,Bvs]), Vs), %Really new
- Used = intersection(union([Hvs,Hus,Gus,Bus]), Vs), %Really used
- {Cs,Csvs,Csus,St4} = icr_clauses2(Cs0, Vs, St3),
- {[{clause,Line,H,G,B}|Cs],[New|Csvs],[Used|Csus],St4};
-icr_clauses2([], _, St) ->
- {[],[],[],St}.
-
-%% lc_tq(Line, Expr, Qualifiers, More, [VisibleVar], State) ->
-%% {TransExpr,[TransQual],TransMore,[NewVar],[UsedVar],State'}
-
-lc_tq(Line, E0, [{generate,Lg,P0,G0}|Qs0], M0, Vs, St0) ->
- {G1,Gvs,Gus,St1} = expr(G0, Vs, St0),
- {P1,Pvs,Pus,St2} = pattern(P0, St1),
- {E1,Qs1,M1,Lvs,Lus,St3} = lc_tq(Line, E0, Qs0, M0, union(Pvs, Vs), St2),
- {E1,[{generate,Lg,P1,G1}|Qs1],M1,
- union(Gvs, Lvs),union([Gus,Pus,Lus]),St3};
-lc_tq(Line, E0, [F0|Qs0], M0, Vs, St0) ->
- %% Allow record/2 and expand out as guard test.
- case erl_lint:is_guard_test(F0) of
- true ->
- {F1,Fvs,_Fus,St1} = guard_tests([F0], Vs, St0),
- {E1,Qs1,M1,Lvs,Lus,St2} = lc_tq(Line, E0, Qs0, M0, union(Fvs, Vs), St1),
- {E1,F1++Qs1,M1,Lvs,Lus,St2};
- false ->
- {F1,Fvs,_Fus,St1} = expr(F0, Vs, St0),
- {E1,Qs1,M1,Lvs,Lus,St2} = lc_tq(Line, E0, Qs0, M0, union(Fvs, Vs), St1),
- {E1,[F1|Qs1],M1,Lvs,Lus,St2}
- end;
-lc_tq(_Line, E0, [], M0, Vs, St0) ->
- {E1,Evs,Eus,St1} = expr(E0, Vs, St0),
- {M1,Mvs,Mus,St2} = expr(M0, Vs, St1),
- {E1,[],M1,union(Evs, Mvs),union(Eus, Mus),St2}.
-
-%% fun_tq(Line, Body, VisibleVariables, State) ->
-%% {Fun,NewVariables,UsedVariables,State'}
-%% Transform an "explicit" fun {'fun', Line, {clauses, Cs}} into an
-%% extended form {'fun', Line, {clauses, Cs}, Info}, unless it is the
-%% name of a BIF (erl_lint has checked that it is not an import).
-%% Process the body sequence directly to get the new and used variables.
-%% "Implicit" funs {'fun', Line, {function, F, A}} are not changed.
-
-fun_tq(Lf, {function,F,A}, Vs, St0) ->
- {As,St1} = new_vars(A, Lf, St0),
- Cs = [{clause,Lf,As,[],[{call,Lf,{atom,Lf,F},As}]}],
- case erl_internal:bif(F, A) of
- true ->
- fun_tq(Lf, {clauses,Cs}, Vs, St1);
- false ->
- Index = St0#expand.fun_index,
- Uniq = erlang:hash(Cs, (1 bsl 27)-1),
- {Fname,St2} = new_fun_name(St1),
- {{'fun',Lf,{function,F,A},{Index,Uniq,Fname}},[],[],
- St2#expand{fun_index=Index+1}}
- end;
-fun_tq(Lf, {clauses,Cs0}, Vs, St0) ->
- Uniq = erlang:hash(Cs0, (1 bsl 27)-1),
- {Cs1,_Hvss,Frees,St1} = fun_clauses(Cs0, Vs, St0),
- Ufrees = union(Frees),
- Index = St1#expand.fun_index,
- {Fname,St2} = new_fun_name(St1),
- {{'fun',Lf,{clauses,Cs1},{Index,Uniq,Fname}},[],Ufrees,
- St2#expand{fun_index=Index+1}}.
-
-fun_clauses([{clause,L,H0,G0,B0}|Cs0], Vs, St0) ->
- {H,Hvs,Hus,St1} = head(H0, St0),
- {G,Gvs,Gus,St2} = guard(G0, union(Hvs, Vs), St1),
- {B,Bvs,Bus,St3} = exprs(B0, union([Vs,Hvs,Gvs]), St2),
- %% Free variables cannot be new anywhere in the clause.
- Free = subtract(union([Gus,Hus,Bus]), union([Hvs,Gvs,Bvs])),
- %%io:format(" Gus :~p~n Bvs :~p~n Bus :~p~n Free:~p~n" ,[Gus,Bvs,Bus,Free]),
- {Cs,Hvss,Frees,St4} = fun_clauses(Cs0, Vs, St3),
- {[{clause,L,H,G,B}|Cs],[Hvs|Hvss],[Free|Frees],St4};
-fun_clauses([], _, St) -> {[],[],[],St}.
-
-%% new_fun_name(State) -> {FunName,State}.
-
-new_fun_name(#expand{func=F,arity=A,fcount=I}=St) ->
- Name = "-" ++ atom_to_list(F) ++ "/" ++ integer_to_list(A)
- ++ "-fun-" ++ integer_to_list(I) ++ "-",
- {list_to_atom(Name),St#expand{fcount=I+1}}.
-
-
-%% normalise_fields([RecDef]) -> [Field].
-%% Normalise the field definitions to always have a default value. If
-%% none has been given then use 'undefined'.
-
-normalise_fields(Fs) ->
- map(fun ({record_field,Lf,Field}) ->
- {record_field,Lf,Field,{atom,Lf,undefined}};
- (F) -> F end, Fs).
-
-%% record_fields(RecordName, State)
-%% find_field(FieldName, Fields)
-
-record_fields(R, St) -> dict:fetch(R, St#expand.records).
-
-find_field(F, [{record_field,_,{atom,_,F},Val}|_]) -> {ok,Val};
-find_field(F, [_|Fs]) -> find_field(F, Fs);
-find_field(_, []) -> error.
-
-%% field_names(RecFields) -> [Name].
-%% Return a list of the field names structures.
-
-field_names(Fs) ->
- map(fun ({record_field,_,Field,_Val}) -> Field end, Fs).
-
-%% index_expr(Line, FieldExpr, Name, Fields) -> IndexExpr.
-%% Return an expression which evaluates to the index of a
-%% field. Currently only handle the case where the field is an
-%% atom. This expansion must be passed through expr again.
-
-index_expr(Line, {atom,_,F}, _Name, Fs) ->
- {integer,Line,index_expr(F, Fs, 2)}.
-
-index_expr(F, [{record_field,_,{atom,_,F},_}|_], I) -> I;
-index_expr(F, [_|Fs], I) ->
- index_expr(F, Fs, I+1).
-
-%% pattern_fields([RecDefField], [Match]) -> [Pattern].
-%% Build a list of match patterns for the record tuple elements.
-%% This expansion must be passed through pattern again. N.B. We are
-%% scanning the record definition field list!
-
-pattern_fields(Fs, Ms) ->
- Wildcard = record_wildcard_init(Ms),
- map(fun ({record_field,L,{atom,_,F},_}) ->
- case find_field(F, Ms) of
- {ok,Match} -> Match;
- error when Wildcard =:= none -> {var,L,'_'};
- error -> Wildcard
- end end,
- Fs).
-
-%% record_inits([RecDefField], [Init]) -> [InitExpr].
-%% Build a list of initialisation expressions for the record tuple
-%% elements. This expansion must be passed through expr
-%% again. N.B. We are scanning the record definition field list!
-
-record_inits(Fs, Is) ->
- WildcardInit = record_wildcard_init(Is),
- map(fun ({record_field,_,{atom,_,F},D}) ->
- case find_field(F, Is) of
- {ok,Init} -> Init;
- error when WildcardInit =:= none -> D;
- error -> WildcardInit
- end end,
- Fs).
-
-record_wildcard_init([{record_field,_,{var,_,'_'},D}|_]) -> D;
-record_wildcard_init([_|Is]) -> record_wildcard_init(Is);
-record_wildcard_init([]) -> none.
-
-%% record_update(Record, RecordName, [RecDefField], [Update], State) ->
-%% {Expr,State'}
-%% Build an expression to update fields in a record returning a new
-%% record. Try to be smart and optimise this. This expansion must be
-%% passed through expr again.
-
-record_update(R, Name, Fs, Us0, St0) ->
- Line = element(2, R),
- {Pre,Us,St1} = record_exprs(Us0, St0),
- Nf = length(Fs), %# of record fields
- Nu = length(Us), %# of update fields
- Nc = Nf - Nu, %# of copy fields
-
- %% We need a new variable for the record expression
- %% to guarantee that it is only evaluated once.
- {Var,St2} = new_var(Line, St1),
-
- %% Try to be intelligent about which method of updating record to use.
- {Update,St} =
- if
- Nu == 0 -> {R,St2}; %No fields updated
- Nu =< Nc -> %Few fields updated
- {record_setel(Var, Name, Fs, Us), St2};
- true -> %The wide area inbetween
- record_match(Var, Name, Fs, Us, St2)
- end,
- {{block,element(2, R),Pre ++ [{match,Line,Var,R},Update]},St}.
-
-%% record_match(Record, RecordName, [RecDefField], [Update], State)
-%% Build a 'case' expression to modify record fields.
-
-record_match(R, Name, Fs, Us, St0) ->
- {Ps,News,St1} = record_upd_fs(Fs, Us, St0),
- Lr = element(2, hd(Us)),
- {{'case',Lr,R,
- [{clause,Lr,[{tuple,Lr,[{atom,Lr,Name}|Ps]}],[],
- [{tuple,Lr,[{atom,Lr,Name}|News]}]},
- {clause,Lr,[{var,Lr,'_'}],[],
- [call_error(Lr, {tuple,Lr,[{atom,Lr,badrecord},{atom,Lr,Name}]})]}
- ]},
- St1}.
-
-record_upd_fs([{record_field,Lf,{atom,_La,F},_Val}|Fs], Us, St0) ->
- {P,St1} = new_var(Lf, St0),
- {Ps,News,St2} = record_upd_fs(Fs, Us, St1),
- case find_field(F, Us) of
- {ok,New} -> {[P|Ps],[New|News],St2};
- error -> {[P|Ps],[P|News],St2}
- end;
-record_upd_fs([], _, St) -> {[],[],St}.
-
-%% record_setel(Record, RecordName, [RecDefField], [Update])
-%% Build a nested chain of setelement calls to build the
-%% updated record tuple.
-
-record_setel(R, Name, Fs, Us0) ->
- Us1 = foldl(fun ({record_field,Lf,Field,Val}, Acc) ->
- I = index_expr(Lf, Field, Name, Fs),
- [{I,Lf,Val}|Acc]
- end, [], Us0),
- Us = sort(Us1),
- Lr = element(2, hd(Us)),
- Wildcards = duplicate(length(Fs), {var,Lr,'_'}),
- {'case',Lr,R,
- [{clause,Lr,[{tuple,Lr,[{atom,Lr,Name}|Wildcards]}],[],
- [foldr(fun ({I,Lf,Val}, Acc) ->
- {call,Lf,{atom,Lf,setelement},[I,Acc,Val]} end,
- R, Us)]},
- {clause,Lr,[{var,Lr,'_'}],[],
- [call_error(Lr, {tuple,Lr,[{atom,Lr,badrecord},{atom,Lr,Name}]})]}]}.
-
-%% Expand a call to record_info/2. We have checked that it is not
-%% shadowed by an import.
-
-record_info_call(Line, [{atom,_Li,Info},{atom,_Ln,Name}], St) ->
- case Info of
- size ->
- {{integer,Line,1+length(record_fields(Name, St))},[],[],St};
- fields ->
- {make_list(field_names(record_fields(Name, St)), Line),
- [],[],St}
- end.
-
-%% Break out expressions from an record update list and bind to new
-%% variables. The idea is that we will evaluate all update expressions
-%% before starting to update the record.
-
-record_exprs(Us, St) ->
- record_exprs(Us, St, [], []).
-
-record_exprs([{record_field,Lf,{atom,_La,_F}=Name,Val}=Field0|Us], St0, Pre, Fs) ->
- case is_simple_val(Val) of
- true ->
- record_exprs(Us, St0, Pre, [Field0|Fs]);
- false ->
- {Var,St} = new_var(Lf, St0),
- Bind = {match,Lf,Var,Val},
- Field = {record_field,Lf,Name,Var},
- record_exprs(Us, St, [Bind|Pre], [Field|Fs])
- end;
-record_exprs([], St, Pre, Fs) ->
- {reverse(Pre),Fs,St}.
-
-is_simple_val({var,_,_}) -> true;
-is_simple_val({atom,_,_}) -> true;
-is_simple_val({integer,_,_}) -> true;
-is_simple_val({float,_,_}) -> true;
-is_simple_val({nil,_}) -> true;
-is_simple_val(_) -> false.
-
-%% pattern_bin([Element], State) -> {[Element],[Variable],[UsedVar],State}.
-
-pattern_bin(Es0, St) ->
- Es1 = bin_expand_strings(Es0),
- foldr(fun (E, Acc) -> pattern_element(E, Acc) end, {[],[],[],St}, Es1).
-
-pattern_element({bin_element,Line,Expr,Size,Type}, {Es,Esvs,Esus,St0}) ->
- {Expr1,Vs1,Us1,St1} = pattern(Expr, St0),
- {Size1,Vs2,Us2,St2} = pat_bit_size(Size, St1),
- {Size2,Type1} = make_bit_type(Line, Size1,Type),
- {[{bin_element,Line,Expr1,Size2,Type1}|Es],
- union([Vs1,Vs2,Esvs]),union([Us1,Us2,Esus]),St2}.
-
-pat_bit_size(default, St) -> {default,[],[],St};
-pat_bit_size({atom,_La,all}=All, St) -> {All,[],[],St};
-pat_bit_size({var,_Lv,V}=Var, St) -> {Var,[],[V],St};
-pat_bit_size(Size, St) ->
- Line = element(2, Size),
- {value,Sz,_} = erl_eval:expr(Size, erl_eval:new_bindings()),
- {{integer,Line,Sz},[],[],St}.
-
-make_bit_type(Line, default, Type0) ->
- case erl_bits:set_bit_type(default, Type0) of
- {ok,all,Bt} -> {{atom,Line,all},erl_bits:as_list(Bt)};
- {ok,Size,Bt} -> {{integer,Line,Size},erl_bits:as_list(Bt)}
- end;
-make_bit_type(_Line, Size, Type0) -> %Integer or 'all'
- {ok,Size,Bt} = erl_bits:set_bit_type(Size, Type0),
- {Size,erl_bits:as_list(Bt)}.
-
-%% expr_bin([Element], [VisibleVar], State) ->
-%% {[Element],[NewVar],[UsedVar],State}.
-
-expr_bin(Es0, Vs, St) ->
- Es1 = bin_expand_strings(Es0),
- foldr(fun (E, Acc) -> bin_element(E, Vs, Acc) end, {[],[],[],St}, Es1).
-
-bin_element({bin_element,Line,Expr,Size,Type}, Vs, {Es,Esvs,Esus,St0}) ->
- {Expr1,Vs1,Us1,St1} = expr(Expr, Vs, St0),
- {Size1,Vs2,Us2,St2} = if Size == default -> {default,[],[],St1};
- true -> expr(Size, Vs, St1)
- end,
- {Size2,Type1} = make_bit_type(Line, Size1, Type),
- {[{bin_element,Line,Expr1,Size2,Type1}|Es],
- union([Vs1,Vs2,Esvs]),union([Us1,Us2,Esus]),St2}.
-
-bin_expand_strings(Es) ->
- foldr(fun ({bin_element,Line,{string,_,S},default,default}, Es1) ->
- foldr(fun (C, Es2) ->
- [{bin_element,Line,{char,Line,C},default,default}|Es2]
- end, Es1, S);
- (E, Es1) -> [E|Es1]
- end, [], Es).
-
-%% new_var_name(State) -> {VarName,State}.
-
-new_var_name(St) ->
- C = St#expand.vcount,
- {list_to_atom("pre" ++ integer_to_list(C)),St#expand{vcount=C+1}}.
-
-%% new_var(Line, State) -> {Var,State}.
-
-new_var(L, St0) ->
- {New,St1} = new_var_name(St0),
- {{var,L,New},St1}.
-
-%% new_vars(Count, Line, State) -> {[Var],State}.
-%% Make Count new variables.
-
-new_vars(N, L, St) -> new_vars(N, L, St, []).
-
-new_vars(N, L, St0, Vs) when N > 0 ->
- {V,St1} = new_var(L, St0),
- new_vars(N-1, L, St1, [V|Vs]);
-new_vars(0, _L, St, Vs) -> {Vs,St}.
-
-%% make_list(TermList, Line) -> ConsTerm.
-
-make_list(Ts, Line) ->
- foldr(fun (H, T) -> {cons,Line,H,T} end, {nil,Line}, Ts).
-
-string_to_conses(Line, Cs, Tail) ->
- foldr(fun (C, T) -> {cons,Line,{char,Line,C},T} end, Tail, Cs).
-
-
-%% In syntax trees, module/package names are atoms or lists of atoms.
-
-package_to_string(A) when atom(A) -> atom_to_list(A);
-package_to_string(L) when list(L) -> packages:concat(L).
-
-expand_package({atom,L,A} = M, St) ->
- case dict:find(A, St#expand.mod_imports) of
- {ok, A1} ->
- {atom,L,A1};
- error ->
- case packages:is_segmented(A) of
- true ->
- M;
- false ->
- M1 = packages:concat(St#expand.package, A),
- {atom,L,list_to_atom(M1)}
- end
- end;
-expand_package(M, _St) ->
- case erl_parse:package_segments(M) of
- error ->
- M;
- M1 ->
- {atom,element(2,M),list_to_atom(package_to_string(M1))}
- end.
-
-%% Create a case-switch on true/false, generating badarg for all other
-%% values.
-
-make_bool_switch(L, E, V, T, F) ->
- make_bool_switch_1(L, E, V, [T], [F]).
-
-make_bool_switch_1(L, E, V, T, F) ->
- case get(sys_pre_expand_in_guard) of
- undefined -> make_bool_switch_body(L, E, V, T, F);
- yes -> make_bool_switch_guard(L, E, V, T, F)
- end.
-
-make_bool_switch_guard(_, E, _, [{atom,_,true}], [{atom,_,false}]) -> E;
-make_bool_switch_guard(L, E, V, T, F) ->
- NegL = -abs(L),
- {'case',NegL,E,
- [{clause,NegL,[{atom,NegL,true}],[],T},
- {clause,NegL,[{atom,NegL,false}],[],F},
- {clause,NegL,[V],[],[V]}
- ]}.
-
-make_bool_switch_body(L, E, V, T, F) ->
- NegL = -abs(L),
- {'case',NegL,E,
- [{clause,NegL,[{atom,NegL,true}],[],T},
- {clause,NegL,[{atom,NegL,false}],[],F},
- {clause,NegL,[V],[],
- [call_error(NegL,{tuple,NegL,[{atom,NegL,badarg},V]})]}
- ]}.
-
-%% Expand a list of cond-clauses to a sequence of case-switches.
-
-cond_clauses([{clause,L,[],[[E]],B}],V) ->
- make_bool_switch_1(L,E,V,B,[call_error(L,{atom,L,cond_clause})]);
-cond_clauses([{clause,L,[],[[E]],B} | Cs],V) ->
- make_bool_switch_1(L,E,V,B,[cond_clauses(Cs,V)]).
-
-%% call_error(Line, Reason) -> Expr.
-%% Build a call to erlang:error/1 with reason Reason.
-
-call_error(L, R) ->
- {call,L,{remote,L,{atom,L,erlang},{atom,L,error}},[R]}.
-
-%% new_in_all(Before, RegionList) -> NewInAll
-%% Return the variables new in all clauses.
-
-new_in_all(Before, Region) ->
- InAll = intersection(Region),
- subtract(InAll, Before).
-
-%% import(Line, Imports, State) ->
-%% State'
-%% imported(Name, Arity, State) ->
-%% {yes,Module} | no
-%% Handle import declarations and est for imported functions. No need to
-%% check when building imports as code is correct.
-
-import({Mod0,Fs}, St) ->
- Mod = list_to_atom(package_to_string(Mod0)),
- Mfs = from_list(Fs),
- St#expand{imports=add_imports(Mod, Mfs, St#expand.imports)};
-import(Mod0, St) ->
- Mod = package_to_string(Mod0),
- Key = list_to_atom(packages:last(Mod)),
- St#expand{mod_imports=dict:store(Key, list_to_atom(Mod),
- St#expand.mod_imports)}.
-
-add_imports(Mod, [F|Fs], Is) ->
- add_imports(Mod, Fs, orddict:store(F, Mod, Is));
-add_imports(_, [], Is) -> Is.
-
-imported(F, A, St) ->
- case orddict:find({F,A}, St#expand.imports) of
- {ok,Mod} -> {yes,Mod};
- error -> no
- end.
diff --git a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/v3_codegen.erl b/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/v3_codegen.erl
deleted file mode 100644
index 2af4d94655..0000000000
--- a/lib/dialyzer/test/options1_tests_SUITE_data/src/compiler/v3_codegen.erl
+++ /dev/null
@@ -1,1755 +0,0 @@
-%% ``The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved via the world wide web at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
-%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
-%% AB. All Rights Reserved.''
-%%
-%% $Id: v3_codegen.erl,v 1.1 2008/12/17 09:53:42 mikpe Exp $
-%%
-%% Purpose : Code generator for Beam.
-
-%% The following assumptions have been made:
-%%
-%% 1. Matches, i.e. things with {match,M,Ret} wrappers, only return
-%% values; no variables are exported. If the match would have returned
-%% extra variables then these have been transformed to multiple return
-%% values.
-%%
-%% 2. All BIF's called in guards are gc-safe so there is no need to
-%% put thing on the stack in the guard. While this would in principle
-%% work it would be difficult to keep track of the stack depth when
-%% trimming.
-%%
-%% The code generation uses variable lifetime information added by
-%% the v3_life module to save variables, allocate registers and
-%% move registers to the stack when necessary.
-%%
-%% We try to use a consistent variable name scheme throughout. The
-%% StackReg record is always called Bef,Int