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

NAME

6       erl_pp - The Erlang pretty printer.
7

DESCRIPTION

9       The functions in this module are used to generate aesthetically attrac‐
10       tive representations of abstract forms, which are suitable  for  print‐
11       ing.  All functions return (possibly deep) lists of characters and gen‐
12       erate an error if the form is wrong.
13
14       All functions can have an optional argument,  which  specifies  a  hook
15       that is called if an attempt is made to print an unknown form.
16

DATA TYPES

18       hook_function() =
19           none |
20           fun((Expr :: erl_parse:abstract_expr(),
21                CurrentIndentation :: integer(),
22                CurrentPrecedence :: integer() >= 0,
23                Options :: options()) ->
24                   io_lib:chars())
25
26              Optional argument HookFunction, shown in the functions described
27              in this module, defines  a  function  that  is  called  when  an
28              unknown  form occurs where there is to be a valid expression. If
29              HookFunction is equal to none, there is no hook function.
30
31              The called hook function is to return a (possibly deep) list  of
32              characters. Function expr/4 is useful in a hook.
33
34              If  CurrentIndentation is negative, there are no line breaks and
35              only a space is used as a separator.
36
37       option() =
38           {hook, hook_function()} | {encoding, latin1 | unicode | utf8}
39
40       options() = hook_function() | [option()]
41

EXPORTS

43       attribute(Attribute) -> io_lib:chars()
44
45       attribute(Attribute, Options) -> io_lib:chars()
46
47              Types:
48
49                 Attribute = erl_parse:abstract_form()
50                 Options = options()
51
52              Same as form/1,2, but only for attribute Attribute.
53
54       expr(Expression) -> io_lib:chars()
55
56       expr(Expression, Options) -> io_lib:chars()
57
58       expr(Expression, Indent, Options) -> io_lib:chars()
59
60       expr(Expression, Indent, Precedence, Options) -> io_lib:chars()
61
62              Types:
63
64                 Expression = erl_parse:abstract_expr()
65                 Indent = integer()
66                 Precedence = integer() >= 0
67                 Options = options()
68
69              Prints one expression. It is useful for implementing hooks  (see
70              section Known Limitations).
71
72       exprs(Expressions) -> io_lib:chars()
73
74       exprs(Expressions, Options) -> io_lib:chars()
75
76       exprs(Expressions, Indent, Options) -> io_lib:chars()
77
78              Types:
79
80                 Expressions = [erl_parse:abstract_expr()]
81                 Indent = integer()
82                 Options = options()
83
84              Same  as  form/1,2,  but only for the sequence of expressions in
85              Expressions.
86
87       form(Form) -> io_lib:chars()
88
89       form(Form, Options) -> io_lib:chars()
90
91              Types:
92
93                 Form = erl_parse:abstract_form() | erl_parse:form_info()
94                 Options = options()
95
96              Pretty prints a Form, which is an abstract form of a  type  that
97              is returned by erl_parse:parse_form/1.
98
99       function(Function) -> io_lib:chars()
100
101       function(Function, Options) -> io_lib:chars()
102
103              Types:
104
105                 Function = erl_parse:abstract_form()
106                 Options = options()
107
108              Same as form/1,2, but only for function Function.
109
110       guard(Guard) -> io_lib:chars()
111
112       guard(Guard, Options) -> io_lib:chars()
113
114              Types:
115
116                 Guard = [erl_parse:abstract_expr()]
117                 Options = options()
118
119              Same as form/1,2, but only for the guard test Guard.
120

KNOWN LIMITATIONS

122       It  is  not  possible to have hook functions for unknown forms at other
123       places than expressions.
124

SEE ALSO

126       erl_eval(3), erl_parse(3), io(3)
127
128
129
130Ericsson AB                     stdlib 3.4.5.1                       erl_pp(3)
Impressum