~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/stdlib/doc/src/erl_parse.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1996</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>erl_parse</title>
 
27
    <prepared>Robert</prepared>
 
28
    <responsible>Bjarne D&auml;cker</responsible>
 
29
    <docno>1</docno>
 
30
    <approved>Bjarne D&auml;cker</approved>
 
31
    <checked></checked>
 
32
    <date>97-01-24</date>
 
33
    <rev>B</rev>
 
34
    <file>erl_parse.sgml</file>
 
35
  </header>
 
36
  <module>erl_parse</module>
 
37
  <modulesummary>The Erlang Parser</modulesummary>
 
38
  <description>
 
39
    <p>This module is the basic Erlang parser which converts tokens into
 
40
      the abstract form of either forms (i.e., top-level constructs),
 
41
      expressions, or terms. The Abstract Format is described in the ERTS
 
42
      User's Guide.
 
43
      Note that a token list must end with the <em>dot</em> token in order
 
44
      to be acceptable to the parse functions (see erl_scan).</p>
 
45
  </description>
 
46
  <funcs>
 
47
    <func>
 
48
      <name>parse_form(Tokens) -> {ok, AbsForm} | {error, ErrorInfo}</name>
 
49
      <fsummary>Parse an Erlang form</fsummary>
 
50
      <type>
 
51
        <v>Tokens = [Token]</v>
 
52
        <v>Token = {Tag,Line} | {Tag,Line,term()}</v>
 
53
        <v>Tag = atom()</v>
 
54
        <v>AbsForm = term()</v>
 
55
        <v>ErrorInfo = see section Error Information below.</v>
 
56
      </type>
 
57
      <desc>
 
58
        <p>This function parses <c>Tokens</c> as if it were a form. It returns:</p>
 
59
        <taglist>
 
60
          <tag><c>{ok, AbsForm}</c></tag>
 
61
          <item>
 
62
            <p>The parsing was successful. <c>AbsForm</c> is the
 
63
              abstract form of the parsed form.</p>
 
64
          </item>
 
65
          <tag><c>{error, ErrorInfo}</c></tag>
 
66
          <item>
 
67
            <p>An error occurred.</p>
 
68
          </item>
 
69
        </taglist>
 
70
      </desc>
 
71
    </func>
 
72
    <func>
 
73
      <name>parse_exprs(Tokens) -> {ok, Expr_list} | {error, ErrorInfo}</name>
 
74
      <fsummary>Parse Erlang expressions</fsummary>
 
75
      <type>
 
76
        <v>Tokens = [Token]</v>
 
77
        <v>Token = {Tag,Line} | {Tag,Line,term()}</v>
 
78
        <v>Tag = atom()</v>
 
79
        <v>Expr_list = [AbsExpr]</v>
 
80
        <v>AbsExpr = term()</v>
 
81
        <v>ErrorInfo = see section Error Information below.</v>
 
82
      </type>
 
83
      <desc>
 
84
        <p>This function parses <c>Tokens</c> as if it were a list of expressions. It returns:</p>
 
85
        <taglist>
 
86
          <tag><c>{ok, Expr_list}</c></tag>
 
87
          <item>
 
88
            <p>The parsing was successful. <c>Expr_list</c> is a
 
89
              list of the abstract forms of the parsed expressions.</p>
 
90
          </item>
 
91
          <tag><c>{error, ErrorInfo}</c></tag>
 
92
          <item>
 
93
            <p>An error occurred.</p>
 
94
          </item>
 
95
        </taglist>
 
96
      </desc>
 
97
    </func>
 
98
    <func>
 
99
      <name>parse_term(Tokens) -> {ok, Term} | {error, ErrorInfo}</name>
 
100
      <fsummary>Parse an Erlang term</fsummary>
 
101
      <type>
 
102
        <v>Tokens = [Token]</v>
 
103
        <v>Token = {Tag,Line} | {Tag,Line,term()}</v>
 
104
        <v>Tag = atom()</v>
 
105
        <v>Term = term()</v>
 
106
        <v>ErrorInfo = see section Error Information below.</v>
 
107
      </type>
 
108
      <desc>
 
109
        <p>This function parses <c>Tokens</c> as if it were a term. It returns:</p>
 
