File: erl_parse.html

package info (click to toggle)
erlang-doc-html 1%3A8.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 18,028 kB
  • ctags: 7,419
  • sloc: perl: 1,841; ansic: 323; erlang: 155
file content (181 lines) | stat: -rw-r--r-- 5,919 bytes parent folder | download
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
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>erl_parse</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>


<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>erl_parse</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
erl_parse</UL>
<H3>MODULE SUMMARY</H3>
<UL>
The Erlang Parser</UL>
<H3>DESCRIPTION</H3>
<UL>
<P>This module is the basic Erlang parser which converts tokens into
the abstract form of either forms (i.e., top-level constructs),
expressions, or terms.
Note that a token list must end with the <STRONG>dot</STRONG> token in order
to be acceptable to the parse functions (see erl_scan).
</UL>
<H3>EXPORTS</H3>
<P><A NAME="parse_form%1"><STRONG><CODE>parse_form(Tokens) -&#62; {ok, AbsForm} | {error, ErrorInfo}</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Tokens = [Token]</CODE></STRONG><BR>
<STRONG><CODE>Token = {Tag,Line} | {Tag,Line,term()}</CODE></STRONG><BR>
<STRONG><CODE>Tag = atom()</CODE></STRONG><BR>
<STRONG><CODE>AbsForm = term()</CODE></STRONG><BR>
<STRONG><CODE>ErrorInfo = see section Error Information below.</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function parses <CODE>Tokens</CODE> as if it were a form. It returns:
<P><DL>
<DT><CODE>{ok, AbsForm}</CODE></DT>
<DD> The parsing was successful. See section <A HREF="#ABSFORM">Abstract Form</A> below for a
description of <CODE>AbsForm</CODE>.
<BR>
</DD>
<DT><CODE>{error, ErrorInfo}</CODE></DT>
<DD>An error occurred.<BR>
</DD>
</DL>
</UL>
<P><A NAME="parse_exprs%1"><STRONG><CODE>parse_exprs(Tokens) -&#62; {ok, Expr_list} | {error, ErrorInfo}</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Tokens = [Token]</CODE></STRONG><BR>
<STRONG><CODE>Token = {Tag,Line} | {Tag,Line,term()}</CODE></STRONG><BR>
<STRONG><CODE>Tag = atom()</CODE></STRONG><BR>
<STRONG><CODE>Expr_list = [AbsExpr]</CODE></STRONG><BR>
<STRONG><CODE>AbsExpr = term()</CODE></STRONG><BR>
<STRONG><CODE>ErrorInfo = see section Error Information below.</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function parses <CODE>Tokens</CODE> as if it were a list of expressions. It returns:
<P><DL>
<DT><CODE>{ok, Expr_list}</CODE></DT>
<DD> The parsing was successful. <CODE>Expr_list</CODE> is a list
of the form <CODE>AbsExpr</CODE>, which is described in the
section <A HREF="#ABSFORM">Abstract
Form</A> below.
<BR>
</DD>
<DT><CODE>{error, ErrorInfo}</CODE></DT>
<DD>An error occurred.<BR>
</DD>
</DL>
</UL>
<P><A NAME="parse_term%1"><STRONG><CODE>parse_term(Tokens) -&#62; {ok, Term} | {error, ErrorInfo}</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Tokens = [Token]</CODE></STRONG><BR>
<STRONG><CODE>Token = {Tag,Line} | {Tag,Line,term()}</CODE></STRONG><BR>
<STRONG><CODE>Tag = atom()</CODE></STRONG><BR>
<STRONG><CODE>Term = term()</CODE></STRONG><BR>
<STRONG><CODE>ErrorInfo = see section Error Information below.</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function parses <CODE>Tokens</CODE> as if it were a term. It returns:
<P><DL>
<DT><CODE>{ok, Term}</CODE></DT>
<DD> The parsing was successful. <CODE>Term</CODE> is
         the Erlang term corresponding to the token list.
<BR>
</DD>
<DT><CODE>{error, ErrorInfo}</CODE></DT>
<DD>An error occurred.<BR>

</DD>
</DL>
</UL>
<P><A NAME="format_error%1"><STRONG><CODE>format_error(ErrorDescriptor) -&#62; string()</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>ErrorDescriptor = errordesc()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Uses an <CODE>ErrorDescriptor</CODE> and returns a string
which describes the error. This function is usually called
implicitly when an <CODE>ErrorInfo</CODE> structure is processed
(see below).
</UL>
<P><A NAME="tokens%1"><STRONG><CODE>tokens(AbsTerm) -&#62; Tokens</CODE></STRONG></A><BR>
<A NAME="tokens%2"><STRONG><CODE>tokens(AbsTerm, MoreTokens) -&#62; Tokens</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Tokens = MoreTokens = [Token]</CODE></STRONG><BR>
<STRONG><CODE>Token = {Tag,Line} | {Tag,Line,term()}</CODE></STRONG><BR>
<STRONG><CODE>Tag = atom()</CODE></STRONG><BR>
<STRONG><CODE>AbsTerm = term()</CODE></STRONG><BR>
<STRONG><CODE>ErrorInfo = see section Error Information below.</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function generates a list of tokens representing the abstract
        form <CODE>AbsTerm</CODE> of an expression. Optionally, it appends
        <CODE>Moretokens</CODE>.
</UL>
<P><A NAME="normalise%1"><STRONG><CODE>normalise(AbsTerm) -&#62; Data</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>AbsTerm = Data = term()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Converts the abstract form <CODE>AbsTerm</CODE> of a term into a
conventional Erlang data structure (i.e., the term itself).
         This is the inverse of <CODE>abstract/1</CODE>.
</UL>
<P><A NAME="abstract%1"><STRONG><CODE>abstract(Data) -&#62; AbsTerm</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Data = AbsTerm = term()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Converts the Erlang data structure <CODE>Data</CODE> into an
abstract form of type <CODE>AbsTerm</CODE>. This is the inverse of
         <CODE>normalise/1</CODE>.
</UL>
<H3>Abstract Form</H3>
<UL>
<A NAME="ABSFORM"><!-- Empty --></A><P>To be supplied</UL>
<H3>Error Information</H3>
<UL>
<P>The <CODE>ErrorInfo</CODE> mentioned above is the standard
<CODE>ErrorInfo</CODE> structure which is returned from all IO
modules. It has the format:

<PRE>    {ErrorLine, Module, ErrorDescriptor}</PRE><P>A string which describes the error is obtained with the following call:

<PRE>apply(Module, format_error, ErrorDescriptor)</PRE></UL>
<H3>See Also</H3>
<UL>
<P><A HREF="io.html">io</A>,
<A HREF="erl_scan.html">erl_scan</A>
</UL>
<H3>AUTHORS</H3>
<UL>
Robert Virding - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright &copy; 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>