cp/guest: clean up guest_create's console handling
[hvf.git] / build / re2c / re2c.1
blobdfb82774e183a52b4a3dbcaaf523e1ee5ea4bc34
1 ./" 
2 ./" $Id: re2c.1.in 862 2008-05-25 14:30:45Z helly $
3 ./"
4 .TH RE2C 1 "25 May 2008" "Version 0.13.5"
5 .ds re \fBre2c\fP
6 .ds le \fBlex\fP
7 .ds rx regular-expression
8 .ds rxs regular-expressions
9 .ds lx \fIl\fP-expression
10 .SH NAME
11 \*(re \- convert \*(rxs to C/C++
13 .SH SYNOPSIS
14 \*(re [\fB-bdDefFghisuvVw1\fP] [\fB-o output\fP] [\fB-c\fP [\fB-t header\fP]] \fBfile\fP
16 .SH DESCRIPTION
17 \*(re is a preprocessor that generates C-based recognizers from regular
18 expressions.
19 The input to \*(re consists of C/C++ source interleaved with
20 comments of the form \fC/*!re2c\fP ... \fC*/\fP which contain
21 scanner specifications.
22 In the output these comments are replaced with code that, when
23 executed, will find the next input token and then execute
24 some user-supplied token-specific code.
26 For example, given the following code
28 .in +3
29 .nf
30 char *scan(char *p)
32 /*!re2c
33         re2c:define:YYCTYPE  = "unsigned char";
34         re2c:define:YYCURSOR = p;
35         re2c:yyfill:enable   = 0;
36         re2c:yych:conversion = 1;
37         re2c:indent:top      = 1;
38         [0-9]+          {return p;}
39         [^]             {return (char*)0;}
42 .fi
43 .in -3
45 \*(re -is will generate
47 .in +3
48 .nf
49 /* Generated by re2c on Sat Apr 16 11:40:58 1994 */
50 char *scan(char *p)
52     {
53         unsigned char yych;
55         yych = (unsigned char)*p;
56         if(yych <= '/') goto yy4;
57         if(yych >= ':') goto yy4;
58         ++p;
59         yych = (unsigned char)*p;
60         goto yy7;
61 yy3:
62         {return p;}
63 yy4:
64         ++p;
65         yych = (unsigned char)*p;
66         {return char*)0;}
67 yy6:
68         ++p;
69         yych = (unsigned char)*p;
70 yy7:
71         if(yych <= '/') goto yy3;
72         if(yych <= '9') goto yy6;
73         goto yy3;
74     }
77 .fi
78 .in -3
80 You can place one \fC/*!max:re2c */\fP comment that will output a "#define 
81 \fCYYMAXFILL\fP <n>" line that holds the maximum number of characters 
82 required to parse the input. That is the maximum value \fCYYFILL\fP(n)
83 will receive. If -1 is in effect then YYMAXFILL can only be triggered once
84 after the last \fC/*!re2c */\fP.
86 You can also use \fC/*!ignore:re2c */\fP blocks that allows to document the
87 scanner code and will not be part of the output.
89 .SH OPTIONS
90 \*(re provides the following options:
91 .TP
92 \fB-?\fP
93 \fB-h\fP
94 Invoke a short help.
95 .TP
96 \fB-b\fP
97 Implies \fB-s\fP.  Use bit vectors as well in the attempt to coax better
98 code out of the compiler.  Most useful for specifications with more than a
99 few keywords (e.g. for most programming languages).
101 \fB-c\fP
102 Used to support (f)lex-like condition support.
104 \fB-d\fP
105 Creates a parser that dumps information about the current position and in 
106 which state the parser is while parsing the input. This is useful to debug 
107 parser issues and states. If you use this switch you need to define a macro
108 \fIYYDEBUG\fP that is called like a function with two parameters:
109 \fIvoid YYDEBUG(int state, char current)\fP. The first parameter receives the 
110 state or -1 and the second parameter receives the input at the current cursor.
112 \fB-D\fP
113 Emit Graphviz dot data. It can then be processed with e.g.
114 "dot -Tpng input.dot > output.png". Please note that scanners with many states
115 may crash dot.
117 \fB-e\fP
118 Cross-compile from an ASCII platform to an EBCDIC one. 
120 \fB-f\fP
121 Generate a scanner with support for storable state.
122 For details see below at \fBSCANNER WITH STORABLE STATES\fP.
124 \fB-F\fP
125 Partial support for flex syntax. When this flag is active then named
126 definitions must be surrounded by curly braces and can be defined without an
127 equal sign and the terminating semi colon. Instead names are treated as direct
128 double quoted strings.
130 \fB-g\fP
131 Generate a scanner that utilizes GCC's computed goto feature. That is \*(re
132 generates jump tables whenever a decision is of a certain complexity (e.g. a 
133 lot of if conditions are otherwise necessary). This is only useable with GCC 
134 and produces output that cannot be compiled with any other compiler. Note that
135 this implies -b and that the complexity threshold can be configured using the
136 inplace configuration "cgoto:threshold".
138 \fB-i\fP
139 Do not output #line information. This is usefull when you want use a CMS tool
140 with the \*(re output which you might want if you do not require your users to 
141 have \*(re themselves when building from your source.
142 \fB-o output\fP
143 Specify the output file.
145 \fB-r\fP
146 Allows reuse of scanner definitions with '\fB/*!use:re2c\fP' after
147 '\fB/*!rules:re2c\fP'. In this mode no '\fB/*!re2c\fP' block and exactly one
148 '\fB/*!rules:re2c\fP' must be present. The rules are being saved and used by
149 every '\fB/*!use:re2c\fP' block that follows. These blocks can contain
150 inplace configurations, especially '\fBre2c:flags:w\fP' and '\fBre2c:flags:u\fP'.
151 That way it is possible to create the same scanner multiple times for different
152 character types, different input mechanisms or different output mechanisms.
153 The '\fB/*!use:re2c\fP' blocks can also contain additional rules that will be
154 appended to the set of rules in '\fB/*!rules:re2c\fP'.
156 \fB-s\fP
157 Generate nested \fCif\fPs for some \fCswitch\fPes.  Many compilers need this
158 assist to generate better code.
160 \fB-t\fP
161 Create a header file that contains types for the (f)lex-like condition support.
162 This can only be activated when \fB-c\fP is in use.
164 \fB-u\fP
165 Generate a parser that supports Unicode chars (UTF-32). This means the 
166 generated code can deal with any valid Unicode character up to 0x10FFFF. When
167 UTF-8 or UTF-16 needs to be supported you need to convert the incoming stream
168 to UTF-32 upon input yourself.
170 \fB-v\fP
171 Show version information.
173 \fB-V\fP
174 Show the version as a number XXYYZZ.
176 \fB-w\fP
177 Create a parser that supports wide chars (UCS-2). This implies \fB-s\fP and 
178 cannot be used together with \fB-e\fP switch.
180 \fB-1\fP
181 Force single pass generation, this cannot be combined with -f and disables 
182 YYMAXFILL generation prior to last \*(re block.
184 \fB--no-generation-date\fP
185 Suppress date output in the generated output so that it only shows the re2c
186 version.
188 \fb--case-insensitive\fP
189 All strings are case insensitive, so all "-expressions are treated
190 in the same way '-expressions are.
192 \fB--case-inverted\fP
193 Invert the meaning of single and double quoted strings.
194 With this switch single quotes are case sensitive and
195 double quotes are case insensitive.
197 .SH "INTERFACE CODE"
198 Unlike other scanner generators, \*(re does not generate complete scanners:
199 the user must supply some interface code.
200 In particular, the user must define the following macros or use the 
201 corresponding inplace configurations:
203 \fCYYCONDTYPE\fP
204 In \fB-c\fP mode you can use \fB-t\fP to generate a file that contains the 
205 enumeration used as conditions. Each of the values refers to a condition of
206 a rule set.
208 \fCYYCTXMARKER\fP
209 \*(lx of type \fC*YYCTYPE\fP.
210 The generated code saves trailing context backtracking information in \fCYYCTXMARKER\fP.
211 The user only needs to define this macro if a scanner specification uses trailing
212 context in one or more of its \*(rxs.
214 \fCYYCTYPE\fP
215 Type used to hold an input symbol.
216 Usually \fCchar\fP or \fCunsigned char\fP.
218 \fCYYCURSOR\fP
219 \*(lx of type \fC*YYCTYPE\fP that points to the current input symbol.
220 The generated code advances \fCYYCURSOR\fP as symbols are matched.
221 On entry, \fCYYCURSOR\fP is assumed to point to the first character of the
222 current token.  On exit, \fCYYCURSOR\fP will point to the first character of
223 the following token.
225 \fCYYDEBUG(\fP\fIstate\fP,\fIcurrent\fC)\fP
226 This is only needed if the \fB-d\fP flag was specified. It allows to easily debug
227 the generated parser by calling a user defined function for every state. The function
228 should have the following signature: \fIvoid YYDEBUG(int state, char current)\fP. 
229 The first parameter receives the state or -1 and the second parameter receives the 
230 input at the current cursor.
232 \fCYYFILL\fP(\fIn\fP\fC\fP)
233 The generated code "calls" \fCYYFILL\fP(n) when the buffer needs
234 (re)filling:  at least \fIn\fP additional characters should
235 be provided. \fCYYFILL\fP(n) should adjust \fCYYCURSOR\fP, \fCYYLIMIT\fP,
236 \fCYYMARKER\fP and \fCYYCTXMARKER\fP as needed.  Note that for typical 
237 programming languages \fIn\fP will be the length of the longest keyword plus one.
238 The user can place a comment of the form \fC/*!max:re2c */\fP once to insert 
239 a \fCYYMAXFILL\fP(n) definition that is set to the maximum length value. If -1 
240 switch is used then \fCYYMAXFILL\fP can be triggered only once after the 
241 last \fC/*!re2c */\fP
242 block.
244 \fCYYGETCONDITION\fP()
245 This define is used to get the condition prior to entering the scanner code
246 when using \fB-c\fP switch. The value must be initialized with a value from
247 the enumeration \fCYYCONDTYPE\fP type.
249 \fCYYGETSTATE\fP()
250 The user only needs to define this macro if the \fB-f\fP flag was specified.
251 In that case, the generated code "calls" \fCYYGETSTATE\fP() at the very beginning
252 of the scanner in order to obtain the saved state. \fCYYGETSTATE\fP() must return a signed
253 integer. The value must be either -1, indicating that the scanner is entered for the
254 first time, or a value previously saved by \fCYYSETSTATE\fP(s).  In the second case, the
255 scanner will resume operations right after where the last \fCYYFILL\fP(n) was called.
257 \fCYYLIMIT\fP
258 Expression of type \fC*YYCTYPE\fP that marks the end of the buffer
259 (\fCYYLIMIT[-1]\fP is the last character in the buffer).
260 The generated code repeatedly compares \fCYYCURSOR\fP to \fCYYLIMIT\fP
261 to determine when the buffer needs (re)filling.
263 \fCYYMARKER\fP
264 \*(lx of type \fC*YYCTYPE\fP.
265 The generated code saves backtracking information in \fCYYMARKER\fP. Some easy
266 scanners might not use this.
268 \fCYYMAXFILL
269 This will be automatically defined by \fC/*!max:re2c */\fP blocks as explained above.
271 \fCYYSETCONDITION(\fP\fIc\fP\fC)\fP
272 This define is used to set the condition in transition rules.  This is only
273 being used when \fB-c\fP is active and transition rules are being used.
275 \fCYYSETSTATE(\fP\fIs\fP\fC)\fP
276 The user only needs to define this macro if the \fB-f\fP flag was specified.
277 In that case, the generated code "calls" \fCYYSETSTATE\fP just before calling
278 \fCYYFILL\fP(n).  The parameter to \fCYYSETSTATE\fP is a signed integer that uniquely
279 identifies the specific instance of \fCYYFILL\fP(n) that is about to be called.
280 Should the user wish to save the state of the scanner and have \fCYYFILL\fP(n) return
281 to the caller, all he has to do is store that unique identifer in a variable.
282 Later, when the scannered is called again, it will call \fCYYGETSTATE()\fP and
283 resume execution right where it left off. The generated code will contain 
284 both \fCYYSETSTATE\fP(s) and \fCYYGETSTATE\fP even if \fCYYFILL\fP(n) is being
285 disabled.
287 .SH "SCANNER WITH STORABLE STATES"
288 When the \fB-f\fP flag is specified, \*(re generates a scanner that
289 can store its current state, return to the caller, and later resume
290 operations exactly where it left off.
292 The default operation of \*(re is a "pull" model, where the scanner asks
293 for extra input whenever it needs it. However, this mode of operation
294 assumes that the scanner is the "owner" the parsing loop, and that may
295 not always be convenient.
297 Typically, if there is a preprocessor ahead of the scanner in the stream,
298 or for that matter any other procedural source of data, the scanner cannot
299 "ask" for more data unless both scanner and source live in a separate threads.
301 The \fB-f\fP flag is useful for just this situation : it lets users design
302 scanners that work in a "push" model, i.e. where data is fed to the scanner
303 chunk by chunk. When the scanner runs out of data to consume, it just stores
304 its state, and return to the caller. When more input data is fed to the scanner,
305 it resumes operations exactly where it left off.
307 When using the -f option \*(re does not accept stdin because it has to do the 
308 full generation process twice which means it has to read the input twice. That
309 means \*(re would fail in case it cannot open the input twice or reading the
310 input for the first time influences the second read attempt.
312 Changes needed compared to the "pull" model.
314 1. User has to supply macros YYSETSTATE() and YYGETSTATE(state)
316 2. The \fB-f\fP option inhibits declaration of \fIyych\fP and
317 \fIyyaccept\fP. So the user has to declare these. Also the user has
318 to save and restore these. In the example \fIexamples/push.re\fP these
319 are declared as fields of the (C++) class of which the scanner is a
320 method, so they do not need to be saved/restored explicitly. For C
321 they could e.g. be made macros that select fields from a structure
322 passed in as parameter. Alternatively, they could be declared as local
323 variables, saved with YYFILL(n) when it decides to return and restored
324 at entry to the function. Also, it could be more efficient to save the
325 state from YYFILL(n) because YYSETSTATE(state) is called
326 unconditionally. YYFILL(n) however does not get \fIstate\fP as
327 parameter, so we would have to store state in a local variable by
328 YYSETSTATE(state).
330 3. Modify YYFILL(n) to return (from the function calling it) if more
331 input is needed.
333 4. Modify caller to recognise "more input is needed" and respond
334 appropriately.
336 5. The generated code will contain a switch block that is used to restores 
337 the last state by jumping behind the corrspoding YYFILL(n) call. This code is
338 automatically generated in the epilog of the first "\fC/*!re2c */\fP" block. 
339 It is possible to trigger generation of the YYGETSTATE() block earlier by 
340 placing a "\fC/*!getstate:re2c */\fP" comment. This is especially useful when
341 the scanner code should be wrapped inside a loop.
343 Please see examples/push.re for push-model scanner. The generated code can be
344 tweaked using inplace configurations "\fBstate:abort\fP" and "\fBstate:nextlabel\fP".
346 .SH "SCANNER WITH CONDITION SUPPORT"
347 You can preceed \*(rxs with a list of condition names when using the \fB-c\fP 
348 switch. In this case \*(re generates scanner blocks for each conditon. Where each of the
349 generated blocks has its own precondition. The precondition is given by the 
350 interface define \fBYYGETCONDITON\fP and must be of type \fBYYCONDTYPE\fP.
352 There are two special rule types. First, the rules of the condition '*' are 
353 merged to all  conditions. And second the empty condition list allows to 
354 provide a code block that does not have a scanner part. Meaning it does not 
355 allow any regular expression. The condition value referring to this special 
356 block is always the one with the enumeration value 0. This way the code of this
357 special rule can be used to initialize a scanner. It is in no way necessary to
358 have these rules: but sometimes it is helpful to have a dedicated uninitialized
359 condition state.
361 Non empty rules allow to specify the new condition, which makes them
362 transition rules. Besides generating calls for the define \fBYYSETCONDTITION\fP
363 no other special code is generated.
365 There is another kind of special rules that allow to prepend code to any code
366 block of all rules of a certain set of conditions or to all code blocks to all
367 rules. This can be helpful when some operation is common among rules. For
368 instance this can be used to store the length of the scanned string. These
369 special setup rules start with an exclamation mark followed by either a list
370 of conditions \fB<! condition, ... >\fP or a star \fB<!*>\fP.
371 When \*(re generates the code for a rule whose state does not have a
372 setup rule and a star'd setup rule is present, than that code will be used
373 as setup code.
375 .SH "SCANNER SPECIFICATIONS"
376 Each scanner specification consists of a set of \fIrules\fP, \fInamed
377 definitions\fP and \fIconfigurations\fP.
379 \fIRules\fP consist of a \*(rx along with a block of C/C++ code that
380 is to be executed when the associated \fI\*(rx\fP is matched. You can either
381 start the code with an opening curly brace or the sequence '\fB:=\fP'. When
382 the code with a curly brace then \*(re counts the brace depth and stops looking
383 for code automatically. Otherwise curly braces are not allowed and \*(re stops
384 looking for code at the first line that does not begin with whitespace.
387 \fI\*(rx\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
389 \fI\*(rx\fP \fC:=\fP \fIC/C++ code\fP
392 If \fB-c\fP is active then each \*(rx is preceeded by a list of 
393 comma separated condition names. Besides normal naming rules there are two 
394 special cases. A rule may contain the single condition name '*' and no contition 
395 name at all. In the latter case the rule cannot have a \*(rx. Non 
396 empty rules may further more specify the new condition. In that case \*(re will
397 generated the necessary code to chnage the condition automatically. Just as above
398 code can be started with a curly brace of the sequence '\fB:=\fP'. Further more
399 rules can use ':=>' as a shortcut to automatically generate code that not only
400 sets the new condition state but also continues execution with the new state. A
401 shortcut rule should not be used in a loop where there is code between the start
402 of the loop and the \*(re block unless \fIre2c:cond:goto\fP is changed
403 to '\fIcontinue;\fP'. If code is necessary before all rule (though not simple
404 jumps) you can doso by using <! pseudo-rules.
407 \fC<\fP\fIcondition-list\fP\fC>\fP \fI\*(rx\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
409 \fC<\fP\fIcondition-list\fP\fC>\fP \fI\*(rx\fP \fC:=\fP \fIC/C++ code\fP
411 \fC<\fP\fIcondition-list\fP\fC>\fP \fI\*(rx\fP \fC=>\fP \fP\fIcondition\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
413 \fC<\fP\fIcondition-list\fP\fC>\fP \fI\*(rx\fP \fC=>\fP \fP\fIcondition\fP \fC:=\fP \fIC/C++ code\fP
415 \fC<\fP\fIcondition-list\fP\fC>\fP \fI\*(rx\fP \fC:=>\fP \fP\fIcondition\fP
417 \fC<\fP\fI*\fP\fC>\fP \fI\*(rx\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
419 \fC<\fP\fI*\fP\fC>\fP \fI\*(rx\fP \fC:=\fP \fIC/C++ code\fP
421 \fC<\fP\fI*\fP\fC>\fP \fI\*(rx\fP \fC=>\fP \fP\fIcondition\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
423 \fC<\fP\fI*\fP\fC>\fP \fI\*(rx\fP \fC=>\fP \fP\fIcondition\fP \fC:=\fP \fIC/C++ code\fP
425 \fC<\fP\fI*\fP\fC>\fP \fI\*(rx\fP \fC:=>\fP \fP\fIcondition\fP
427 \fC<>\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
429 \fC<>\fP \fC:=\fP \fIC/C++ code\fP
431 \fC<>\fP \fC=>\fP \fP\fIcondition\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
433 \fC<>\fP \fC=>\fP \fP\fIcondition\fP \fC:=\fP \fIC/C++ code\fP
435 \fC<>\fP \fC:=>\fP \fP\fIcondition\fP
437 \fC<!\fIcondition-list\fP\fC>\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
439 \fC<!\fIcondition-list\fP\fC>\fP \fC:=\fP \fIC/C++ code\fP
441 \fC<!*>\fP \fC{\fP \fIC/C++ code\fP \fC}\fP
443 \fC<!*>\fP \fC:=\fP \fIC/C++ code\fP
446 Named definitions are of the form:
449 \fIname\fP \fC=\fP \fI\*(rx\fP\fC;\fP
452 \fB-F\fP is active, then named definitions are also of the form:
455 \fIname\fP \fI\*(rx\fP
458 Configurations look like named definitions whose names start 
459 with "\fBre2c:\fP":
462 \fCre2c:\fP\fIname\fP \fC=\fP \fIvalue\fP\fC;\fP
465 \fCre2c:\fP\fIname\fP \fC=\fP \fB"\fP\fIvalue\fP\fB"\fP\fC;\fP
468 .SH "SUMMARY OF RE2C REGULAR-EXPRESSIONS"
470 \fC"foo"\fP
471 the literal string \fCfoo\fP.
472 ANSI-C escape sequences can be used.
474 \fC'foo'\fP
475 the literal string \fCfoo\fP (characters [a-zA-Z] treated case-insensitive).
476 ANSI-C escape sequences can be used.
478 \fC[xyz]\fP
479 a "character class"; in this case,
480 the \*(rx matches either an '\fCx\fP', a '\fCy\fP', or a '\fCz\fP'.
482 \fC[abj-oZ]\fP
483 a "character class" with a range in it;
484 matches an '\fCa\fP', a '\fCb\fP', any letter from '\fCj\fP' through '\fCo\fP',
485 or a '\fCZ\fP'.
487 \fC[^\fIclass\fP\fC]\fP
488 an inverted "character class".
490 \fIr\fP\fC\e\fP\fIs\fP
491 match any \fIr\fP which isn't an \fIs\fP. \fIr\fP and \fIs\fP must be \*(rxs
492 which can be expressed as character classes.
494 \fIr\fP\fC*\fP
495 zero or more \fIr\fP's, where \fIr\fP is any \*(rx
497 \fC\fIr\fP\fC+\fP
498 one or more \fIr\fP's
500 \fC\fIr\fP\fC?\fP
501 zero or one \fIr\fP's (that is, "an optional \fIr\fP")
503 name
504 the expansion of the "named definition" (see above)
506 \fC(\fP\fIr\fP\fC)\fP
507 an \fIr\fP; parentheses are used to override precedence
508 (see below)
510 \fIrs\fP
511 an \fIr\fP followed by an \fIs\fP ("concatenation")
513 \fIr\fP\fC|\fP\fIs\fP
514 either an \fIr\fP or an \fIs\fP
516 \fIr\fP\fC/\fP\fIs\fP
517 an \fIr\fP but only if it is followed by an \fIs\fP. The \fIs\fP is not part of
518 the matched text. This type of \*(rx is called "trailing context". A trailing
519 context can only be the end of a rule and not part of a named definition.
521 \fIr\fP\fC{\fP\fIn\fP\fC}\fP
522 matches \fIr\fP exactly \fIn\fP times.
524 \fIr\fP\fC{\fP\fIn\fP\fC,}\fP
525 matches \fIr\fP at least \fIn\fP times.
527 \fIr\fP\fC{\fP\fIn\fP\fC,\fP\fIm\fP\fC}\fP
528 matches \fIr\fP at least \fIn\fP but not more than \fIm\fP times.
530 \fC.\fP
531 match any character except newline (\\n).
533 \fIdef\fP
534 matches named definition as specified by \fIdef\fP only if \fB-F\fP is
535 off. If the switch \fB-F\fP is active then this behaves like it was enclosed
536 in double quotes and matches the string \fIdef\fP.
538 Character classes and string literals may contain octoal or hexadecimal 
539 character definitions and the following set of escape sequences (\fB\\n\fP,
540  \fB\\t\fP, \fB\\v\fP, \fB\\b\fP, \fB\\r\fP, \fB\\f\fP, \fB\\a\fP, \fB\\\\\fP).
541 An octal character is defined by a backslash followed by its three octal digits
542 and a hexadecimal character is defined by backslash, a lower cased '\fBx\fP' 
543 and its two hexadecimal digits or a backslash, an upper cased \fBX\fP and its 
544 four hexadecimal digits.
546 \*(re further more supports the c/c++ unicode notation. That is a backslash followed
547 by either a lowercased \fBu\fP and its four hexadecimal digits or an uppercased 
548 \fBU\fP and its eight hexadecimal digits. However only in \fB-u\fP mode the
549 generated code can deal with any valid Unicode character up to 0x10FFFF.
551 Since characters greater \fB\\X00FF\fP are not allowed in non unicode mode, the 
552 only portable "\fBany\fP" rules are \fB(.|"\\n")\fP and \fB[^]\fP.
554 The \*(rxs listed above are grouped according to
555 precedence, from highest precedence at the top to lowest at the bottom.
556 Those grouped together have equal precedence.
558 .SH "INPLACE CONFIGURATION"
560 It is possible to configure code generation inside \*(re blocks. The following
561 lists the available configurations:
563 \fIre2c:condprefix\fP \fB=\fP yyc_ \fB;\fP
564 Allows to specify the prefix used for condition labels. That is this text is 
565 prepended to any condition label in the generated output file.
567 \fIre2c:condenumprefix\fP \fB=\fP yyc \fB;\fP
568 Allows to specify the prefix used for condition values. That is this text is 
569 prepended to any condition enum value in the generated output file. 
571 \fIre2c:cond:divider\fP \fB=\fP "/* *********************************** */" \fB;\fP
572 Allows to customize the devider for condition blocks. You can use '@@' to 
573 put the name of the condition or ustomize the plaeholder
574 using \fIre2c:cond:divider@cond\fP.
576 \fIre2c:cond:divider@cond\fP \fB=\fP @@ \fB;\fP
577 Specifies the placeholder that will be replaced with the condition name
578 in \fIre2c:cond:divider\fP.
580 \fIre2c:cond:goto\fP \fB=\fP "goto @@;" \fB;\fP
581 Allows to customize the condition goto statements used with ':=>' style rules.
582 You can use '@@' to put the name of the condition or ustomize the plaeholder
583 using \fIre2c:cond:goto@cond\fP. You can also change this to 'continue;',
584 which would allow you to continue with the next loop cycle including any code
585 between loop start and re2c block.
587 \fIre2c:cond:goto@cond\fP \fB=\fP @@ \fB;\fP
588 Spcifies the placeholder that will be replaced with the condition label
589 in \fIre2c:cond:goto\fP.
591 \fIre2c:indent:top\fP \fB=\fP 0 \fB;\fP
592 Specifies the minimum number of indendation to use. Requires a numeric value 
593 greater than or equal zero.
595 \fIre2c:indent:string\fP \fB=\fP "\\t" \fB;\fP
596 Specifies the string to use for indendation. Requires a string that should 
597 contain only whitespace unless you need this for external tools. The easiest 
598 way to specify spaces is to enclude them in single or double quotes. If you do 
599 not want any indendation at all you can simply set this to \fB""\fP.
601 \fIre2c:yych:conversion\fP \fB=\fP 0 \fB;\fP
602 When this setting is non zero, then \*(re automatically generates conversion 
603 code whenever yych gets read. In this case the type must be defined using
604 \fBre2c:define:YYCTYPE\fP.
606 \fIre2c:yych:emit\fP \fB=\fP 1 \fB;\fP
607 Generation of \fByych\fP can be suppressed by setting this to 0.
609 \fIre2c:yybm:hex\fP \fB=\fP 0 \fB;\fP
610 If set to zero then a decimal table is being used else a hexadecimal table 
611 will be generated.
613 \fIre2c:yyfill:enable\fP \fB=\fP 1 \fB;\fP
614 Set this to zero to suppress generation of YYFILL(n). When using this be sure
615 to verify that the generated scanner does not read behind input. Allowing
616 this behavior might introduce sever security issues to you programs.
618 \fIre2c:yyfill:check\fP \fB=\fP 1 \fB;\fP
619 This can be set 0 to suppress output of the pre condition using YYCURSOR and
620 YYLIMIT which becomes usefull when YYLIMIT + max(YYFILL) is always accessible.
622 \fIre2c:yyfill:parameter\fP \fB=\fP 1 \fB;\fP
623 Allows to suppress parameter passing to \fBYYFILL\fP calls. If set to zero 
624 then no parameter is passed to \fBYYFILL\fP. However \fBdefine:YYFILL@LEN\fP
625 allows to specify a replacement string for the actual length value. If set to
626 a non zero value then \fBYYFILL\fP usage will be followed by the number of 
627 requested characters in braces unless \fBre2c:define:YYFILL:naked\fP is set. 
628 Also look at \fBre2c:define:YYFILL:naked\fP and \fBre2c:define:YYFILL@LEN\fP.
630 \fIre2c:startlabel\fP \fB=\fP 0 \fB;\fP
631 If set to a non zero integer then the start label of the next scanner blocks 
632 will be generated even if not used by the scanner itself. Otherwise the normal 
633 \fByy0\fP like start label is only being generated if needed. If set to a text 
634 value then a label with that text will be generated regardless of whether the 
635 normal start label is being used or not. This setting is being reset to \fB0\fP
636 after a start label has been generated.
638 \fIre2c:labelprefix\fP \fB=\fP yy \fB;\fP
639 Allows to change the prefix of numbered labels. The default is \fByy\fP and
640 can be set any string that is a valid label.
642 \fIre2c:state:abort\fP \fB=\fP 0 \fB;\fP
643 When not zero and switch -f is active then the \fCYYGETSTATE\fP block will 
644 contain a default case that aborts and a -1 case is used for initialization.
646 \fIre2c:state:nextlabel\fP \fB=\fP 0 \fB;\fP
647 Used when -f is active to control whether the \fCYYGETSTATE\fP block is 
648 followed by a \fCyyNext:\fP label line. Instead of using \fCyyNext\fP you can 
649 usually also use configuration \fIstartlabel\fP to force a specific start label
650 or default to \fCyy0\fP as start label. Instead of using a dedicated label it 
651 is often better to separate the YYGETSTATE code from the actual scanner code by
652 placing a "\fC/*!getstate:re2c */\fP" comment.
654 \fIre2c:cgoto:threshold\fP \fB=\fP 9 \fB;\fP
655 When -g is active this value specifies the complexity threshold that triggers
656 generation of jump tables rather than using nested if's and decision bitfields.
657 The threshold is compared against a calculated estimation of if-s needed where 
658 every used bitmap divides the threshold by 2.
660 \fIre2c:yych:conversion\fP \fB=\fP 0 \fB;\fP
661 When the input uses signed characters and \fB-s\fP or \fB-b\fP switches are 
662 in effect re2c allows to automatically convert to the unsigned character type 
663 that is then necessary for its internal single character. When this setting 
664 is zero or an empty string the conversion is disabled. Using a non zero number
665 the conversion is taken from \fBYYCTYPE\fP. If that is given by an inplace 
666 configuration that value is being used. Otherwise it will be \fB(YYCTYPE)\fP 
667 and changes to that configuration are  no longer possible. When this setting is
668 a string the braces must be specified. Now assuming your input is a \fBchar*\fP
669 buffer and you are using above mentioned switches you can set \fBYYCTYPE\fP to
670 \fBunsigned char\fP and this setting to either \fB1\fP or \fB"(unsigned char)"\fP.
672 \fIre2c:define:define:YYCONDTYPE\fP \fB=\fP YYCONDTYPE \fB;\fP
673 Enumeration used for condition support with \fB-c\fP mode.
675 \fIre2c:define:YYCTXMARKER\fP \fB=\fP YYCTXMARKER \fB;\fP
676 Allows to overwrite the define YYCTXMARKER and thus avoiding it by setting the
677 value to the actual code needed.
679 \fIre2c:define:YYCTYPE\fP \fB=\fP YYCTYPE \fB;\fP
680 Allows to overwrite the define YYCTYPE and thus avoiding it by setting the
681 value to the actual code needed.
683 \fIre2c:define:YYCURSOR\fP \fB=\fP YYCURSOR \fB;\fP
684 Allows to overwrite the define YYCURSOR and thus avoiding it by setting the
685 value to the actual code needed.
687 \fIre2c:define:YYDEBUG\fP \fB=\fP YYDEBUG \fB;\fP
688 Allows to overwrite the define \fBYYDEBUG\fP and thus avoiding it by setting the
689 value to the actual code needed.
691 \fIre2c:define:YYFILL\fP \fB=\fP YYFILL \fB;\fP
692 Allows to overwrite the define \fBYYFILL\fP and thus avoiding it by setting the
693 value to the actual code needed.
695 \fIre2c:define:YYFILL:naked\fP \fB=\fP 0 \fB;\fP
696 When set to 1 neither braces, parameter nor semicolon gets emitted.
698 \fIre2c:define:YYFILL@len\fP \fB=\fP @@ \fB;\fP
699 When using \fIre2c:define:YYFILL\fP and \fIre2c:yyfill:parameter\fP is 0 then
700 any occurence of this text inside \fBYYFILL\fP will be replaced with the actual
701 length value.
703 \fIre2c:define:YYGETCONDITION\fP \fB=\fP YYGETCONDITION \fB;\fP
704 Allows to overwrite the define \fBYYGETCONDITION\fP.
706 \fIre2c:define:YYGETCONDITION:naked\fP \fB=\fP  \fB;\fP
707 When set to 1 neither braces, parameter nor semicolon gets emitted.
709 \fIre2c:define:YYGETSTATE\fP \fB=\fP YYGETSTATE \fB;\fP
710 Allows to overwrite the define \fBYYGETSTATE\fP and thus avoiding it by setting the
711 value to the actual code needed.
713 \fIre2c:define:YYGETSTATE:naked\fP \fB=\fP 0 \fB;\fP
714 When set to 1 neither braces, parameter nor semicolon gets emitted.
716 \fIre2c:define:YYLIMIT\fP \fB=\fP YYLIMIT \fB;\fP
717 Allows to overwrite the define \fBYYLIMIT\fP and thus avoiding it by setting the
718 value to the actual code needed.
720 \fIre2c:define:YYMARKER\fP \fB=\fP YYMARKER \fB;\fP
721 Allows to overwrite the define \fBYYMARKER\fP and thus avoiding it by setting the
722 value to the actual code needed.
724 \fIre2c:define:YYSETCONDITION\fP \fB=\fP YYSETCONDITION \fB;\fP
725 Allows to overwrite the define \fBYYSETCONDITION\fP.
727 \fIre2c:define:YYSETCONDITION@cond\fP \fB=\fP @@ \fB;\fP
728 When using \fIre2c:define:YYSETCONDITION\fP then any occurence of this text 
729 inside \fBYYSETCONDITION\fP will be replaced with the actual new condition value.
731 \fIre2c:define:YYSETSTATE\fP \fB=\fP YYSETSTATE \fB;\fP
732 Allows to overwrite the define \fBYYSETSTATE\fP and thus avoiding it by setting the
733 value to the actual code needed.
735 \fIre2c:define:YYSETSTATE:naked\fP \fB=\fP 0 \fB;\fP
736 When set to 1 neither braces, parameter nor semicolon gets emitted.
738 \fIre2c:define:YYSETSTATE@state\fP \fB=\fP @@ \fB;\fP
739 When using \fIre2c:define:YYSETSTATE\fP then any occurence of this text 
740 inside \fBYYSETSTATE\fP will be replaced with the actual new state value.
742 \fIre2c:label:yyFillLabel\fP \fB=\fP yyFillLabel \fB;\fP
743 Allows to overwrite the name of the label yyFillLabel.
745 \fIre2c:label:yyNext\fP \fB=\fP yyNext \fB;\fP
746 Allows to overwrite the name of the label yyNext.
748 \fIre2c:variable:yyaccept\fP \fB=\fP yyaccept \fB;\fP
749 Allows to overwrite the name of the variable yyaccept.
751 \fIre2c:variable:yybm\fP \fB=\fP yybm \fB;\fP
752 Allows to overwrite the name of the variable yybm.
754 \fIre2c:variable:yych\fP \fB=\fP yych \fB;\fP
755 Allows to overwrite the name of the variable yych.
757 \fIre2c:variable:yyctable\fP \fB=\fP yyctable \fB;\fP
758 When both \fB-c\fP and \fB-g\fP are active then \*(re uses this variable to 
759 generate a static jump table for YYGETCONDITION.
761 \fIre2c:variable:yystable\fP \fB=\fP yystable \fB;\fP
762 When both \fB-f\fP and \fB-g\fP are active then \*(re uses this variable to 
763 generate a static jump table for YYGETSTATE.
765 \fIre2c:variable:yytarget\fP \fB=\fP yytarget \fB;\fP
766 Allows to overwrite the name of the variable yytarget.
768 .SH "UNDERSTANDING RE2C"
770 The subdirectory lessons of the \*(re distribution contains a few step by step
771 lessons to get you started with \*(re. All examples in the lessons subdirectory
772 can be compiled and actually work.
774 .SH FEATURES
776 \*(re does not provide a default action:
777 the generated code assumes that the input
778 will consist of a sequence of tokens.
779 Typically this can be dealt with by adding a rule such as the one for
780 unexpected characters in the example above.
782 The user must arrange for a sentinel token to appear at the end of input
783 (and provide a rule for matching it):
784 \*(re does not provide an \fC<<EOF>>\fP expression.
785 If the source is from a null-byte terminated string, a
786 rule matching a null character will suffice.  If the source is from a
787 file then you could pad the input with a newline (or some other character that 
788 cannot appear within another token); upon recognizing such a character check 
789 to see if it is the sentinel and act accordingly. And you can also use YYFILL(n)
790 to end the scanner in case not enough characters are available which is nothing
791 else then e detection of end of data/file.
793 .SH BUGS
795 Difference only works for character sets.
797 The \*(re internal algorithms need documentation.
799 .SH "SEE ALSO"
801 flex(1), lex(1).
803 More information on \*(re can be found here:
804 .PD 0
806 .B http://re2c.org/
807 .PD 1
809 .SH AUTHORS
810 .PD 0
812 Peter Bumbulis <peter@csg.uwaterloo.ca>
814 Brian Young <bayoung@acm.org>
816 Dan Nuffer <nuffer@users.sourceforge.net>
818 Marcus Boerger <helly@users.sourceforge.net>
820 Hartmut Kaiser <hkaiser@users.sourceforge.net>
822 Emmanuel Mogenet <mgix@mgix.com> added storable state
824 .PD 1
826 .SH VERSION INFORMATION
827 This manpage describes \*(re, version 0.13.5.