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  un‐
28              known  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()} |
39           {encoding, latin1 | unicode | utf8} |
40           {quote_singleton_atom_types, boolean()} |
41           {linewidth, integer() >= 1} |
42           {indent, integer() >= 1}
43
44              The option quote_singleton_atom_types is used to add  quotes  to
45              all singleton atom types.
46
47              The option linewidth controls the maximum line width for format‐
48              ted lines (defaults to 72 characters).
49
50              The option indent controls the  indention  for  formatted  lines
51              (defaults to 4 spaces).
52
53       options() = hook_function() | [option()]
54

EXPORTS

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

KNOWN LIMITATIONS

135       It is not possible to have hook functions for unknown  forms  at  other
136       places than expressions.
137

SEE ALSO

139       erl_eval(3), erl_parse(3), io(3)
140
141
142
143Ericsson AB                      stdlib 3.16.1                       erl_pp(3)
Impressum