110
        <taglist>
 
111
          <tag><c>{ok, Term}</c></tag>
 
112
          <item>
 
113
            <p>The parsing was successful. <c>Term</c> is
 
114
              the Erlang term corresponding to the token list.</p>
 
115
          </item>
 
116
          <tag><c>{error, ErrorInfo}</c></tag>
 
117
          <item>
 
118
            <p>An error occurred.</p>
 
119
          </item>
 
120
        </taglist>
 
121
      </desc>
 
122
    </func>
 
123
    <func>
 
124
      <name>format_error(ErrorDescriptor) -> Chars</name>
 
125
      <fsummary>Format an error descriptor</fsummary>
 
126
      <type>
 
127
        <v>ErrorDescriptor = errordesc()</v>
 
128
        <v>Chars = [char() | Chars]</v>
 
129
      </type>
 
130
      <desc>
 
131
        <p>Uses an <c>ErrorDescriptor</c> and returns a string
 
132
          which describes the error. This function is usually called
 
133
          implicitly when an <c>ErrorInfo</c> structure is processed
 
134
          (see below).</p>
 
135
      </desc>
 
136
    </func>
 
137
    <func>
 
138
      <name>tokens(AbsTerm) -> Tokens</name>
 
139
      <name>tokens(AbsTerm, MoreTokens) -> Tokens</name>
 
140
      <fsummary>Generate a list of tokens for an expression</fsummary>
 
141
      <type>
 
142
        <v>Tokens = MoreTokens = [Token]</v>
 
143
        <v>Token = {Tag,Line} | {Tag,Line,term()}</v>
 
144
        <v>Tag = atom()</v>
 
145
        <v>AbsTerm = term()</v>
 
146
        <v>ErrorInfo = see section Error Information below.</v>
 
147
      </type>
 
148
      <desc>
 
149
        <p>This function generates a list of tokens representing the abstract
 
150
          form <c>AbsTerm</c> of an expression. Optionally, it appends
 
151
          <c>Moretokens</c>.</p>
 
152
      </desc>
 
153
    </func>
 
154
    <func>
 
155
      <name>normalise(AbsTerm) -> Data</name>
 
156
      <fsummary>Convert abstract form to an Erlang term</fsummary>
 
157
      <type>
 
158
        <v>AbsTerm = Data = term()</v>
 
159
      </type>
 
160
      <desc>
 
161
        <p>Converts the abstract form <c>AbsTerm</c> of a term into a
 
162
          conventional Erlang data structure (i.e., the term itself).
 
163
          This is the inverse of <c>abstract/1</c>.</p>
 
164
      </desc>
 
165
    </func>
 
166
    <func>
 
167
      <name>abstract(Data) -> AbsTerm</name>
 
168
      <fsummary>Convert an Erlang term into an abstract form</fsummary>
 
169
      <type>
 
170
        <v>Data = AbsTerm = term()</v>
 
171
      </type>
 
172
      <desc>
 
173
        <p>Converts the Erlang data structure <c>Data</c> into an
 
174
          abstract form of type <c>AbsTerm</c>. This is the inverse of
 
175
          <c>normalise/1</c>.</p>
 
176
      </desc>
 
177
    </func>
 
178
  </funcs>
 
179
 
 
180
  <section>
 
181
    <title>Error Information</title>
 
182
    <p>The <c>ErrorInfo</c> mentioned above is the standard
 
183
      <c>ErrorInfo</c> structure which is returned from all IO
 
184
      modules. It has the format:
 
185
      </p>
 
186
    <code type="none">
 
187
    {ErrorLine, Module, ErrorDescriptor}    </code>
 
188
    <p>A string which describes the error is obtained with the following call:
 
189
      </p>
 
190
    <code type="none">
 
191
apply(Module, format_error, ErrorDescriptor)    </code>
 
192
  </section>
 
193
 
 
194
  <section>
 
195
    <title>See Also</title>
 
196
    <p><seealso marker="io">io(3)</seealso>,
 
197
      <seealso marker="erl_scan">erl_scan(3)</seealso>,
 
198
      ERTS User's Guide</p>
 
199
  </section>
 
200
</erlref>
 
201