8
8
< div class ="navbar "> < a name ="#navbar_top "> </ a > < table width ="100% " border ="0 " cellspacing ="0 " cellpadding ="2 " summary ="navigation bar "> < tr > < td > < a href ="overview-summary.html " target ="overviewFrame "> Overview</ a > </ td > < td > < a href ="http://www.erlang.org/ "> < img src ="erlang.png " align ="right " border ="0 " alt ="erlang logo "> </ a > </ td > </ tr > </ table > </ div >
9
9
< h1 > leex documentation</ h1 >
10
10
< p > Copyright © 2008 Robert Virding</ p >
11
- < p > < b > Version:</ b > 0.1
11
+ < p > < b > Version:</ b > 0.3
12
12
</ p >
13
13
< p > < b > Authors:</ b > Robert Virding (< a href ="mailto:rvirding@gmail.com "> < tt > rvirding@gmail.com</ tt > </ a > ).</ p >
14
14
@@ -25,22 +25,34 @@ <h4><a name="DESCRIPTION">DESCRIPTION</a></h4>
25
25
26
26
< h4 > < a name ="DATATYPES "> DATATYPES</ a > </ h4 >
27
27
28
- < pre > ScanRet = {ok,Tokens,EndLine} |
29
- {eof,EndLine} |
30
- {error,ErrorDescriptor,EndLine}
31
- Cont = continuation()
32
- ErrorDescriptor = {ErrorLine,Module,Error}</ pre >
28
+ < p > ScanRet = {ok,Tokens,EndLine} |
29
+ {eof,EndLine} |
30
+ {error,ErrorDescriptor,EndLine}</ p >
31
+
32
+ < p > Cont = continuation()</ p >
33
+
34
+ < p > ErrorDescriptor = {ErrorLine,Module,Error}</ p >
35
+
33
36
< h4 > < a name ="EXPORTS "> EXPORTS</ a > </ h4 >
34
37
35
- < p > file(FileName) -> ok | error
36
- file(FileName, Options) -> ok | error</ p >
38
+ < p > file(FileName) -> ok | error</ p >
39
+
40
+ < p > file(FileName, Options) -> ok | error</ p >
37
41
38
42
< p > The current options are:</ p >
39
43
44
+ < p > {includefile,File}
45
+ Use a specific or customised prologue file instead of
46
+ default leex/include/leexinc.hrl which is otherwise
47
+ included.</ p >
48
+
40
49
< p > {outdir,Dir} - generate the scanner file in directory Dir
41
50
dfa_graph - generate a .dot file which contains a
42
51
desciption of the DFA in a format which can be
43
- viewd with Graphviz, www.graphviz.com</ p >
52
+ viewd with Graphviz, www.graphviz.com
53
+ verbose
54
+ Output information from parsing the input file and
55
+ generating the internal tables.</ p >
44
56
45
57
< p > Generate a lexical analyzer from the definition in the input
46
58
file. The input file has the extension .xrl. This is added to
@@ -49,15 +61,17 @@ <h4><a name="EXPORTS">EXPORTS</a></h4>
49
61
50
62
< h4 > < a name ="GENERATED_SCANNER_EXPORTS "> GENERATED SCANNER EXPORTS</ a > </ h4 >
51
63
52
- < p > string(String) -> ScanRet
53
- string(String, StartLine) -> ScanRet</ p >
64
+ < p > string(String) -> ScanRet</ p >
65
+
66
+ < p > string(String, StartLine) -> ScanRet</ p >
54
67
55
68
< p > Scan String and return all the tokens in it, or an error.
56
69
N.B. it is an error if all of the characters in String are
57
70
consumed.</ p >
58
71
59
- < p > token(Cont, Chars) -> {more,Cont} | {done,ScanRet,RestChars}
60
- token(Cont, Chars, StartLine) -> {more,Cont} | {done,ScanRet,RestChars}</ p >
72
+ < p > token(Cont, Chars) -> {more,Cont} | {done,ScanRet,RestChars}</ p >
73
+
74
+ < p > token(Cont, Chars, StartLine) -> {more,Cont} | {done,ScanRet,RestChars}</ p >
61
75
62
76
< p > This is a re-entrant call to try and scan one token from
63
77
Chars. If there are enough characters in Chars to either scan
@@ -74,8 +88,9 @@ <h4><a name="GENERATED_SCANNER_EXPORTS">GENERATED SCANNER EXPORTS</a></h4>
74
88
< p > io:request(InFile, {get_until,Prompt,Module,token,[Line]})
75
89
-> ScanRet</ p >
76
90
77
- < p > tokens(Cont, Chars) -> {more,Cont} | {done,ScanRet,RestChars}
78
- tokens(Cont, Chars, StartLine) -> {more,Cont} | {done,ScanRet,RestChars}</ p >
91
+ < p > tokens(Cont, Chars) -> {more,Cont} | {done,ScanRet,RestChars}</ p >
92
+
93
+ < p > tokens(Cont, Chars, StartLine) -> {more,Cont} | {done,ScanRet,RestChars}</ p >
79
94
80
95
< p > This is a re-entrant call to try and scan tokens from Chars.
81
96
If there are enough characters in Chars to either scan tokens
@@ -169,16 +184,32 @@ <h5><a name="Input_File_Format">Input File Format</a></h5>
169
184
{error,ErrString} - an error in the token, ErrString is a string
170
185
describing the error</ p >
171
186
187
+ < p > It is also possible to push back characters into the input
188
+ characters with the following returns:</ p >
189
+
190
+ < p > {token,Token,PushBackList}
191
+ {end_token,Token,PushBackList}
192
+ {skip_token,PushBackList}</ p >
193
+
194
+ < p > These have the same meanings as the normal returns but the
195
+ characters in PushBackList will be prepended to the input
196
+ characters and scanned for the next token. Note that pushing
197
+ back a newline will mean the line numbering will no longer be
198
+ correct. N.B. Pushing back characters gives you unexpected
199
+ possibilities to cause the scanner to loop!</ p >
200
+
172
201
< p > The following example would match a simple Erlang integer or
173
202
float and return a token which could be sent to the Erlang
174
203
parser:</ p >
175
204
205
+
176
206
< p > D = [0-9]</ p >
177
207
178
208
< p > {D}+ : {token,{integer,
179
209
TokenLine,
180
- list_to_integer(TokenChars)}}.
181
- {D}+\.{D}+((E|e)(\+|\-)?{D}+)? :
210
+ list_to_integer(TokenChars)}}.</ p >
211
+
212
+ < p > {D}+\.{D}+((E|e)(\+|\-)?{D}+)? :
182
213
{token,{float,TokenLine,list_to_float(TokenChars)}}.</ p >
183
214
184
215
< p > The Erlang code in the "Erlang Code." section is written into
@@ -196,58 +227,80 @@ <h5><a name="Regular_Expressions">Regular Expressions</a></h5>
196
227
following characters:</ p >
197
228
198
229
< p > c
199
- matches the non-metacharacter c.
200
- \c
201
- matches the escape sequence or literal character c.
202
- .
203
- matches any character.
204
- ^
205
- matches the beginning of a string.
206
- $
207
- matches the end of a string.
208
- [abc...]
230
+ matches the non-metacharacter c.</ p >
231
+
232
+ < p > \c
233
+ matches the escape sequence or literal character c.</ p >
234
+
235
+ < p > .
236
+ matches any character.</ p >
237
+
238
+ < p > ^
239
+ matches the beginning of a string.</ p >
240
+
241
+ < p > $
242
+ matches the end of a string.</ p >
243
+
244
+ < p > [abc...]
209
245
character class, which matches any of the characters
210
246
abc... Character ranges are specified by a pair of
211
- characters separated by a -.
212
- [^abc...]
247
+ characters separated by a -.</ p >
248
+
249
+ < p > [^abc...]
213
250
negated character class, which matches any character
214
- except abc....
215
- r1 | r2
216
- alternation. It matches either r1 or r2.
217
- r1r2
218
- concatenation. It matches r1 and then r2.
219
- r+
220
- matches one or more rs.
221
- r*
222
- matches zero or more rs.
223
- r?
224
- matches zero or one rs.
225
- (r)
251
+ except abc....</ p >
252
+
253
+ < p > r1 | r2
254
+ alternation. It matches either r1 or r2.</ p >
255
+
256
+ < p > r1r2
257
+ concatenation. It matches r1 and then r2.</ p >
258
+
259
+ < p > r+
260
+ matches one or more rs.</ p >
261
+
262
+ < p > r*
263
+ matches zero or more rs.</ p >
264
+
265
+ < p > r?
266
+ matches zero or one rs.</ p >
267
+
268
+ < p > (r)
226
269
grouping. It matches r.</ p >
227
270
228
271
< p > The escape sequences allowed are the same as for Erlang strings:</ p >
229
272
230
273
< p > \b
231
- backspace
232
- \f
233
- form feed
234
- \n
235
- newline (line feed)
236
- \r
237
- carriage return
238
- \t
239
- tab
240
- \e
241
- escape
242
- \v
243
- vertical tab
244
- \s
245
- space
246
- \d
247
- delete
248
- \ddd
249
- the octal value ddd
250
- \c
274
+ backspace</ p >
275
+
276
+ < p > \f
277
+ form feed</ p >
278
+
279
+ < p > \n
280
+ newline (line feed)</ p >
281
+
282
+ < p > \r
283
+ carriage return</ p >
284
+
285
+ < p > \t
286
+ tab</ p >
287
+
288
+ < p > \e
289
+ escape</ p >
290
+
291
+ < p > \v
292
+ vertical tab</ p >
293
+
294
+ < p > \s
295
+ space</ p >
296
+
297
+ < p > \d
298
+ delete</ p >
299
+
300
+ < p > \ddd
301
+ the octal value ddd</ p >
302
+
303
+ < p > \c
251
304
any other character literally, for example \\ for
252
305
backslash, \" for ")</ p >
253
306
@@ -264,6 +317,6 @@ <h5><a name="Regular_Expressions">Regular Expressions</a></h5>
264
317
a nasty error.
265
318
< hr >
266
319
< div class ="navbar "> < a name ="#navbar_bottom "> </ a > < table width ="100% " border ="0 " cellspacing ="0 " cellpadding ="2 " summary ="navigation bar "> < tr > < td > < a href ="overview-summary.html " target ="overviewFrame "> Overview</ a > </ td > < td > < a href ="http://www.erlang.org/ "> < img src ="erlang.png " align ="right " border ="0 " alt ="erlang logo "> </ a > </ td > </ tr > </ table > </ div >
267
- < p > < i > Generated by EDoc, Aug 13 2008, 04:18:13 .</ i > </ p >
320
+ < p > < i > Generated by EDoc, Dec 29 2008, 02:29:17 .</ i > </ p >
268
321
</ body >
269
322
</ html >
0 commit comments