1cerl(3)                    Erlang Module Definition                    cerl(3)
2
3
4

NAME

6       cerl - Core Erlang abstract syntax trees.
7

DESCRIPTION

9       Core Erlang abstract syntax trees.
10
11       This  module defines an abstract data type for representing Core Erlang
12       source code as syntax trees.
13
14       A recommended starting point for the first-time user is the  documenta‐
15       tion of the function type/1.
16
17       NOTES:
18
19       This  module  deals with the composition and decomposition of syntactic
20       entities (as opposed to semantic ones); its purpose is to hide all  di‐
21       rect  references  to  the data structures used to represent these enti‐
22       ties. With few exceptions, the functions in this module perform no  se‐
23       mantic  interpretation of their inputs, and in general, the user is as‐
24       sumed to pass type-correct arguments - if this is not done, the effects
25       are not defined.
26
27       Currently,  the internal data structure used is the same as the record-
28       based data structures used traditionally in the Beam compiler.
29
30       The internal representations of abstract syntax trees  are  subject  to
31       change  without  notice, and should not be documented outside this mod‐
32       ule. Furthermore, we do not give any guarantees on how an abstract syn‐
33       tax  tree may or may not be represented, with the following exceptions:
34       no syntax tree is represented by a single atom, such as none, by a list
35       constructor  [X  |  Y],  or by the empty list []. This can be relied on
36       when writing functions that operate on syntax trees.
37

DATA TYPES

39         c_binary() = #c_binary{}:
40
41
42         c_bitstr() = #c_bitstr{}:
43
44
45         c_call() = #c_call{}:
46
47
48         c_clause() = #c_clause{}:
49
50
51         c_cons() = #c_cons{}:
52
53
54         c_fun() = #c_fun{}:
55
56
57         c_let() = #c_let{}:
58
59
60         c_literal() = #c_literal{}:
61
62
63         c_map() = #c_map{}:
64
65
66         c_map_pair() = #c_map_pair{}:
67
68
69         c_module() = #c_module{}:
70
71
72         c_tuple() = #c_tuple{}:
73
74
75         c_values() = #c_values{}:
76
77
78         c_var() = #c_var{}:
79
80
81         cerl():
82
83
84           An abstract Core Erlang syntax tree.
85
86           Every abstract syntax tree  has  a  type,  given  by  the  function
87           type/1.  In  addition,  each syntax tree has a list of user annota‐
88           tions (cf. get_ann/1), which are included in the Core  Erlang  syn‐
89           tax.
90
91         map_op() = #c_literal{val=assoc} | #c_literal{val=exact}:
92
93
94         var_name() = integer() | atom() | {atom(), integer()}:
95
96

EXPORTS

