aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/doc/src/epp.xml
blob: 8cc977681fb5d837129a5fb85fa3b0254b57508e (plain) (blame)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>1996</year><year>2014</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>epp</title>
    <prepared>Kenneth Lundin</prepared>
    <responsible>Kenneth Lundin</responsible>
    <docno>1</docno>
    <approved>Kenneth Lundin</approved>
    <checked></checked>
    <date>97-01-31</date>
    <rev>B</rev>
    <file>epp.sgml</file>
  </header>
  <module>epp</module>
  <modulesummary>An Erlang Code Preprocessor</modulesummary>
  <description>
    <p>The Erlang code preprocessor includes functions which are used
      by <c>compile</c> to preprocess macros and include files before
      the actual parsing takes place.</p>
    <p>The Erlang source file <marker
      id="encoding"><em>encoding</em></marker> is selected by a
      comment in one of the first two lines of the source file. The
      first string that matches the regular expression
      <c>coding\s*[:=]\s*([-a-zA-Z0-9])+</c> selects the encoding. If
      the matching string is not a valid encoding it is ignored. The
      valid encodings are <c>Latin-1</c> and <c>UTF-8</c> where the
      case of the characters can be chosen freely. Examples:</p>
      <pre>
%% coding: utf-8</pre>
      <pre>
%% For this file we have chosen encoding = Latin-1</pre>
      <pre>
%% -*- coding: latin-1 -*-</pre>
  </description>
  <datatypes>
    <datatype>
      <name name="macros"></name>
    </datatype>
    <datatype>
      <name name="epp_handle"></name>
      <desc><p>Handle to the epp server.</p></desc>
    </datatype>
    <datatype>
      <name name="source_encoding"></name>
    </datatype>
  </datatypes>
  <funcs>
    <func>
      <name name="open" arity="2"/>
      <name name="open" arity="3"/>
      <fsummary>Open a file for preprocessing</fsummary>
      <desc>
        <p>Opens a file for preprocessing.</p>
      </desc>
    </func>
    <func>
      <name name="close" arity="1"/>
      <fsummary>Close the preprocessing of the file associated with <c>Epp</c></fsummary>
      <desc>
        <p>Closes the preprocessing of a file.</p>
      </desc>
    </func>
    <func>
      <name name="parse_erl_form" arity="1"/>
      <fsummary>Return the next Erlang form from the opened Erlang source file</fsummary>
      <desc>
        <p>Returns the next Erlang form from the opened Erlang source file.
          The tuple <c>{eof, <anno>Line</anno>}</c> is returned at end-of-file. The first
          form corresponds to an implicit attribute <c>-file(File,1).</c>, where
          <c>File</c> is the name of the file.</p>
      </desc>
    </func>
    <func>
      <name name="parse_file" arity="3"/>
      <fsummary>Preprocess and parse an Erlang source file</fsummary>
      <desc>
        <p>Preprocesses and parses an Erlang source file.
          Note that the tuple <c>{eof, <anno>Line</anno>}</c> returned at end-of-file is
          included as a "form".</p>
      </desc>
    </func>
    <func>
      <name name="default_encoding" arity="0"/>
      <fsummary>Return the default encoding of Erlang source files</fsummary>
      <desc>
        <p>Returns the default encoding of Erlang source files.</p>
      </desc>
    </func>
    <func>
      <name name="encoding_to_string" arity="1"/>
      <fsummary>Return a string representation of an encoding</fsummary>
      <desc>
        <p>Returns a string representation of an encoding. The string
        is recognized by <c>read_encoding/1,2</c>,
        <c>read_encoding_from_binary/1,2</c>, and
        <c>set_encoding/1</c> as a valid encoding.</p>
      </desc>
    </func>
    <func>
      <name name="read_encoding" arity="1"/>
      <name name="read_encoding" arity="2"/>
      <fsummary>Read the encoding from a file</fsummary>
      <desc>
        <p>Read the <seealso marker="#encoding">encoding</seealso> from
          a file. Returns the read encoding, or <c>none</c> if no
          valid encoding was found.</p>
        <p>The option <c>in_comment_only</c> is <c>true</c> by
          default, which is correct for Erlang source files. If set to
          <c>false</c> the encoding string does not necessarily have to
          occur in a comment.</p>
      </desc>
    </func>
    <func>
      <name name="read_encoding_from_binary" arity="1"/>
      <name name="read_encoding_from_binary" arity="2"/>
      <fsummary>Read the encoding from a binary</fsummary>
      <desc>
        <p>Read the <seealso marker="#encoding">encoding</seealso> from
          a binary. Returns the read encoding, or <c>none</c> if no
          valid encoding was found.</p>
        <p>The option <c>in_comment_only</c> is <c>true</c> by
          default, which is correct for Erlang source files. If set to
          <c>false</c> the encoding string does not necessarily have to
          occur in a comment.</p>
      </desc>
    </func>
    <func>
      <name name="set_encoding" arity="1"/>
      <fsummary>Read and set the encoding of an IO device</fsummary>
      <desc>
        <p>Reads the <seealso marker="#encoding">encoding</seealso> from
          an IO device and sets the encoding of the device
          accordingly. The position of the IO device referenced by
          <c><anno>File</anno></c> is not affected. If no valid
          encoding can be read from the IO device the encoding of the
          IO device is set to the default encoding.</p>
        <p>Returns the read encoding, or <c>none</c> if no valid
          encoding was found.</p>
      </desc>
    </func>
    <func>
      <name name="format_error" arity="1"/>
      <fsummary>Format an error descriptor</fsummary>
      <desc>
        <p>Takes an <c><anno>ErrorDescriptor</anno></c> and returns
          a string which
          describes the error or warning. This function is usually
          called implicitly when processing an <c>ErrorInfo</c>
          structure (see below).</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>Error Information</title>
    <p>The <c>ErrorInfo</c> mentioned above is the standard
      <c>ErrorInfo</c> structure which is returned from all IO
      modules. It has the following format:
      </p>
    <code type="none">
    {ErrorLine, Module, ErrorDescriptor}    </code>
    <p>A string which describes the error is obtained with the following call:
      </p>
    <code type="none">
    Module:format_error(ErrorDescriptor)    </code>
  </section>

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