Version 0.10.2 (2006-??-??)
---------------------------
- Changed to generate YYMARKER only when needed or in single pass mode.
-- Added -t switch to force two pass generation.
+- Added -1 switch to force single pass generation and make two pass the default.
- Fixed -i switch.
- Added configuration 'yyfill:enable' to allow suppression of YYFILL() blocks.
- Added tutorial like lessons to re2c.
-/* Generated by re2c 0.10.2.dev on Sun Apr 16 13:38:11 2006 */
+/* Generated by re2c 0.10.2.dev on Sun Apr 16 18:19:25 2006 */
#line 1 "scanner.re"
/* $Id$ */
#include <stdlib.h>
++YYCURSOR;
#line 110 "scanner.re"
{
- if (bUsedYYMaxFill && bLastPass && !tFlag) {
+ if (bUsedYYMaxFill && bSinglePass) {
fatal("found scanner block after YYMAXFILL declaration");
}
out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
extern bool iFlag;
extern bool sFlag;
extern bool wFlag;
-extern bool tFlag;
+extern bool bSinglePass;
extern bool bLastPass;
extern bool bUsedYYAccept;
<h2>2006-??-??: 0.10.2</h2>
<ul>
<li>Changed to generate YYMARKER only when needed or in single pass mode.</li>
-<li>Added -t switch to force two pass generation.</li>
+<li>Added -1 switch to force single pass generation and make two pass the default.</li>
<li>Fixed -i switch.</li>
<li>Added configuration 'yyfill:enable' to allow suppression of YYFILL() blocks.</li>
<li>Added tutorial like lessons to re2c.</li>
<p>re2c - convert regular expressions to C/C++</p>
<a name="lbAC" id="lbAC"> </a>
<h2>SYNOPSIS</h2>
-<p><b>re2c</b> [<b>-bdefhistvVw</b>] [<b>-o output</b>] file</p>
+<p><b>re2c</b> [<b>-bdefhisvVw1</b>] [<b>-o output</b>] file</p>
<a name="lbAD" id="lbAD"> </a>
<h2>DESCRIPTION</h2>
<p><b>re2c</b> is a preprocessor that generates C-based recognizers from
</pre>
<br />
<br />
-<p>After the /*!re2c */ blocks you can place one /*!max:re2c */ comment
-that will output a define (YYMAXFILL) that holds the maximum number of
-characters required to parse the input. That is the maximum value YYFILL(n)
-will receive. If -t is in effect then YYMAXFILL can be triggered once anywhere
-in the code.</p>
+<p>You can place one /*!max:re2c */ comment that will output a "#define YYMAXFILL
+<n>" line that holds the maximum number of characters
+required to parse the input. That is the maximum value YYFILL(n)
+will receive. If -1 is in effect then YYMAXFILL can be triggered once
+after the last /*!re2c */.</p>
<p>You can also use /*!ignore:re2c */ blocks that allows to document the
scanner code and will not be part of the output.</p>
<a name="lbAE" id="lbAE"> </a>
<dt><b>-e</b></dt>
<dd>Cross-compile from an ASCII platform to an EBCDIC one.<br /><br /></dd>
<dt><b>-f</b></dt>
-<dd>Implies -t. Generate a scanner with support for storable state. For details see below
+<dd>Generate a scanner with support for storable state. For details see below
at <b>SCANNER WITH STORABLE STATES</b>.<br /><br /></dd>
<dt><b>-i</b></dt>
<dd>Do not output #line information. This is usefull when you want use a CMS
<dt><b>-s</b></dt>
<dd>Generate nested ifs for some switches. Many compilers need this assist to
generate better code.<br /><br /></dd>
-<dt><b>-t</b></dt>
-<dd>Force two pass generation, allows YYMAXFILL generation prior to last re2c
-block.<br /><br /></dd>
<dt><b>-v</b></dt>
<dd>Show version information.<br /><br /></dd>
<dt><b>-V</b></dt>
<dt><b>-w</b></dt>
<dd>Create a parser that supports wide chars (UCS-2). This implies <b>-s</b>
and cannot be used together with <b>-e</b> switch.<br /><br /></dd>
+<dt><b>-1</b></dt>
+<dd>Force single pass generation. This cannot be combined with -f.<br /><br /></dd>
</dl>
<br />
<br />
least <i>n</i> additional characters should be provided. YYFILL(n) should adjust
YYCURSOR, YYLIMIT, YYMARKER and YYCTXMARKER as needed. Note that for typical
programming languages <i>n</i> will be the length of the longest keyword plus
-one. The user can place a comment of the form /*!max:re2c */ once after the
-end of the last scanner block to insert a YYMAXFILL definition that is
-set to the maximum length value. If -t switch is used then YYMAXFILL can be
-triggered once anywhere in the code.<br /><br /></dd>
+one. The user can place a comment of the form /*!max:re2c */ once to insert
+a YYMAXFILL definition that is set to the maximum length value. If -1
+switch is used then YYMAXFILL can be triggered once after the last /*!re2c */
+block.<br /><br /></dd>
<dt>YYGETSTATE()</dt>
<dd>The user only needs to define this macro if the <b>-f</b> flag was
specified. In that case, the generated code "calls" YYGETSTATE at the very
bool iFlag = false;
bool sFlag = false;
bool wFlag = false;
-bool tFlag = false;
-bool bLastPass = false;
+bool bSinglePass = false;
+bool bLastPass = false;
bool bUsedYYAccept = false;
bool bUsedYYMaxFill = false;
mbo_opt_struct('i', 0, "no-debug-info"),
mbo_opt_struct('o', 1, "output"),
mbo_opt_struct('s', 0, "nested-ifs"),
- mbo_opt_struct('t', 0, "two-pass"),
mbo_opt_struct('v', 0, "version"),
mbo_opt_struct('V', 0, "vernum"),
mbo_opt_struct('w', 0, "wide-chars"),
+ mbo_opt_struct('1', 0, "two-pass"),
mbo_opt_struct('-', 0, NULL) /* end of args */
};
static void usage()
{
- cerr << "usage: re2c [-esbvhd] file\n"
+ cerr << "usage: re2c [-bdefhisvVw1] [-o file] file\n"
"\n"
"-? -h --help Display this info.\n"
"\n"
"-e --ecb Cross-compile from an ASCII platform to\n"
" an EBCDIC one.\n"
"\n"
- "-f --storable-state Implies -t. Generate a scanner that supports storable\n"
- " states.\n"
+ "-f --storable-state Generate a scanner that supports storable states.\n"
"\n"
"-i --no-debug-info Do not generate '#line' info (usefull for versioning).\n"
"\n"
"-s --nested-ifs Generate nested ifs for some switches. Many compilers\n"
" need this assist to generate better code.\n"
"\n"
- "-t --two-pass Force two pass generation, allows YYMAXFILL generation\n"
- " prior to last re2c block.\n"
- "\n"
"-v --version Show version information.\n"
"-V --vernum Show version as one number.\n"
"\n"
"-w --wide-chars Create a parser that supports wide chars (UCS-2). This\n"
" implies -s and cannot be used together with -e switch.\n"
+ "\n"
+ "-1 --single-pass Force two pass generation, allows YYMAXFILL generation\n"
+ " prior to last re2c block.\n"
;
}
case 'f':
fFlag = true;
- tFlag = true;
+ if (bSinglePass) {
+ std::cerr << "re2c: error: cannot combine -1 and -f switch\n";
+ return 1;
+ }
break;
case 'i':
sFlag = true;
break;
- case 't':
- tFlag = true;
+ case '1':
+ if (bFlag) {
+ std::cerr << "re2c: error: cannot combine -1 and -f switch\n";
+ return 1;
+ }
+ bSinglePass = true;
break;
case 'v':
sourceFileInfo = file_info(sourceFileName, &scanner);
outputFileInfo = file_info(outputFileName, &output);
- if (tFlag)
+ if (!bSinglePass)
{
bUsedYYMarker = false;
re2c \- convert regular expressions to C/C++
.SH SYNOPSIS
-\*(re [\fB-bdefhistvVw\fP] [\fB-o output\fP] file\fP
+\*(re [\fB-bdefhisvVw1\fP] [\fB-o output\fP] file\fP
.SH DESCRIPTION
\*(re is a preprocessor that generates C-based recognizers from regular
.fi
.in -3
-After the \fC/*!re2c */\fP blocks you can place one \fC/*!max:re2c */\fP comment
-that will output a define (\fCYYMAXFILL\fP) that holds the maximum number of
-characters required to parse the input. That is the maximum value \fCYYFILL\fP(n)
-will receive. If -t is in effect then YYMAXFILL can be triggered once anywhere
-in the code.
+You can place one \fC/*!max:re2c */\fP comment that will output a "#define
+\fCYYMAXFILL\fP <n>" line that holds the maximum number of characters
+required to parse the input. That is the maximum value \fCYYFILL\fP(n)
+will receive. If -1 is in effect then YYMAXFILL can only be triggered once
+after the last \fC/*!re2c */\fP.
You can also use \fC/*!ignore:re2c */\fP blocks that allows to document the
scanner code and will not be part of the output.
Cross-compile from an ASCII platform to an EBCDIC one.
.TP
\fB-f\fP
-Implies \fB-t\fP. Generate a scanner with support for storable state.
+Generate a scanner with support for storable state.
For details see below at \fBSCANNER WITH STORABLE STATES\fP.
.TP
\fB-i\fP
Generate nested \fCif\fPs for some \fCswitch\fPes. Many compilers need this
assist to generate better code.
.TP
-\fB-t\fP
-Force two pass generation, allows YYMAXFILL generation prior to last re2c block.
-.TP
\fB-v\fP
Show version information.
.TP
\fB-w\fP
Create a parser that supports wide chars (UCS-2). This implies \fB-s\fP and
cannot be used together with \fB-e\fP switch.
+.TP
+\fB-1\fP
+Force single pass generation, this cannot be combined with -f.
.SH "INTERFACE CODE"
Unlike other scanner generators, \*(re does not generate complete scanners:
the user must supply some interface code.
be provided. \fCYYFILL\fP(n) should adjust \fCYYCURSOR\fP, \fCYYLIMIT\fP,
\fCYYMARKER\fP and \fCYYCTXMARKER\fP as needed. Note that for typical
programming languages \fIn\fP will be the length of the longest keyword plus one.
-The user can place a comment of the form \fC/*!max:re2c */\fP once after the
-end of the last scanner block to insert a \fCYYMAXFILL\fP definition that is
-set to the maximum length value. If -t switch is used then YYMAXFILL can be
-triggered once anywhere in the code.
+The user can place a comment of the form \fC/*!max:re2c */\fP once to insert
+a \fCYYMAXFILL\fP definition that is set to the maximum length value. If -1
+switch is used then YYMAXFILL can be triggered once after the last \fC/*!re2c */\fP
+block.
.TP
\fCYYGETSTATE()\fP
The user only needs to define this macro if the \fB-f\fP flag was specified.
echo:
/*!re2c
"/*!re2c" {
- if (bUsedYYMaxFill && bLastPass && !tFlag) {
+ if (bUsedYYMaxFill && bSinglePass) {
fatal("found scanner block after YYMAXFILL declaration");
}
out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
-/* Generated by re2c */
-#line 1 "error1.re"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define RET(n) return n
-
-int scan(const char *s, int l) {
-const char *p = s;
-const char *q;
-#define YYCTYPE char
-#define YYCURSOR p
-#define YYLIMIT (s+l)
-#define YYMARKER q
-#define YYFILL(n)
re2c: error: line 18, column 5: illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers
-/* Generated by re2c */
-#line 1 "error10.re"
re2c: error: line 2, column 6: Illegal unicode character, eight hexadecimal digits are required
-/* Generated by re2c */
-#line 1 "error11.re"
re2c: error: line 2, column 9: Illegal unicode character, non hexadecimal digit found
-/* Generated by re2c */
-#line 1 "error12.re"
re2c: error: line 3, column 17: trailing contexts are not allowed in named definitions
--- /dev/null
+/* Generated by re2c */
+#line 1 "error13.1.re"
+#define YYMAXFILL 1
+
+re2c: error: line 0, column 1: found scanner block after YYMAXFILL declaration
/* Generated by re2c */
#line 1 "error13.re"
-#define YYMAXFILL 1
+#define YYMAXFILL 3
+
+
+#line 7 "<stdout>"
+{
+ YYCTYPE yych;
+
+ if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+ yych = *YYCURSOR;
+ switch(yych){
+ case 'A': goto yy2;
+ default: goto yy4;
+ }
+yy2:
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'B': goto yy5;
+ default: goto yy3;
+ }
+yy3:
+#line 6 "error13.re"
+ { return 0; }
+#line 26 "<stdout>"
+yy4:
+ yych = *++YYCURSOR;
+ goto yy3;
+yy5:
+ yych = *++YYCURSOR;
+ switch(yych){
+ case 'C': goto yy7;
+ case 'D': goto yy9;
+ default: goto yy6;
+ }
+yy6:
+ YYCURSOR = YYMARKER;
+ goto yy3;
+yy7:
+ ++YYCURSOR;
+#line 4 "error13.re"
+ { return 1; }
+#line 44 "<stdout>"
+yy9:
+ ++YYCURSOR;
+#line 5 "error13.re"
+ { return 2; }
+#line 49 "<stdout>"
+}
+#line 7 "error13.re"
-re2c: error: line 0, column 1: found scanner block after YYMAXFILL declaration
/* Generated by re2c */
-#line 1 "error13.t.re"
-#define YYMAXFILL 3
-
+#line 1 "error14.1.re"
-#line 7 "<stdout>"
+#line 5 "<stdout>"
{
YYCTYPE yych;
default: goto yy3;
}
yy3:
-#line 6 "error13.t.re"
+#line 4 "error14.1.re"
{ return 0; }
-#line 26 "<stdout>"
+#line 24 "<stdout>"
yy4:
yych = *++YYCURSOR;
goto yy3;
goto yy3;
yy7:
++YYCURSOR;
-#line 4 "error13.t.re"
+#line 2 "error14.1.re"
{ return 1; }
-#line 44 "<stdout>"
+#line 42 "<stdout>"
yy9:
++YYCURSOR;
-#line 5 "error13.t.re"
+#line 3 "error14.1.re"
{ return 2; }
-#line 49 "<stdout>"
+#line 47 "<stdout>"
}
-#line 7 "error13.t.re"
+#line 5 "error14.1.re"
+
+
+#define YYMAXFILL 3
+re2c: error: line 5, column 1: cannot generate YYMAXFILL twice
-/* Generated by re2c */
-#line 1 "error14.re"
-
-#line 5 "<stdout>"
-{
- YYCTYPE yych;
-
- if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
- yych = *YYCURSOR;
- switch(yych){
- case 'A': goto yy2;
- default: goto yy4;
- }
-yy2:
- yych = *(YYMARKER = ++YYCURSOR);
- switch(yych){
- case 'B': goto yy5;
- default: goto yy3;
- }
-yy3:
-#line 4 "error14.re"
- { return 0; }
-#line 24 "<stdout>"
-yy4:
- yych = *++YYCURSOR;
- goto yy3;
-yy5:
- yych = *++YYCURSOR;
- switch(yych){
- case 'C': goto yy7;
- case 'D': goto yy9;
- default: goto yy6;
- }
-yy6:
- YYCURSOR = YYMARKER;
- goto yy3;
-yy7:
- ++YYCURSOR;
-#line 2 "error14.re"
- { return 1; }
-#line 42 "<stdout>"
-yy9:
- ++YYCURSOR;
-#line 3 "error14.re"
- { return 2; }
-#line 47 "<stdout>"
-}
-#line 5 "error14.re"
-
-
-#define YYMAXFILL 3
-
re2c: error: line 5, column 1: cannot generate YYMAXFILL twice
+++ /dev/null
-re2c: error: line 5, column 1: cannot generate YYMAXFILL twice
-/* Generated by re2c */
-#line 1 "error2.re"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define RET(n) return n
-
-int scan(const char *s, int l) {
-const char *p = s;
-const char *q;
-#define YYCTYPE char
-#define YYCURSOR p
-#define YYLIMIT (s+l)
-#define YYMARKER q
-#define YYFILL(n)
re2c: error: line 18, column 5: illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers
-/* Generated by re2c */
-#line 1 "error3.re"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define RET(n) return n
-
-int scan(const char *s, int l) {
-const char *p = s;
-const char *q;
-#define YYCTYPE char
-#define YYCURSOR p
-#define YYLIMIT (s+l)
-#define YYMARKER q
-#define YYFILL(n)
re2c: error: line 18, column 5: unexpected character: ']'
-/* Generated by re2c */
-#line 1 "error4.re"
re2c: error: line 2, column 5: Illegal hexadecimal character code, two hexadecimal digits are required
-/* Generated by re2c */
-#line 1 "error5.re"
re2c: error: line 2, column 5: Illegal hexadecimal character code
-/* Generated by re2c */
-#line 1 "error6.re"
re2c: error: line 2, column 7: Illegal hexadecimal character code, four hexadecimal digits are required
-/* Generated by re2c */
-#line 1 "error7.re"
re2c: error: line 2, column 3: Illegal octal character code, first digit must be 0 thru 3
-/* Generated by re2c */
-#line 1 "error8.re"
re2c: error: line 2, column 4: Illegal octal character code, non octal digit found
-/* Generated by re2c */
-#line 1 "error9.re"
re2c: error: line 2, column 5: Illegal octal character code, non octal digit found