summaryrefslogtreecommitdiff
path: root/lib/stdlib/doc/src/erl_pp.xml
blob: c9d9e2723d4d069f69bbe43b5a410e822bd85728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>1996</year>
      <year>2013</year>
      <holder>Ericsson AB, All Rights Reserved</holder>
    </copyright>
    <legalnotice>
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  The Initial Developer of the Original Code is Ericsson AB.
    </legalnotice>

    <title>erl_pp</title>
    <prepared>Robert Virding</prepared>
    <responsible>Bjarne D&auml;cker</responsible>
    <docno>1</docno>
    <approved>Bjarne D&auml;cker</approved>
    <checked></checked>
    <date>97-01-24</date>
    <rev>B</rev>
    <file>erl_pp.sgml</file>
  </header>
  <module>erl_pp</module>
  <modulesummary>The Erlang Pretty Printer</modulesummary>
  <description>
    <p>The functions in this module are used to generate
      aesthetically attractive representations of abstract
      forms, which are suitable for printing. All functions return (possibly deep)
      lists of characters and generate an error if the form is wrong.</p>
    <p>All functions can have an optional argument which specifies a hook
      that is called if an attempt is made to print an unknown form.</p>
  </description>
  <datatypes>
    <datatype>
      <name name="hook_function"/>
      <desc>
        <p>The optional argument <marker id="hook_function">
          <c>HookFunction</c></marker>, shown in the functions described below,
          defines a function which is called when an unknown form occurs where there
          should be a valid expression.</p>

        <p>If <c>HookFunction</c> is equal to <c>none</c> there is no hook
           function.</p>

        <p>The called hook function should return a (possibly deep) list
          of characters. <seealso marker="#expr/4"><c>expr/4</c></seealso>
          is useful in a hook.
          </p>
        <p>If <c><anno>CurrentIndentation</anno></c> is negative, there will be no line
          breaks and only a space is used as a separator.</p>
      </desc>
    </datatype>
    <datatype>
      <name name="option"/>
    </datatype>
    <datatype>
      <name name="options"/>
    </datatype>
  </datatypes>
  <funcs>
    <func>
      <name name="form" arity="1"/>
      <name name="form" arity="2"/>
      <fsummary>Pretty print a form</fsummary>
      <desc>
        <p>Pretty prints a 
          <c><anno>Form</anno></c> which is an abstract form of a type which is
          returned by <seealso marker="erl_parse#parse_form/1">
          <c>erl_parse:parse_form/1</c></seealso>.</p>
      </desc>
    </func>
    <func>
      <name name="attribute" arity="1"/>
      <name name="attribute" arity="2"/>
      <fsummary>Pretty print an attribute</fsummary>
      <desc>
        <p>The same as <c>form</c>, but only for the attribute
          <c><anno>Attribute</anno></c>.</p>
      </desc>
    </func>
    <func>
      <name name="function" arity="1"/>
      <name name="function" arity="2"/>
      <fsummary>Pretty print a function</fsummary>
      <desc>
        <p>The same as <c>form</c>, but only for the function
          <c><anno>Function</anno></c>.</p>
      </desc>
    </func>
    <func>
      <name name="guard" arity="1"/>
      <name name="guard" arity="2"/>
      <fsummary>Pretty print a guard</fsummary>
      <desc>
        <p>The same as <c>form</c>, but only for the guard test
          <c><anno>Guard</anno></c>.</p>
      </desc>
    </func>
    <func>
      <name name="exprs" arity="1"/>
      <name name="exprs" arity="2"/>
      <name name="exprs" arity="3"/>
      <fsummary>Pretty print <c>Expressions</c></fsummary>
      <desc>
        <p>The same as <c>form</c>, but only for the sequence of
          expressions in <c><anno>Expressions</anno></c>.</p>
      </desc>
    </func>
    <func>
      <name name="expr" arity="1"/>
      <name name="expr" arity="2"/>
      <name name="expr" arity="3"/>
      <name name="expr" arity="4"/>
      <fsummary>Pretty print one <c>Expression</c></fsummary>
      <desc>
        <p>This function prints one expression. It is useful for implementing hooks (see below).</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>Bugs</title>
    <p>It should be possible to have hook functions for unknown forms
      at places other than expressions.</p>
  </section>

  <section>
    <title>See Also</title>
    <p><seealso marker="io">io(3)</seealso>,
      <seealso marker="erl_parse">erl_parse(3)</seealso>,
      <seealso marker="erl_eval">erl_eval(3)</seealso></p>
  </section>
</erlref>