98       abstract(Term::term()) -> cerl()
99
100              Creates a syntax tree corresponding to an Erlang term. Term must
101              be a literal term, i.e., one that can be represented as a source
102              code  literal.  Thus,  it  may not contain a process identifier,
103              port, reference, binary or function value as a subterm.
104
105              Note: This is a constant time operation.
106
107              See  also:  ann_abstract/2,  concrete/1,  is_literal/1,  is_lit‐
108              eral_term/1.
109
110       add_ann(Annotations::[term()], Node::cerl()) -> cerl()
111
112              Appends Annotations to the list of user annotations of Node.
113
114              Note:   this  is  equivalent  to  set_ann(Node,  Annotations  ++
115              get_ann(Node)), but potentially more efficient.
116
117              See also: get_ann/1, set_ann/2.
118
119       alias_pat(Node::cerl()) -> cerl()
120
121              Returns the pattern subtree of an abstract pattern alias.
122
123              See also: c_alias/2.
124
125       alias_var(Node::cerl()) -> cerl()
126
127              Returns the variable subtree of an abstract pattern alias.
128
129              See also: c_alias/2.
130
131       ann_abstract(Annotations::[term()], Term::term()) -> cerl()
132
133              See also: abstract/1.
134
135       ann_c_alias(As::[term()], Variable::cerl(), Pattern::cerl()) -> cerl()
136
137              See also: c_alias/2.
138
139       ann_c_apply(As::[term()],  Operator::cerl(),  Arguments::[cerl()])   ->
140       cerl()
141
142              See also: c_apply/2.
143
144       ann_c_atom(As::[term()], Name) -> cerl()
145
146              Types:
147
148                 Name = atom() | string()
149
150              See also: c_atom/1.
151
152       ann_c_binary(As::[term()], Segments::[cerl()]) -> cerl()
153
154              See also: c_binary/1.
155
156       ann_c_bitstr(As::[term()],  Value::cerl(),  Size::cerl(), Type::cerl(),
157       Flags::cerl()) -> cerl()
158
159              Equivalent to ann_c_bitstr(As, Value, Size,  abstract(1),  Type,
160              Flags).
161
162       ann_c_bitstr(As::[term()],  Value::cerl(),  Size::cerl(), Unit::cerl(),
163       Type::cerl(), Flags::cerl()) -> cerl()
164
165              See also: ann_c_bitstr/5, c_bitstr/5.
166
167       ann_c_call(As::[term()],    Module::cerl(),     Name::cerl(),     Argu‐
168       ments::[cerl()]) -> cerl()
169
170              See also: c_call/3.
171
172       ann_c_case(As::[term()], Argument::cerl(), Clauses::[cerl()]) -> cerl()
173
174              See also: c_case/2.
175
176       ann_c_catch(As::[term()], Body::cerl()) -> cerl()
177
178              See also: c_catch/1.
179
180       ann_c_char(As::[term()], Value::char()) -> cerl()
181
182              See also: c_char/1.
183
184       ann_c_clause(As::[term()], Patterns::[cerl()], Body::cerl()) -> cerl()
185
186              Equivalent to ann_c_clause(As, Patterns, c_atom(true), Body).
187
188              See also: c_clause/3.
189
190       ann_c_clause(As::[term()],      Patterns::[cerl()],      Guard::cerl(),
191       Body::cerl()) -> cerl()
192
193              See also: ann_c_clause/3, c_clause/3.
194
195       ann_c_cons(As::[term()], Head::cerl(), Tail::cerl()) -> cerl()
196
197              See also: c_cons/2.
198
199       ann_c_cons_skel(As::[term()], Head::cerl(), Tail::cerl()) -> cerl()
200
201              See also: c_cons_skel/2.
202
203       ann_c_float(As::[term()], Value::float()) -> cerl()
204
205              See also: c_float/1.
206
207       ann_c_fname(As::[term()], Name::atom(), Arity::arity()) -> cerl()
208
209              Equivalent to ann_c_var(As, {Atom, Arity}).
210
211              See also: c_fname/2.
212
213       ann_c_fun(As::[term()], Variables::[cerl()], Body::cerl()) -> cerl()
214
215              See also: c_fun/2.
216
217       ann_c_int(As::[term()], Value::integer()) -> cerl()
218
219              See also: c_int/1.
220
221       ann_c_let(As::[term()],     Variables::[cerl()],      Argument::cerl(),
222       Body::cerl()) -> c_let()
223
224              See also: c_let/3.
225
226       ann_c_letrec(As::[term()],       Definitions::[{cerl(),       cerl()}],
227       Body::cerl()) -> cerl()
228
229              See also: c_letrec/2.
230
231       ann_c_map(As::[term()], Es::[c_map_pair()]) -> c_map() | c_literal()
232
233       ann_c_map(As::[term()],     C_literal::c_map()      |      c_literal(),
234       Es::[c_map_pair()]) -> c_map() | c_literal()
235
236       ann_c_map_pair(As::[term()],   Op::cerl(),   K::cerl(),  V::cerl())  ->
237       c_map_pair()
238
239       ann_c_map_pattern(As::[term()], Pairs::[c_map_pair()]) -> c_map()
240
241       ann_c_module(As::[term()], Name::cerl(), Exports,  Es::Definitions)  ->
242       cerl()
243
244              Types:
245
246                 Exports = [cerl()]
247                 Definitions = [{cerl(), cerl()}]
248
249              See also: ann_c_module/5, c_module/3.
250
251       ann_c_module(As::[term()],  Name::cerl(),  Exports,  Attrs::Attributes,
252       Es::Definitions) -> cerl()
253
254              Types:
255
256                 Exports = [cerl()]
257                 Attributes = [{cerl(), cerl()}]
258                 Definitions = [{cerl(), cerl()}]
259
260              See also: ann_c_module/4, c_module/4.
261
262       ann_c_nil(As::[term()]) -> cerl()
263
264              See also: c_nil/0.
265
266       ann_c_primop(As::[term()], Name::cerl(), Arguments::[cerl()]) -> cerl()
267
268              See also: c_primop/2.
269
270       ann_c_receive(As::[term()], Clauses::[cerl()]) -> cerl()
271
272              Equivalent  to  ann_c_receive(As,   Clauses,   c_atom(infinity),
273              c_atom(true)).
274
275              See also: c_atom/1, c_receive/3.
276
277       ann_c_receive(As::[term()],   Clauses::[cerl()],  Timeout::cerl(),  Ac‐
278       tion::cerl()) -> cerl()
279
280              See also: ann_c_receive/2, c_receive/3.
281
282       ann_c_seq(As::[term()], Argument::cerl(), Body::cerl()) -> cerl()
283
284              See also: c_seq/2.
285
286       ann_c_string(As::[term()], Value::string()) -> cerl()
287
288              See also: c_string/1.
289
290       ann_c_try(As::[term()],    Expression::cerl(),     Variables::[cerl()],
291       Body::cerl(), EVars::[cerl()], Handler::cerl()) -> cerl()
292
293              See also: c_try/5.
294
295       ann_c_tuple(As::[term()], Elements::[cerl()]) -> cerl()
296
297              See also: c_tuple/1.
298
299       ann_c_tuple_skel(As::[term()], Elements::[cerl()]) -> cerl()
300
301              See also: c_tuple_skel/1.
302
303       ann_c_values(As::[term()], Elements::[cerl()]) -> cerl()
304
305              See also: c_values/1.
306
307       ann_c_var(As::[term()], Name::var_name()) -> cerl()
308
309              See also: c_var/1.
310
311       ann_make_data(As::[term()],   Type::dtype(),   Elements::[cerl()])   ->
312       cerl()
313
314              See also: make_data/2.
315
316       ann_make_data_skel(As::[term()], Type::dtype(), Elements::[cerl()])  ->
317       cerl()
318
319              See also: make_data_skel/2.
320
321       ann_make_list(As::[term()], List::[cerl()]) -> cerl()
322
323              Equivalent to ann_make_list(As, List, none).
324
325       ann_make_list(As::[term()], List::[cerl()], Tail) -> cerl()
326
327              Types:
328
329                 Tail = cerl() | none
330
331              See also: ann_make_list/2, make_list/2.
332
333       ann_make_tree(As::[term()],   Type::ctype(),   Groups::[[cerl()]])   ->
334       cerl()
335
336              Creates a syntax tree with the given annotations, type and  sub‐
337              trees. See make_tree/2 for details.
338
339              See also: make_tree/2.
340
341       apply_args(Node::cerl()) -> [cerl()]
342
343              Returns  the  list  of argument subtrees of an abstract function
344              application.
345
346              See also: apply_arity/1, c_apply/2.
347
348       apply_arity(Node::cerl()) -> arity()
349
350              Returns the number of argument subtrees of an abstract  function
351              application.
352
353              Note: this is equivalent to length(apply_args(Node)), but poten‐
354              tially more efficient.
355
356              See also: apply_args/1, c_apply/2.
357
358       apply_op(Node::cerl()) -> cerl()
359
360              Returns the operator subtree of an  abstract  function  applica‐
361              tion.
362
363              See also: c_apply/2.
364
365       atom_lit(Node::cerl()) -> string()
366
367              Returns the literal string represented by an abstract atom. This
368              always includes surrounding single-quote characters.
369
370              Note that an abstract atom may have several literal  representa‐
371              tions,  and  that the representation yielded by this function is
372              not fixed;  e.g.,  atom_lit(c_atom("a\012b"))  could  yield  the
373              string "\'a\\nb\'".
374
375              See also: c_atom/1.
376
377       atom_name(Node::cerl()) -> string()
378
379              Returns the printname of an abstract atom.
380
381              See also: c_atom/1.
382
383       atom_val(Node::cerl()) -> atom()
384
385              Returns the value represented by an abstract atom.
386
387              See also: c_atom/1.
388
389       binary_segments(Node::cerl()) -> [cerl()]
390
391              Returns  the list of segment subtrees of an abstract binary-tem‐
392              plate.
393
394              See also: c_binary/1, c_bitstr/5.
395
396       bitstr_bitsize(Node::cerl()) -> any | all | utf | integer()
397
398              Returns the total size in bits of an  abstract  bit-string  tem‐
399              plate.  If  the  size field is an integer literal, the result is
400              the product of the size and unit values; if the  size  field  is
401              the  atom  literal all, the atom all is returned. If the size is
402              not a literal, the atom any is returned.
403
404              See also: c_bitstr/5.
405
406       bitstr_flags(Node::cerl()) -> cerl()
407
408              Returns the flags subtree of an abstract bit-string template.
409
410              See also: c_bitstr/5.
411
412       bitstr_size(Node::cerl()) -> cerl()
413
414              Returns the size subtree of an abstract bit-string template.
415
416              See also: c_bitstr/5.
417
418       bitstr_type(Node::cerl()) -> cerl()
419
420              Returns the type subtree of an abstract bit-string template.
421
422              See also: c_bitstr/5.
423
424       bitstr_unit(Node::cerl()) -> cerl()
425
426              Returns the unit subtree of an abstract bit-string template.
427
428              See also: c_bitstr/5.
429
430       bitstr_val(Node::cerl()) -> cerl()
431
432              Returns the value subtree of an abstract bit-string template.
433
434              See also: c_bitstr/5.
435
436       c_alias(Variable::cerl(), Pattern::cerl()) -> cerl()
437
438              Creates an abstract pattern alias. The result represents  "Vari‐
439              able = Pattern".
440
441              See  also:  alias_pat/1, alias_var/1, ann_c_alias/3, c_clause/3,
442              is_c_alias/1, update_c_alias/3.
443
444       c_apply(Operator::cerl(), Arguments::[cerl()]) -> cerl()
445
446              Creates an abstract function application. If Arguments  is  [A1,
447              ..., An], the result represents "apply Operator(A1, ..., An)".
448
449              See   also:   ann_c_apply/3,  apply_args/1,  apply_arity/1,  ap‐
450              ply_op/1, c_call/3, c_primop/2, is_c_apply/1, update_c_apply/3.
451
452       c_atom(Name) -> cerl()
453
454              Types:
455
456                 Name = atom() | string()
457
458              Creates an abstract atom literal. The print name of the atom  is
459              the character sequence represented by Name.
460
461              Note:  passing  a  string  as argument to this function causes a
462              corresponding atom to be created for  the  internal  representa‐
463              tion.
464
465              See  also:  ann_c_atom/2,  atom_lit/1,  atom_name/1, atom_val/1,
466              is_c_atom/1.
467
468       c_binary(Segments::[cerl()]) -> cerl()
469
470              Creates an abstract binary-template. A binary object is in  this
471              context  a  sequence of an arbitrary number of bits. (The number
472              of bits used to be evenly divisible by 8, but after  the  intro‐
473              duction  of  bit  strings in the Erlang language, the choice was
474              made to use the binary template for  all  bit  strings.)  It  is
475              specified  by zero or more bit-string template segments of arbi‐
476              trary lengths (in number of bits). If Segments is [S1, ..., Sn],
477              the  result  represents  "#{S1, ..., Sn}#". All the Si must have
478              type bitstr.
479
480              See   also:   ann_c_binary/2,   binary_segments/1,   c_bitstr/5,
481              is_c_binary/1, update_c_binary/2.
482
483       c_bitstr(Value::cerl(), Type::cerl(), Flags::cerl()) -> cerl()
484
485              Equivalent  to c_bitstr(Value, abstract(all), abstract(1), Type,
486              Flags).
487
488       c_bitstr(Value::cerl(), Size::cerl(), Type::cerl(),  Flags::cerl())  ->
489       cerl()
490
491              Equivalent to c_bitstr(Value, Size, abstract(1), Type, Flags).
492
493       c_bitstr(Value::cerl(),   Size::cerl(),   Unit::cerl(),   Type::cerl(),
494       Flags::cerl()) -> cerl()
495
496              Creates an abstract bit-string template. These can only occur as
497              components  of an abstract binary-template (see c_binary/1). The
498              result represents "#<Value>(Size,  Unit,  Type,  Flags)",  where
499              Unit  must represent a positive integer constant, Type must rep‐
500              resent a constant atom (one of 'integer', 'float', or 'binary'),
501              and  Flags  must represent a constant list "[F1, ..., Fn]" where
502              all the Fi are atoms.
503
504              See also: ann_c_bitstr/6,  bitstr_flags/1,  bitstr_size/1,  bit‐
505              str_type/1,  bitstr_unit/1,  bitstr_val/1, c_binary/1, is_c_bit‐
506              str/1, update_c_bitstr/6.
507
508       c_call(Module::cerl(), Name::cerl(), Arguments::[cerl()]) -> cerl()
509
510              Creates an abstract inter-module call. If Arguments is [A1, ...,
511              An], the result represents "call Module:Name(A1, ..., An)".
512
513              See  also:  ann_c_call/4,  c_apply/2,  c_primop/2,  call_args/1,
514              call_arity/1,  call_module/1,  call_name/1,   is_c_call/1,   up‐
515              date_c_call/4.
516
517       c_case(Argument::cerl(), Clauses::[cerl()]) -> cerl()
518
519              Creates  an  abstract  case-expression.  If Clauses is [C1, ...,
520              Cn], the result represents "case Argument of  C1  ...  Cn  end".
521              Clauses must not be empty.
522
523              See  also:  ann_c_case/3,  c_clause/3, case_arg/1, case_arity/1,
524              case_clauses/1, is_c_case/1, update_c_case/3.
525
526       c_catch(Body::cerl()) -> cerl()
527
528              Creates an  abstract  catch-expression.  The  result  represents
529              "catch Body".
530
531              Note: catch-expressions can be rewritten as try-expressions, and
532              will eventually be removed from Core Erlang.
533
534              See also: ann_c_catch/2,  c_try/5,  catch_body/1,  is_c_catch/1,
535              update_c_catch/2.
536
537       c_char(Value) -> cerl()
538
539              Types:
540
541                 Value = char() | integer()
542
543              Creates  an abstract character literal. If the local implementa‐
544              tion of Erlang defines char() as a  subset  of  integer(),  this
545              function is equivalent to c_int/1. Otherwise, if the given value
546              is an integer, it will be converted to the  character  with  the
547              corresponding code. The lexical representation of a character is
548              "$Char", where Char is a single printing character or an  escape
549              sequence.
550
551              See   also:   ann_c_char/2,   c_int/1,  c_string/1,  char_lit/1,
552              char_val/1, is_c_char/1, is_print_char/1.
553
554       c_clause(Patterns::[cerl()], Body::cerl()) -> cerl()
555
556              Equivalent to c_clause(Patterns, c_atom(true), Body).
557
558              See also: c_atom/1.
559
560       c_clause(Patterns::[cerl()], Guard::cerl(), Body::cerl()) -> cerl()
561
562              Creates an an abstract clause. If Patterns is [P1, ..., Pn], the
563              result represents "<P1, ..., Pn> when Guard -> Body".
564
565              See  also:  ann_c_clause/4,  c_case/2,  c_clause/2, c_receive/3,
566              clause_arity/1,  clause_body/1,  clause_guard/1,  clause_pats/1,
567              clause_vars/1, is_c_clause/1, update_c_clause/4.
568
569       c_cons(Head::cerl(), Tail::cerl()) -> cerl()
570
571              Creates  an  abstract  list  constructor.  The result represents
572              "[Head | Tail]". Note that if both Head and Tail have type  lit‐
573              eral,  then  the result will also have type literal, and annota‐
574              tions on Head and Tail are lost.
575
576              Recall that in Erlang, the tail element of a list constructor is
577              not necessarily a list.
578
579              See   also:  ann_c_cons/3,  c_cons_skel/2,  c_nil/0,  cons_hd/1,
580              cons_tl/1,    is_c_cons/1,     is_c_list/1,     list_elements/1,
581              list_length/1, make_list/2, update_c_cons/3.
582
583       c_cons_skel(Head::cerl(), Tail::cerl()) -> cerl()
584
585              Creates  an  abstract  list  constructor skeleton. Does not fold
586              constant literals, i.e., the result always has type cons, repre‐
587              senting "[Head | Tail]".
588
589              This  function  is  occasionally  useful when it is necessary to
590              have annotations on the subnodes of  a  list  constructor  node,
591              even  when the subnodes are constant literals. Note however that
592              is_literal/1 will yield false and concrete/1 will fail if passed
593              the result from this function.
594
595              fold_literal/1  can  be used to revert a node to the normal-form
596              representation.
597
598              See  also:  ann_c_cons_skel/3,  c_cons/2,  c_nil/0,  concrete/1,
599              fold_literal/1,   is_c_cons/1,  is_c_list/1,  is_literal/1,  up‐
600              date_c_cons_skel/3.
601
602       c_float(Value::float()) -> cerl()
603
604              Creates an abstract floating-point literal. The  lexical  repre‐
605              sentation is the decimal floating-point numeral of Value.
606
607              See also: ann_c_float/2, float_lit/1, float_val/1, is_c_float/1.
608
609       c_fname(Name::atom(), Arity::arity()) -> cerl()
610
611              Equivalent to c_var({Name, Arity}).
612
613              See     also:    ann_c_fname/3,    fname_arity/1,    fname_id/1,
614              is_c_fname/1, update_c_fname/3.
615
616       c_fun(Variables::[cerl()], Body::cerl()) -> cerl()
617
618              Creates an abstract fun-expression. If Variables  is  [V1,  ...,
619              Vn],  the result represents "fun (V1, ..., Vn) -> Body". All the
620              Vi must have type var.
621
622              See  also:  ann_c_fun/3,  fun_arity/1,  fun_body/1,  fun_vars/1,
623              is_c_fun/1, update_c_fun/3.
624
625       c_int(Value::integer()) -> cerl()
626
627              Creates  an abstract integer literal. The lexical representation
628              is the canonical decimal numeral of Value.
629
630              See   also:   ann_c_int/2,   c_char/1,   int_lit/1,   int_val/1,
631              is_c_int/1.
632
633       c_let(Variables::[cerl()], Argument::cerl(), Body::cerl()) -> cerl()
634
635              Creates  an  abstract  let-expression. If Variables is [V1, ...,
636              Vn], the result represents "let <V1,  ...,  Vn>  =  Argument  in
637              Body". All the Vi must have type var.
638
639              See   also:  ann_c_let/4,  is_c_let/1,  let_arg/1,  let_arity/1,
640              let_body/1, let_vars/1, update_c_let/4.
641
642       c_letrec(Definitions::[{cerl(), cerl()}], Body::cerl()) -> cerl()
643
644              Creates an abstract letrec-expression. If Definitions  is  [{V1,
645              F1},  ...,  {Vn, Fn}], the result represents "letrec V1 = F1 ...
646              Vn = Fn in Body. All the Vi must have  type  var  and  represent
647              function names. All the Fi must have type 'fun'.
648
649              See  also:  ann_c_letrec/3,  is_c_letrec/1,  letrec_body/1,  le‐
650              trec_defs/1, letrec_vars/1, update_c_letrec/3.
651
652       c_map(Pairs::[c_map_pair()]) -> c_map()
653
654       c_map_pair(Key::cerl(), Val::cerl()) -> c_map_pair()
655
656       c_map_pair_exact(Key::cerl(), Val::cerl()) -> c_map_pair()
657
658       c_map_pattern(Pairs::[c_map_pair()]) -> c_map()
659
660       c_module(Name::cerl(), Exports, Es::Definitions) -> cerl()
661
662              Types:
663
664                 Exports = [cerl()]
665                 Definitions = [{cerl(), cerl()}]
666
667              Equivalent to c_module(Name, Exports, [], Definitions).
668
669       c_module(Name::cerl(), Exports, Attrs::Attributes, Es::Definitions)  ->
670       cerl()
671
672              Types:
673
674                 Exports = [cerl()]
675                 Attributes = [{cerl(), cerl()}]
676                 Definitions = [{cerl(), cerl()}]
677
678              Creates an abstract module definition. The result represents
679
680                  module Name [E1, ..., Ek]
681                    attributes [K1 = T1, ...,
682                                Km = Tm]
683                    V1 = F1
684                    ...
685                    Vn = Fn
686                  end
687
688              if  Exports  =  [E1, ..., Ek], Attributes = [{K1, T1}, ..., {Km,
689              Tm}], and Definitions = [{V1, F1}, ..., {Vn, Fn}].
690
691              Name and all the Ki must be atom literals, and all the  Ti  must
692              be  constant  literals. All the Vi and Ei must have type var and
693              represent function names. All the Fi must have type 'fun'.
694
695              See also:  ann_c_module/4,  ann_c_module/5,  c_atom/1,  c_fun/2,
696              c_module/3,    c_var/1,   is_literal/1,   module_attrs/1,   mod‐
697              ule_defs/1, module_exports/1, module_name/1, module_vars/1,  up‐
698              date_c_module/5.
699
700       c_nil() -> cerl()
701
702              Creates  an abstract empty list. The result represents "[]". The
703              empty list is traditionally called "nil".
704
705              See also: ann_c_nil/1, c_cons/2, is_c_list/1.
706
707       c_primop(Name::cerl(), Arguments::[cerl()]) -> cerl()
708
709              Creates an abstract primitive operation call.  If  Arguments  is
710              [A1, ..., An], the result represents "primop Name(A1, ..., An)".
711              Name must be an atom literal.
712
713              See also: ann_c_primop/3,  c_apply/2,  c_call/3,  is_c_primop/1,
714              primop_args/1, primop_arity/1, primop_name/1, update_c_primop/3.
715
716       c_receive(Clauses::[cerl()]) -> cerl()
717
718              Equivalent      to      c_receive(Clauses,     c_atom(infinity),
719              c_atom(true)).
720
721              See also: c_atom/1.
722
723       c_receive(Clauses::[cerl()], Timeout::cerl(), Action::cerl()) -> cerl()
724
725              Creates an abstract receive-expression. If Clauses is [C1,  ...,
726              Cn],  the  result represents "receive C1 ... Cn after Timeout ->
727              Action end".
728
729              See  also:  ann_c_receive/4,  c_receive/1,  is_c_receive/1,  re‐
730              ceive_action/1,    receive_clauses/1,   receive_timeout/1,   up‐
731              date_c_receive/4.
732
733       c_seq(Argument::cerl(), Body::cerl()) -> cerl()
734
735              Creates an abstract sequencing expression. The result represents
736              "do Argument Body".
737
738              See  also:  ann_c_seq/3,  is_c_seq/1, seq_arg/1, seq_body/1, up‐
739              date_c_seq/3.
740
741       c_string(Value::string()) -> cerl()
742
743              Creates an abstract string literal. Equivalent  to  creating  an
744              abstract  list  of  the  corresponding  character  literals (cf.
745              is_c_string/1), but is typically  more  efficient.  The  lexical
746              representation  of  a  string is ""Chars"", where Chars is a se‐
747              quence of printing characters or spaces.
748
749              See    also:    ann_c_string/2,     c_char/1,     is_c_string/1,
750              is_print_string/1, string_lit/1, string_val/1.
751
752       c_try(Argument::cerl(),  Variables::[cerl()],  Body::cerl(), Exception‐
753       Vars::[cerl()], Handler::cerl()) -> cerl()
754
755              Creates an abstract try-expression. If Variables  is  [V1,  ...,
756              Vn]  and  ExceptionVars  is [X1, ..., Xm], the result represents
757              "try Argument of <V1, ..., Vn> -> Body catch <X1,  ...,  Xm>  ->
758              Handler". All the Vi and Xi must have type var.
759
760              See   also:   ann_c_try/6,   c_catch/1,  is_c_try/1,  try_arg/1,
761              try_body/1, try_vars/1, update_c_try/6.
762
763       c_tuple(Elements::[cerl()]) -> cerl()
764
765              Creates an abstract tuple. If Elements is [E1, ..., En], the re‐
766              sult  represents "{E1, ..., En}". Note that if all nodes in Ele‐
767              ments have type literal, or if Elements is empty, then  the  re‐
768              sult will also have type literal and annotations on nodes in El‐
769              ements are lost.
770
771              Recall that Erlang has distinct 1-tuples, i.e.,  {X}  is  always
772              distinct from X itself.
773
774              See also: ann_c_tuple/2, c_tuple_skel/1, is_c_tuple/1, tuple_ar‐
775              ity/1, tuple_es/1, update_c_tuple/2.
776
777       c_tuple_skel(Elements::[cerl()]) -> cerl()
778
779              Creates an abstract tuple skeleton. Does not fold constant  lit‐
780              erals,  i.e.,  the  result  always  has type tuple, representing
781              "{E1, ..., En}", if Elements is [E1, ..., En].
782
783              This function is occasionally useful when  it  is  necessary  to
784              have  annotations on the subnodes of a tuple node, even when all
785              the subnodes are constant literals. Note  however  that  is_lit‐
786              eral/1  will  yield false and concrete/1 will fail if passed the
787              result from this function.
788
789              fold_literal/1 can be used to revert a node to  the  normal-form
790              representation.
791
792              See  also:  ann_c_tuple_skel/2, c_tuple/1, concrete/1, fold_lit‐
793              eral/1,  is_c_tuple/1,  is_literal/1,  tuple_es/1,  update_c_tu‐
794              ple_skel/2.
795
796       c_values(Elements::[cerl()]) -> cerl()
797
798              Creates  an  abstract  value list. If Elements is [E1, ..., En],
799              the result represents "<E1, ..., En>".
800
801              See also: ann_c_values/2, is_c_values/1, update_c_values/2, val‐
802              ues_arity/1, values_es/1.
803
804       c_var(Name::var_name()) -> cerl()
805
806              Types:
807
808                 var_name() = integer() | atom() | {atom(), integer()}
809
810              Creates  an  abstract  variable. A variable is identified by its
811              name, given by the Name parameter.
812
813              If a name is given by a single atom, it should either be a "sim‐
814              ple"  atom which does not need to be single-quoted in Erlang, or
815              otherwise its print name should correspond to  a  proper  Erlang
816              variable,  i.e.,  begin with an uppercase character or an under‐
817              score. Names on the form {A, N} represent  function  name  vari‐
818              ables "A/N"; these are special variables which may be bound only
819              in the function definitions of a module or a  letrec.  They  may
820              not  be bound in let expressions and cannot occur in clause pat‐
821              terns. The atom A in a function name may be any atom; the  inte‐
822              ger  N  must  be  nonnegative.  The functions c_fname/2 etc. are
823              utilities for handling function name variables.
824
825              When printing variable names, they must have the form of  proper
826              Core  Erlang  variables  and function names. E.g., a name repre‐
827              sented by an integer such as 42 could be formatted as "_42",  an
828              atom  'Xxx' simply as "Xxx", and an atom foo as "_foo". However,
829              one must assure that any two  valid  distinct  names  are  never
830              mapped to the same strings. Tuples such as {foo, 2} representing
831              function names can simply by formatted  as  "'foo'/2",  with  no
832              risk of conflicts.
833
834              See   also:   ann_c_var/2,  c_fname/2,  c_letrec/2,  c_module/4,
835              is_c_var/1, update_c_var/2, var_name/1.
836
837       call_args(Node::cerl()) -> [cerl()]
838
839              Returns the list of argument subtrees of an abstract  inter-mod‐
840              ule call.
841
842              See also: c_call/3, call_arity/1.
843
844       call_arity(Node::cerl()) -> arity()
845
846              Returns  the  number  of argument subtrees of an abstract inter-
847              module call.
848
849              Note: this is equivalent to length(call_args(Node)), but  poten‐
850              tially more efficient.
851
852              See also: c_call/3, call_args/1.
853
854       call_module(Node::cerl()) -> cerl()
855
856              Returns the module subtree of an abstract inter-module call.
857
858              See also: c_call/3.
859
860       call_name(Node::cerl()) -> cerl()
861
862              Returns the name subtree of an abstract inter-module call.
863
864              See also: c_call/3.
865
866       case_arg(Node::cerl()) -> cerl()
867
868              Returns the argument subtree of an abstract case-expression.
869
870              See also: c_case/2.
871
872       case_arity(Node::cerl()) -> integer()
873
874              Equivalent  to  clause_arity(hd(case_clauses(Node))), but poten‐
875              tially more efficient.
876
877              See also: c_case/2, case_clauses/1, clause_arity/1.
878
879       case_clauses(Node::cerl()) -> [cerl()]
880
881              Returns the list of clause subtrees of an abstract  case-expres‐
882              sion.
883
884              See also: c_case/2, case_arity/1.
885
886       catch_body(Node::cerl()) -> cerl()
887
888              Returns the body subtree of an abstract catch-expression.
889
890              See also: c_catch/1.
891
892       char_lit(Node::cerl()) -> string()
893
894              Returns the literal string represented by an abstract character.
895              This includes a leading $ character. Currently,  all  characters
896              that are not in the set of ISO 8859-1 (Latin-1) "printing" char‐
897              acters will be escaped.
898
899              See also: c_char/1.
900
901       char_val(Node::cerl()) -> char()
902
903              Returns the value represented by an abstract character literal.
904
905              See also: c_char/1.
906
907       clause_arity(Node::cerl()) -> integer()
908
909              Returns the number of pattern subtrees of an abstract clause.
910
911              Note: this is equivalent to length(clause_pats(Node)),  but  po‐
912              tentially more efficient.
913
914              See also: c_clause/3, clause_pats/1.
915
916       clause_body(Node::cerl()) -> cerl()
917
918              Returns the body subtree of an abstract clause.
919
920              See also: c_clause/3.
921
922       clause_guard(Node::cerl()) -> cerl()
923
924              Returns the guard subtree of an abstract clause.
925
926              See also: c_clause/3.
927
928       clause_pats(Node::cerl()) -> [cerl()]
929
930              Returns the list of pattern subtrees of an abstract clause.
931
932              See also: c_clause/3, clause_arity/1.
933
934       clause_vars(Clause::cerl()) -> [cerl()]
935
936              Returns the list of all abstract variables in the patterns of an
937              abstract clause. The order of listing is not defined.
938
939              See also: c_clause/3, pat_list_vars/1.
940
941       concrete(Node::cerl()) -> term()
942
943              Returns the Erlang term represented by a syntax tree. An  excep‐
944              tion is thrown if Node does not represent a literal term.
945
946              Note: This is a constant time operation.
947
948              See also: abstract/1, is_literal/1.
949
950       cons_hd(C_cons::cerl()) -> cerl()
951
952              Returns the head subtree of an abstract list constructor.
953
954              See also: c_cons/2.
955
956       cons_tl(C_cons::cerl()) -> cerl()
957
958              Returns the tail subtree of an abstract list constructor.
959
960              Recall  that  the  tail  does not necessarily represent a proper
961              list.
962
963              See also: c_cons/2.
964
965       copy_ann(Source::cerl(), Target::cerl()) -> cerl()
966
967              Copies the list of user annotations from Source to Target.
968
969              Note: this is equivalent  to  set_ann(Target,  get_ann(Source)),
970              but potentially more efficient.
971
972              See also: get_ann/1, set_ann/2.
973
974       data_arity(Node::cerl()) -> integer()
975
976              Returns  the number of subtrees of a data constructor node. This
977              is equivalent to length(data_es(Node)), but potentially more ef‐
978              ficient.
979
980              See also: data_es/1, is_data/1.
981
982       data_es(Node::cerl()) -> [cerl()]
983
984              Returns  the list of subtrees of a data constructor node. If the
985              arity of the constructor is zero, the result is the empty list.
986
987              Note: if data_type(Node) is cons, the number of subtrees is  ex‐
988              actly  two. If data_type(Node) is {atomic, Value}, the number of
989              subtrees is zero.
990
991              See also: data_arity/1, data_type/1, is_data/1, make_data/2.
992
993       data_type(Node::cerl()) -> dtype()
994
995              Types:
996
997                 dtype() = cons | tuple | {atomic, Value}
998                 Value = integer() | float() | atom() | []
999
1000              Returns a type descriptor for  a  data  constructor  node.  (Cf.
1001              is_data/1.)  This  is  mainly useful for comparing types and for
1002              constructing new nodes of the same type  (cf.  make_data/2).  If
1003              Node represents an integer, floating-point number, atom or empty
1004              list, the result is {atomic, Value}, where Value is the value of
1005              concrete(Node), otherwise the result is either cons or tuple.
1006
1007              Type  descriptors  can be compared for equality or order (in the
1008              Erlang term order),  but  remember  that  floating-point  values
1009              should in general never be tested for equality.
1010
1011              See also: concrete/1, is_data/1, make_data/2, type/1.
1012
1013       float_lit(Node::cerl()) -> string()
1014
1015              Returns  the numeral string represented by a floating-point lit‐
1016              eral node.
1017
1018              See also: c_float/1.
1019
1020       float_val(Node::cerl()) -> float()
1021
1022              Returns the value represented by a floating-point literal node.
1023
1024              See also: c_float/1.
1025
1026       fname_arity(C_var::cerl()) -> arity()
1027
1028              Returns the arity part of an abstract function name variable.
1029
1030              See also: c_fname/2, fname_id/1.
1031
1032       fname_id(C_var::cerl()) -> atom()
1033
1034              Returns the identifier part of an abstract function  name  vari‐
1035              able.
1036
1037              See also: c_fname/2, fname_arity/1.
1038
1039       fold_literal(Node::cerl()) -> cerl()
1040
1041              Assures that literals have a compact representation. This is oc‐
1042              casionally  useful  if  c_cons_skel/2,  c_tuple_skel/1  or   un‐
1043              fold_literal/1  were  used  in the construction of Node, and you
1044              want to revert to the normal "folded" representation  of  liter‐
1045              als.  If  Node  represents a tuple or list constructor, its ele‐
1046              ments are rewritten recursively, and the node  is  reconstructed
1047              using  c_cons/2  or  c_tuple/1, respectively; otherwise, Node is
1048              not changed.
1049
1050              See also: c_cons/2,  c_cons_skel/2,  c_tuple/1,  c_tuple_skel/1,
1051              is_literal/1, unfold_literal/1.
1052
1053       from_records(Tree::record(record_types())) -> cerl()
1054
1055              Types:
1056
1057                 record_types()  =  c_alias  |  c_apply  |  c_call  | c_case |
1058                 c_catch | c_clause | c_cons | c_fun  |  c_let  |  c_letrec  |
1059                 c_lit  |  c_module  |  c_primop | c_receive | c_seq | c_try |
1060                 c_tuple | c_values | c_var
1061
1062              Translates an explicit record representation to a  corresponding
1063              abstract  syntax  tree.  The  records  are  defined  in the file
1064              "core_parse.hrl".
1065
1066              See also: to_records/1, type/1.
1067
1068       fun_arity(Node::cerl()) -> arity()
1069
1070              Returns the number of parameter subtrees of an abstract  fun-ex‐
1071              pression.
1072
1073              Note:  this  is equivalent to length(fun_vars(Node)), but poten‐
1074              tially more efficient.
1075
1076              See also: c_fun/2, fun_vars/1.
1077
1078       fun_body(Node::cerl()) -> cerl()
1079
1080              Returns the body subtree of an abstract fun-expression.
1081
1082              See also: c_fun/2.
1083
1084       fun_vars(Node::cerl()) -> [cerl()]
1085
1086              Returns the list of parameter subtrees of  an  abstract  fun-ex‐
1087              pression.
1088
1089              See also: c_fun/2, fun_arity/1.
1090
1091       get_ann(Node::cerl()) -> [term()]
1092
1093              Returns  the  list  of user annotations associated with a syntax
1094              tree node. For a newly created node, this is the empty list. The
1095              annotations may be any terms.
1096
1097              See also: set_ann/2.
1098
1099       int_lit(Node::cerl()) -> string()
1100
1101              Returns  the  numeral  string  represented by an integer literal
1102              node.
1103
1104              See also: c_int/1.
1105
1106       int_val(Node::cerl()) -> integer()
1107
1108              Returns the value represented by an integer literal node.
1109
1110              See also: c_int/1.
1111
1112       is_c_alias(Node::cerl()) -> boolean()
1113
1114              Returns true if Node is an  abstract  pattern  alias,  otherwise
1115              false.
1116
1117              See also: c_alias/2.
1118
1119       is_c_apply(Node::cerl()) -> boolean()
1120
1121              Returns true if Node is an abstract function application, other‐
1122              wise false.
1123
1124              See also: c_apply/2.
1125
1126       is_c_atom(Node::cerl()) -> boolean()
1127
1128              Returns true if  Node  represents  an  atom  literal,  otherwise
1129              false.
1130
1131              See also: c_atom/1.
1132
1133       is_c_binary(Node::cerl()) -> boolean()
1134
1135              Returns  true  if Node is an abstract binary-template; otherwise
1136              false.
1137
1138              See also: c_binary/1.
1139
1140       is_c_bitstr(Node::cerl()) -> boolean()
1141
1142              Returns true if Node is an abstract bit-string template;  other‐
1143              wise false.
1144
1145              See also: c_bitstr/5.
1146
1147       is_c_call(Node::cerl()) -> boolean()
1148
1149              Returns  true  if  Node is an abstract inter-module call expres‐
1150              sion; otherwise false.
1151
1152              See also: c_call/3.
1153
1154       is_c_case(C_case::cerl()) -> boolean()
1155
1156              Returns true if Node is an abstract  case-expression;  otherwise
1157              false.
1158
1159              See also: c_case/2.
1160
1161       is_c_catch(Node::cerl()) -> boolean()
1162
1163              Returns  true if Node is an abstract catch-expression, otherwise
1164              false.
1165
1166              See also: c_catch/1.
1167
1168       is_c_char(Node::cerl()) -> boolean()
1169
1170              Returns true if Node may represent a character  literal,  other‐
1171              wise false.
1172
1173              If the local implementation of Erlang defines char() as a subset
1174              of integer(), then is_c_int(Node) will also yield true.
1175
1176              See also: c_char/1, is_print_char/1.
1177
1178       is_c_clause(Node::cerl()) -> boolean()
1179
1180              Returns true if Node is an abstract clause, otherwise false.
1181
1182              See also: c_clause/3.
1183
1184       is_c_cons(Node::cerl()) -> boolean()
1185
1186              Returns true if Node is an abstract list constructor,  otherwise
1187              false.
1188
1189       is_c_float(Node::cerl()) -> boolean()
1190
1191              Returns true if Node represents a floating-point literal, other‐
1192              wise false.
1193
1194              See also: c_float/1.
1195
1196       is_c_fname(Node::cerl()) -> boolean()
1197
1198              Returns true if Node is an abstract function name variable, oth‐
1199              erwise false.
1200
1201              See also: c_fname/2, c_var/1, var_name/1.
1202
1203       is_c_fun(Node::cerl()) -> boolean()
1204
1205              Returns  true  if  Node is an abstract fun-expression, otherwise
1206              false.
1207
1208              See also: c_fun/2.
1209
1210       is_c_int(Node::cerl()) -> boolean()
1211
1212              Returns true if Node represents an  integer  literal,  otherwise
1213              false.
1214
1215              See also: c_int/1.
1216
1217       is_c_let(Node::cerl()) -> boolean()
1218
1219              Returns  true  if  Node is an abstract let-expression, otherwise
1220              false.
1221
1222              See also: c_let/3.
1223
1224       is_c_letrec(Node::cerl()) -> boolean()
1225
1226              Returns true if Node is an abstract letrec-expression, otherwise
1227              false.
1228
1229              See also: c_letrec/2.
1230
1231       is_c_list(Node::cerl()) -> boolean()
1232
1233              Returns  true if Node represents a proper list, otherwise false.
1234              A proper list is either the empty list [], or a cons cell  [Head
1235              | Tail], where recursively Tail is a proper list.
1236
1237              Note:  Because Node is a syntax tree, the actual run-time values
1238              corresponding to its subtrees may often  be  partially  or  com‐
1239              pletely  unknown.  Thus,  if  Node  represents e.g. "[... | Ns]"
1240              (where Ns is a variable), then the function will  return  false,
1241              because  it  is  not known whether Ns will be bound to a list at
1242              run-time. If Node instead represents e.g. "[1, 2, 3]" or  "[A  |
1243              []]", then the function will return true.
1244
1245              See also: c_cons/2, c_nil/0, list_elements/1, list_length/1.
1246
1247       is_c_map(Node::cerl()) -> boolean()
1248
1249              Returns  true  if Node is an abstract map constructor, otherwise
1250              false.
1251
1252       is_c_map_empty(C_map::c_map() | c_literal()) -> boolean()
1253
1254       is_c_map_pattern(C_map::c_map()) -> boolean()
1255
1256       is_c_module(Node::cerl()) -> boolean()
1257
1258              Returns true if Node is an abstract module definition, otherwise
1259              false.
1260
1261              See also: type/1.
1262
1263       is_c_nil(Node::cerl()) -> boolean()
1264
1265              Returns true if Node is an abstract empty list, otherwise false.
1266
1267       is_c_primop(Node::cerl()) -> boolean()
1268
1269              Returns  true  if  Node is an abstract primitive operation call,
1270              otherwise false.
1271
1272              See also: c_primop/2.
1273
1274       is_c_receive(Node::cerl()) -> boolean()
1275
1276              Returns true if Node is an abstract  receive-expression,  other‐
1277              wise false.
1278
1279              See also: c_receive/3.
1280
1281       is_c_seq(Node::cerl()) -> boolean()
1282
1283              Returns  true if Node is an abstract sequencing expression, oth‐
1284              erwise false.
1285
1286              See also: c_seq/2.
1287
1288       is_c_string(Node::cerl()) -> boolean()
1289
1290              Returns true if Node may represent a string  literal,  otherwise
1291              false.   Strings   are  defined  as  lists  of  characters;  see
1292              is_c_char/1 for details.
1293
1294              See also: c_string/1, is_c_char/1, is_print_string/1.
1295
1296       is_c_try(Node::cerl()) -> boolean()
1297
1298              Returns true if Node is an  abstract  try-expression,  otherwise
1299              false.
1300
1301              See also: c_try/5.
1302
1303       is_c_tuple(Node::cerl()) -> boolean()
1304
1305              Returns true if Node is an abstract tuple, otherwise false.
1306
1307              See also: c_tuple/1.
1308
1309       is_c_values(Node::cerl()) -> boolean()
1310
1311              Returns true if Node is an abstract value list; otherwise false.
1312
1313              See also: c_values/1.
1314
1315       is_c_var(Node::cerl()) -> boolean()
1316
1317              Returns true if Node is an abstract variable, otherwise false.
1318
1319              See also: c_var/1.
1320
1321       is_data(Node::cerl()) -> boolean()
1322
1323              Returns  true  if  Node represents a data constructor, otherwise
1324              false. Data constructors are cons cells, tuples, and atomic lit‐
1325              erals.
1326
1327              See also: data_arity/1, data_es/1, data_type/1.
1328
1329       is_leaf(Node::cerl()) -> boolean()
1330
1331              Returns  true  if Node is a leaf node, otherwise false. The cur‐
1332              rent leaf node types are literal and var.
1333
1334              Note: all literals (cf. is_literal/1) are leaf  nodes,  even  if
1335              they  represent structured (constant) values such as {foo, [bar,
1336              baz]}. Also note that variables are leaf nodes but not literals.
1337
1338              See also: is_literal/1, type/1.
1339
1340       is_literal(Node::cerl()) -> boolean()
1341
1342              Returns true if Node represents a literal term, otherwise false.
1343              This  function  returns  true  if  and only if the value of con‐
1344              crete(Node) is defined.
1345
1346              Note: This is a constant time operation.
1347
1348              See also: abstract/1, concrete/1, fold_literal/1.
1349
1350       is_literal_term(Term::term()) -> boolean()
1351
1352              Returns true if Term can be represented as a literal,  otherwise
1353              false.  This  function  takes  time  proportional to the size of
1354              Term.
1355
1356              See also: abstract/1.
1357
1358       is_print_char(Node::cerl()) -> boolean()
1359
1360              Returns true if Node may represent a "printing" character,  oth‐
1361              erwise  false. (Cf. is_c_char/1.) A "printing" character has ei‐
1362              ther a given graphical representation, or a "named"  escape  se‐
1363              quence  such as "\n". Currently, only ISO 8859-1 (Latin-1) char‐
1364              acter values are recognized.
1365
1366              See also: c_char/1, is_c_char/1.
1367
1368       is_print_string(Node::cerl()) -> boolean()
1369
1370              Returns true if Node may represent a string  literal  containing
1371              only  "printing"  characters, otherwise false. See is_c_string/1
1372              and is_print_char/1 for  details.  Currently,  only  ISO  8859-1
1373              (Latin-1) character values are recognized.
1374
1375              See also: c_string/1, is_c_string/1, is_print_char/1.
1376
1377       let_arg(Node::cerl()) -> cerl()
1378
1379              Returns the argument subtree of an abstract let-expression.
1380
1381              See also: c_let/3.
1382
1383       let_arity(Node::cerl()) -> integer()
1384
1385              Returns  the  number  of left-hand side variables of an abstract
1386              let-expression.
1387
1388              Note: this is equivalent to length(let_vars(Node)),  but  poten‐
1389              tially more efficient.
1390
1391              See also: c_let/3, let_vars/1.
1392
1393       let_body(Node::cerl()) -> cerl()
1394
1395              Returns the body subtree of an abstract let-expression.
1396
1397              See also: c_let/3.
1398
1399       let_vars(Node::cerl()) -> [cerl()]
1400
1401              Returns the list of left-hand side variables of an abstract let-
1402              expression.
1403
1404              See also: c_let/3, let_arity/1.
1405
1406       letrec_body(Node::cerl()) -> cerl()
1407
1408              Returns the body subtree of an abstract letrec-expression.
1409
1410              See also: c_letrec/2.
1411
1412       letrec_defs(Node::cerl()) -> [{cerl(), cerl()}]
1413
1414              Returns the list of definitions of  an  abstract  letrec-expres‐
1415              sion.  If  Node represents "letrec V1 = F1 ... Vn = Fn in Body",
1416              the returned value is [{V1, F1}, ..., {Vn, Fn}].
1417
1418              See also: c_letrec/2.
1419
1420       letrec_vars(Node::cerl()) -> [cerl()]
1421
1422              Returns the list of left-hand side function variable subtrees of
1423              a letrec-expression. If Node represents "letrec V1 = F1 ... Vn =
1424              Fn in Body", the returned value is [V1, ..., Vn].
1425
1426              See also: c_letrec/2.
1427
1428       list_elements(C_cons::cerl()) -> [cerl()]
1429
1430              Returns the list of element subtrees of an abstract  list.  Node
1431              must  represent a proper list. E.g., if Node represents "[X1, X2
1432              | [X3, X4 | []]", then list_elements(Node) yields the list  [X1,
1433              X2, X3, X4].
1434
1435              See   also:   c_cons/2,   c_nil/0,  is_c_list/1,  list_length/1,
1436              make_list/2.
1437
1438       list_length(Node::cerl()) -> integer()
1439
1440              Returns the number of element subtrees of an abstract list. Node
1441              must  represent  a  proper list. E.g., if Node represents "[X1 |
1442              [X2, X3 | [X4, X5, X6]]]", then  list_length(Node)  returns  the
1443              integer 6.
1444
1445              Note: this is equivalent to length(list_elements(Node)), but po‐
1446              tentially more efficient.
1447
1448              See also: c_cons/2, c_nil/0, is_c_list/1, list_elements/1.
1449
1450       make_data(Type::dtype(), Elements::[cerl()]) -> cerl()
1451
1452              Creates a data constructor node with the specified type and sub‐
1453              trees.  (Cf.  data_type/1.) An exception is thrown if the length
1454              of Elements is invalid for the given Type; see data_es/1 for ar‐
1455              ity constraints on constructor types.
1456
1457              See     also:     ann_make_data/3,    data_es/1,    data_type/1,
1458              make_data_skel/2, update_data/3.
1459
1460       make_data_skel(Type::dtype(), Elements::[cerl()]) -> cerl()
1461
1462              Like  make_data/2,   but   analogous   to   c_tuple_skel/1   and
1463              c_cons_skel/2.
1464
1465              See  also:  ann_make_data_skel/3, c_cons_skel/2, c_tuple_skel/1,
1466              make_data/2, update_data_skel/3.
1467
1468       make_list(List) -> Node
1469
1470              Equivalent to make_list(List, none).
1471
1472       make_list(List::[cerl()], Tail) -> cerl()
1473
1474              Types:
1475
1476                 Tail = cerl() | none
1477
1478              Creates an abstract list from the elements in List and  the  op‐
1479              tional  Tail.  If Tail is none, the result will represent a nil-
1480              terminated list, otherwise it represents "[... | Tail]".
1481
1482              See also: ann_make_list/3, c_cons/2,  c_nil/0,  list_elements/1,
1483              update_list/3.
1484
1485       make_tree(Type::ctype(), Groups::[[cerl()]]) -> cerl()
1486
1487              Creates  a  syntax  tree  with the given type and subtrees. Type
1488              must be a node type name (cf. type/1) that  does  not  denote  a
1489              leaf  node  type (cf. is_leaf/1). Groups must be a nonempty list
1490              of groups of syntax trees, representing the subtrees of  a  node
1491              of the given type, in left-to-right order as they would occur in
1492              the printed program text, grouped by category as  done  by  sub‐
1493              trees/1.
1494
1495              The  result  of  ann_make_tree(get_ann(Node),  type(Node),  sub‐
1496              trees(Node)) (cf. update_tree/2) represents the same source code
1497              text as the original Node, assuming that subtrees(Node) yields a
1498              nonempty list. However, it does not necessarily have  the  exact
1499              same data representation as Node.
1500
1501              See  also:  ann_make_tree/3,  is_leaf/1, subtrees/1, type/1, up‐
1502              date_tree/2.
1503
1504       map_arg(C_literal::c_map() | c_literal()) -> c_map() | c_literal()
1505
1506       map_es(C_literal::c_map() | c_literal()) -> [c_map_pair()]
1507
1508       map_pair_key(C_map_pair::c_map_pair()) -> cerl()
1509
1510       map_pair_op(C_map_pair::c_map_pair()) -> map_op()
1511
1512       map_pair_val(C_map_pair::c_map_pair()) -> cerl()
1513
1514       meta(Tree::cerl()) -> cerl()
1515
1516              Creates a meta-representation of a syntax tree. The result  rep‐
1517              resents  an  Erlang  expression  "MetaTree" which, if evaluated,
1518              will yield a new syntax tree representing the same  source  code
1519              text  as  Tree  (although  the actual data representation may be
1520              different). The expression represented by MetaTree is  implemen‐
1521              tation  independent  with  regard to the data structures used by
1522              the abstract syntax tree implementation.
1523
1524              Any node in Tree whose node type is var (cf. type/1), and  whose
1525              list  of annotations (cf. get_ann/1) contains the atom meta_var,
1526              will remain unchanged in the resulting tree, except that exactly
1527              one occurrence of meta_var is removed from its annotation list.
1528
1529              The  main  use  of  the  function  meta/1 is to transform a data
1530              structure Tree, which represents a piece of program code, into a
1531              form that is representation independent when printed. E.g., sup‐
1532              pose Tree represents a variable  named  "V".  Then  (assuming  a
1533              function   print/1   for   printing  syntax  trees),  evaluating
1534              print(abstract(Tree)) - simply using abstract/1 to map  the  ac‐
1535              tual  data  structure  onto a syntax tree representation - would
1536              output a string that  might  look  something  like  "{var,  ...,
1537              'V'}", which is obviously dependent on the implementation of the
1538              abstract syntax trees. This could e.g. be useful for  caching  a
1539              syntax  tree  in  a  file. However, in some situations like in a
1540              program generator generator (with two "generator"),  it  may  be
1541              unacceptable.  Using  print(meta(Tree))  instead  would output a
1542              representation independent syntax tree generating expression; in
1543              the above case, something like "cerl:c_var('V')".
1544
1545              The  implementation  tries to generate compact code with respect
1546              to literals and lists.
1547
1548              See also: abstract/1, get_ann/1, type/1.
1549
1550       module_attrs(Node::cerl()) -> [{cerl(), cerl()}]
1551
1552              Returns the list of pairs of attribute key/value subtrees of  an
1553              abstract module definition.
1554
1555              See also: c_module/4.
1556
1557       module_defs(Node::cerl()) -> [{cerl(), cerl()}]
1558
1559              Returns  the  list of function definitions of an abstract module
1560              definition.
1561
1562              See also: c_module/4.
1563
1564       module_exports(Node::cerl()) -> [cerl()]
1565
1566              Returns the list of exports subtrees of an abstract module defi‐
1567              nition.
1568
1569              See also: c_module/4.
1570
1571       module_name(Node::cerl()) -> cerl()
1572
1573              Returns the name subtree of an abstract module definition.
1574
1575              See also: c_module/4.
1576
1577       module_vars(Node::cerl()) -> [cerl()]
1578
1579              Returns the list of left-hand side function variable subtrees of
1580              an abstract module definition.
1581
1582              See also: c_module/4.
1583
1584       pat_list_vars(Patterns::[cerl()]) -> [cerl()]
1585
1586              Returns the list of all abstract variables  in  the  given  pat‐
1587              terns.  An  exception is thrown if some element in Patterns does
1588              not represent a well-formed Core Erlang clause pattern. The  or‐
1589              der of listing is not defined.
1590
1591              See also: clause_vars/1, pat_vars/1.
1592
1593       pat_vars(Pattern::cerl()) -> [cerl()]
1594
1595              Returns  the list of all abstract variables in a pattern. An ex‐
1596              ception is thrown if Node does not represent a well-formed  Core
1597              Erlang clause pattern. The order of listing is not defined.
1598
1599              See also: clause_vars/1, pat_list_vars/1.
1600
1601       primop_args(Node::cerl()) -> [cerl()]
1602
1603              Returns  the  list of argument subtrees of an abstract primitive
1604              operation call.
1605
1606              See also: c_primop/2, primop_arity/1.
1607
1608       primop_arity(Node::cerl()) -> arity()
1609
1610              Returns the number of argument subtrees of an abstract primitive
1611              operation call.
1612
1613              Note:  this  is equivalent to length(primop_args(Node)), but po‐
1614              tentially more efficient.
1615
1616              See also: c_primop/2, primop_args/1.
1617
1618       primop_name(Node::cerl()) -> cerl()
1619
1620              Returns the name subtree  of  an  abstract  primitive  operation
1621              call.
1622
1623              See also: c_primop/2.
1624
1625       receive_action(Node::cerl()) -> cerl()
1626
1627              Returns the action subtree of an abstract receive-expression.
1628
1629              See also: c_receive/3.
1630
1631       receive_clauses(Node::cerl()) -> [cerl()]
1632
1633              Returns  the  list of clause subtrees of an abstract receive-ex‐
1634              pression.
1635
1636              See also: c_receive/3.
1637
1638       receive_timeout(Node::cerl()) -> cerl()
1639
1640              Returns the timeout subtree of an abstract receive-expression.
1641
1642              See also: c_receive/3.
1643
1644       seq_arg(Node::cerl()) -> cerl()
1645
1646              Returns the argument subtree of an abstract  sequencing  expres‐
1647              sion.
1648
1649              See also: c_seq/2.
1650
1651       seq_body(Node::cerl()) -> cerl()
1652
1653              Returns the body subtree of an abstract sequencing expression.
1654
1655              See also: c_seq/2.
1656
1657       set_ann(Node::cerl(), Annotations::[term()]) -> cerl()
1658
1659              Sets the list of user annotations of Node to Annotations.
1660
1661              See also: add_ann/2, copy_ann/2, get_ann/1.
1662
1663       string_lit(Node::cerl()) -> string()
1664
1665              Returns  the  literal  string represented by an abstract string.
1666              This includes surrounding double-quote  characters  "...".  Cur‐
1667              rently,  characters  that  are  not  in  the  set  of ISO 8859-1
1668              (Latin-1) "printing" characters will be escaped, except for spa‐
1669              ces.
1670
1671              See also: c_string/1.
1672
1673       string_val(Node::cerl()) -> string()
1674
1675              Returns the value represented by an abstract string literal.
1676
1677              See also: c_string/1.
1678
1679       subtrees(Node::cerl()) -> [[cerl()]]
1680
1681              Returns the grouped list of all subtrees of a node. If Node is a
1682              leaf node (cf. is_leaf/1), this is the empty list, otherwise the
1683              result  is  always a nonempty list, containing the lists of sub‐
1684              trees of Node, in left-to-right  order  as  they  occur  in  the
1685              printed program text, and grouped by category. Often, each group
1686              contains only a single subtree.
1687
1688              Depending on the type of Node, the size of some  groups  may  be
1689              variable  (e.g.,  the  group consisting of all the elements of a
1690              tuple), while others always contain the same number of  elements
1691              -  usually  exactly one (e.g., the group containing the argument
1692              expression of a case-expression). Note, however, that the  exact
1693              structure of the returned list (for a given node type) should in
1694              general not be depended upon,  since  it  might  be  subject  to
1695              change without notice.
1696
1697              The   function   subtrees/1   and   the   constructor  functions
1698              make_tree/2 and update_tree/2 can be a great help if  one  wants
1699              to  traverse a syntax tree, visiting all its subtrees, but treat
1700              nodes of the tree in a uniform way in most or all  cases.  Using
1701              these  functions  makes  this simple, and also assures that your
1702              code is not overly sensitive to extensions of  the  syntax  tree
1703              data type, because any node types not explicitly handled by your
1704              code can be left to a default case.
1705
1706              For example:
1707
1708                  postorder(F, Tree) ->
1709                      F(case subtrees(Tree) of
1710                          [] -> Tree;
1711                          List -> update_tree(Tree,
1712                                              [[postorder(F, Subtree)
1713                                                || Subtree <- Group]
1714                                               || Group <- List])
1715                        end).
1716
1717
1718              maps the function F on Tree and all its subtrees, doing a  post-
1719              order  traversal  of  the  syntax  tree.  (Note  the  use of up‐
1720              date_tree/2 to preserve  annotations.)  For  a  simple  function
1721              like:
1722
1723                  f(Node) ->
1724                      case type(Node) of
1725                          atom -> atom("a_" ++ atom_name(Node));
1726                          _ -> Node
1727                      end.
1728
1729
1730              the  call  postorder(fun f/1, Tree) will yield a new representa‐
1731              tion of Tree in which all atom names have been extended with the
1732              prefix  "a_",  but nothing else (including annotations) has been
1733              changed.
1734
1735              See also: is_leaf/1, make_tree/2, update_tree/2.
1736
1737       to_records(Tree::cerl()) -> record(record_types())
1738
1739              Translates an abstract syntax tree to a  corresponding  explicit
1740              record  representation.  The  records  are  defined  in the file
1741              "cerl.hrl".
1742
1743              See also: from_records/1, type/1.
1744
1745       try_arg(Node::cerl()) -> cerl()
1746
1747              Returns the expression subtree of an abstract try-expression.
1748
1749              See also: c_try/5.
1750
1751       try_body(Node::cerl()) -> cerl()
1752
1753              Returns the success body subtree of an abstract try-expression.
1754
1755              See also: c_try/5.
1756
1757       try_evars(Node::cerl()) -> [cerl()]
1758
1759              Returns the list of exception variable subtrees of  an  abstract
1760              try-expression.
1761
1762              See also: c_try/5.
1763
1764       try_handler(Node::cerl()) -> cerl()
1765
1766              Returns  the  exception  body subtree of an abstract try-expres‐
1767              sion.
1768
1769              See also: c_try/5.
1770
1771       try_vars(Node::cerl()) -> [cerl()]
1772
1773              Returns the list of success variable  subtrees  of  an  abstract
1774              try-expression.
1775
1776              See also: c_try/5.
1777
1778       tuple_arity(Node::cerl()) -> integer()
1779
1780              Returns the number of element subtrees of an abstract tuple.
1781
1782              Note:  this  is equivalent to length(tuple_es(Node)), but poten‐
1783              tially more efficient.
1784
1785              See also: c_tuple/1, tuple_es/1.
1786
1787       tuple_es(C_tuple::cerl()) -> [cerl()]
1788
1789              Returns the list of element subtrees of an abstract tuple.
1790
1791              See also: c_tuple/1.
1792
1793       type(Node::cerl()) -> atom()
1794
1795              Returns the type tag of Node. Current node types are:
1796
1797              alias apply binary bitstr call case catch clause
1798              cons fun let letrec literal map map_pair module
1799              primop receive seq try tuple values var
1800
1801
1802              Note: The name of the primary constructor function  for  a  node
1803              type  is  always  the name of the type itself, prefixed by "c_";
1804              recognizer predicates are correspondingly prefixed  by  "is_c_".
1805              Furthermore,   to  simplify  preservation  of  annotations  (cf.
1806              get_ann/1), there are analogous constructor  functions  prefixed
1807              by  "ann_c_" and "update_c_", for setting the annotation list of
1808              the new node to either a specific value or to the annotations of
1809              an existing node, respectively.
1810
1811              See  also:  abstract/1, c_alias/2, c_apply/2, c_binary/1, c_bit‐
1812              str/5,  c_call/3,  c_case/2,  c_catch/1,  c_clause/3,  c_cons/2,
1813              c_fun/2,  c_let/3,  c_letrec/2,  c_module/3,  c_primop/2,  c_re‐
1814              ceive/1,  c_seq/2,  c_try/5,  c_tuple/1,  c_values/1,   c_var/1,
1815              data_type/1,   from_records/1,  get_ann/1,  meta/1,  subtrees/1,
1816              to_records/1.
1817
1818       unfold_literal(Node::cerl()) -> cerl()
1819
1820              Assures that literals have a fully expanded  representation.  If
1821              Node  represents  a  literal tuple or list constructor, its ele‐
1822              ments are rewritten recursively, and the node  is  reconstructed
1823              using  c_cons_skel/2 or c_tuple_skel/1, respectively; otherwise,
1824              Node is not changed. The fold_literal/1 can be used to revert to
1825              the normal compact representation.
1826
1827              See  also:  c_cons/2,  c_cons_skel/2, c_tuple/1, c_tuple_skel/1,
1828              fold_literal/1, is_literal/1.
1829
1830       update_c_alias(Old::cerl(),   Variable::cerl(),   Pattern::cerl())   ->
1831       cerl()
1832
1833              See also: c_alias/2.
1834
1835       update_c_apply(Old::cerl(),  Operator::cerl(),  Arguments::[cerl()]) ->
1836       cerl()
1837
1838              See also: c_apply/2.
1839
1840       update_c_binary(Old::cerl(), Segments::[cerl()]) -> cerl()
1841
1842              See also: c_binary/1.
1843
1844       update_c_bitstr(Old::cerl(), Value::cerl(), Size::cerl(), Type::cerl(),
1845       Flags::cerl()) -> cerl()
1846
1847              Equivalent  to  update_c_bitstr(Node,  Value, Size, abstract(1),
1848              Type, Flags).
1849
1850       update_c_bitstr(Old::cerl(), Value::cerl(), Size::cerl(), Unit::cerl(),
1851       Type::cerl(), Flags::cerl()) -> cerl()
1852
1853              See also: c_bitstr/5, update_c_bitstr/5.
1854
1855       update_c_call(Old::cerl(),    Module::cerl(),    Name::cerl(),    Argu‐
1856       ments::[cerl()]) -> cerl()
1857
1858              See also: c_call/3.
1859
1860       update_c_case(Old::cerl(),  Argument::cerl(),   Clauses::[cerl()])   ->
1861       cerl()
1862
1863              See also: c_case/2.
1864
1865       update_c_catch(Old::cerl(), Body::cerl()) -> cerl()
1866
1867              See also: c_catch/1.
1868
1869       update_c_clause(Old::cerl(),     Patterns::[cerl()],     Guard::cerl(),
1870       Body::cerl()) -> cerl()
1871
1872              See also: c_clause/3.
1873
1874       update_c_cons(Old::cerl(), Head::cerl(), Tail::cerl()) -> cerl()
1875
1876              See also: c_cons/2.
1877
1878       update_c_cons_skel(Old::cerl(), Head::cerl(), Tail::cerl()) -> cerl()
1879
1880              See also: c_cons_skel/2.
1881
1882       update_c_fname(Old::cerl(), Name::atom()) -> cerl()
1883
1884              Like update_c_fname/3, but takes the arity from Node.
1885
1886              See also: c_fname/2, update_c_fname/3.
1887
1888       update_c_fname(Old::cerl(), Name::atom(), Arity::arity()) -> cerl()
1889
1890              Equivalent to update_c_var(Old, {Atom, Arity}).
1891
1892              See also: c_fname/2, update_c_fname/2.
1893
1894       update_c_fun(Old::cerl(), Variables::[cerl()], Body::cerl()) -> cerl()
1895
1896              See also: c_fun/2.
1897
1898       update_c_let(Node::c_let(),   Variables::[cerl()],    Argument::cerl(),
1899       Body::cerl()) -> c_let()
1900
1901              See also: c_let/3.
1902
1903       update_c_letrec(Old::cerl(),      Definitions::[{cerl(),      cerl()}],
1904       Body::cerl()) -> cerl()
1905
1906              See also: c_letrec/2.
1907
1908       update_c_map(C_map::c_map(),  M::cerl(),  Es::[cerl()])  ->  c_map()  |
1909       c_literal()
1910
1911       update_c_map_pair(Old::c_map_pair(),      Op::map_op(),      K::cerl(),
1912       V::cerl()) -> c_map_pair()
1913
1914       update_c_module(Old::cerl(), Name::cerl(), Exports,  Attrs::Attributes,
1915       Es::Definitions) -> cerl()
1916
1917              Types:
1918
1919                 Exports = [cerl()]
1920                 Attributes = [{cerl(), cerl()}]
1921                 Definitions = [{cerl(), cerl()}]
1922
1923              See also: c_module/4.
1924
1925       update_c_primop(Old::cerl(),   Name::cerl(),   Arguments::[cerl()])  ->
1926       cerl()
1927
1928              See also: c_primop/2.
1929
1930       update_c_receive(Old::cerl(), Clauses::[cerl()],  Timeout::cerl(),  Ac‐
1931       tion::cerl()) -> cerl()
1932
1933              See also: c_receive/3.
1934
1935       update_c_seq(Old::cerl(), Argument::cerl(), Body::cerl()) -> cerl()
1936
1937              See also: c_seq/2.
1938
1939       update_c_try(Old::cerl(),    Expression::cerl(),   Variables::[cerl()],
1940       Body::cerl(), EVars::[cerl()], Handler::cerl()) -> cerl()
1941
1942              See also: c_try/5.
1943
1944       update_c_tuple(Old::cerl(), Elements::[cerl()]) -> cerl()
1945
1946              See also: c_tuple/1.
1947
1948       update_c_tuple_skel(Old::cerl(), Elements::[cerl()]) -> cerl()
1949
1950              See also: c_tuple_skel/1.
1951
1952       update_c_values(Old::cerl(), Elements::[cerl()]) -> cerl()
1953
1954              See also: c_values/1.
1955
1956       update_c_var(Old::cerl(), Name::var_name()) -> cerl()
1957
1958              See also: c_var/1.
1959
1960       update_data(Old::cerl(), Type::dtype(), Elements::[cerl()]) -> cerl()
1961
1962              See also: make_data/2.
1963
1964       update_data_skel(Old::cerl(),  Type::dtype(),  Elements::[cerl()])   ->
1965       cerl()
1966
1967              See also: make_data_skel/2.
1968
1969       update_list(Old::cerl(), List::[cerl()]) -> cerl()
1970
1971              Equivalent to update_list(Old, List, none).
1972
1973       update_list(Old::cerl(), List::[cerl()], Tail) -> cerl()
1974
1975              Types:
1976
1977                 Tail = cerl() | none
1978
1979              See also: make_list/2, update_list/2.
1980
1981       update_tree(Old::cerl(), Groups::[[cerl()]]) -> cerl()
1982
1983              Creates a syntax tree with the given subtrees, and the same type
1984              and  annotations  as  the  Old  node.  This  is  equivalent   to
1985              ann_make_tree(get_ann(Node),  type(Node),  Groups),  but  poten‐
1986              tially more efficient.
1987
1988              See also: ann_make_tree/3, get_ann/1, type/1, update_tree/3.
1989
1990       update_tree(Old::cerl(), Type::ctype(), Groups::[[cerl()]]) -> cerl()
1991
1992              Creates a syntax tree with the given type and subtrees, and  the
1993              same  annotations  as  the  Old  node.  This  is  equivalent  to
1994              ann_make_tree(get_ann(Node), Type, Groups), but potentially more
1995              efficient.
1996
1997              See also: ann_make_tree/3, get_ann/1, update_tree/2.
1998
1999       values_arity(Node::cerl()) -> integer()
2000
2001              Returns  the  number  of  element  subtrees of an abstract value
2002              list.
2003
2004              Note: This is equivalent to length(values_es(Node)), but  poten‐
2005              tially more efficient.
2006
2007              See also: c_values/1, values_es/1.
2008
2009       values_es(Node::cerl()) -> [cerl()]
2010
2011              Returns the list of element subtrees of an abstract value list.
2012
2013              See also: c_values/1, values_arity/1.
2014
2015       var_name(Node::cerl()) -> var_name()
2016
2017              Returns the name of an abstract variable.
2018
2019              See also: c_var/1.
2020

AUTHORS

2022       Richard Carlsson <carlsson.richard@gmail.com>
2023
2024
2025
2026                               compiler 7.6.9.1                        cerl(3)
Impressum