1erl_pp(3) Erlang Module Definition erl_pp(3)
2
3
4
6 erl_pp - The Erlang pretty printer.
7
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
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()} |
39 {encoding, latin1 | unicode | utf8} |
40 {quote_singleton_atom_types, boolean()}
41
42 The option quote_singleton_atom_types is used to add quotes to
43 all singleton atom types.
44
45 options() = hook_function() | [option()]
46
48 attribute(Attribute) -> io_lib:chars()
49
50 attribute(Attribute, Options) -> io_lib:chars()
51
52 Types:
53
54 Attribute = erl_parse:abstract_form()
55 Options = options()
56
57 Same as form/1,2, but only for attribute Attribute.
58
59 expr(Expression) -> io_lib:chars()
60
61 expr(Expression, Options) -> io_lib:chars()
62
63 expr(Expression, Indent, Options) -> io_lib:chars()
64
65 expr(Expression, Indent, Precedence, Options) -> io_lib:chars()
66
67 Types:
68
69 Expression = erl_parse:abstract_expr()
70 Indent = integer()
71 Precedence = integer() >= 0
72 Options = options()
73
74 Prints one expression. It is useful for implementing hooks (see
75 section Known Limitations).
76
77 exprs(Expressions) -> io_lib:chars()
78
79 exprs(Expressions, Options) -> io_lib:chars()
80
81 exprs(Expressions, Indent, Options) -> io_lib:chars()
82
83 Types:
84
85 Expressions = [erl_parse:abstract_expr()]
86 Indent = integer()
87 Options = options()
88
89 Same as form/1,2, but only for the sequence of expressions in
90 Expressions.
91
92 form(Form) -> io_lib:chars()
93
94 form(Form, Options) -> io_lib:chars()
95
96 Types:
97
98 Form = erl_parse:abstract_form() | erl_parse:form_info()
99 Options = options()
100
101 Pretty prints a Form, which is an abstract form of a type that
102 is returned by erl_parse:parse_form/1.
103
104 function(Function) -> io_lib:chars()
105
106 function(Function, Options) -> io_lib:chars()
107
108 Types:
109
110 Function = erl_parse:abstract_form()
111 Options = options()
112
113 Same as form/1,2, but only for function Function.
114
115 guard(Guard) -> io_lib:chars()
116
117 guard(Guard, Options) -> io_lib:chars()
118
119 Types:
120
121 Guard = [erl_parse:abstract_expr()]
122 Options = options()
123
124 Same as form/1,2, but only for the guard test Guard.
125
127 It is not possible to have hook functions for unknown forms at other
128 places than expressions.
129
131 erl_eval(3), erl_parse(3), io(3)
132
133
134
135Ericsson AB stdlib 3.10 erl_pp(3)