Also allow use '-r' together with '-e'. Added test.
{
bUseYYSetStateNaked = num != 0;
}
+ else if (cfg.to_string() == "flags:e")
+ {
+ if (num != 0)
+ encoding.setEBCDIC();
+ else
+ encoding.unsetEBCDIC();
+ if (encoding.isBad())
+ fatal("Cannot set '-e' switch: please reset '-w', '-x', '-u' and '-8' switches at first.\n");
+ }
else if (cfg.to_string() == "flags:u")
{
- if (!rFlag)
- {
- fatalf("cannot use configuration name '%s' without -r flag", cfg.to_string().c_str());
- }
if (num != 0)
encoding.setUTF32();
else
}
else if (cfg.to_string() == "flags:w")
{
- if (!rFlag)
- {
- fatalf("cannot use configuration name '%s' without -r flag", cfg.to_string().c_str());
- }
if (num != 0)
encoding.setUCS2();
else
}
else if (cfg.to_string() == "flags:x")
{
- if (!rFlag)
- {
- fatalf("cannot use configuration name '%s' without -r flag", cfg.to_string().c_str());
- }
if (num != 0)
encoding.setUTF16();
else
}
else if (cfg.to_string() == "flags:8")
{
- if (!rFlag)
- {
- fatalf("cannot use configuration name '%s' without -r flag", cfg.to_string().c_str());
- }
if (num != 0)
encoding.setUTF8();
else
'<b>/*!rules:re2c</b>'. In this mode no '<b>/*!re2c</b>' block and exactly one
'<b>/*!rules:re2c</b>' must be present. The rules are being saved and used by
every '<b>/*!use:re2c</b>' block that follows. These blocks can contain
-inplace configurations, especially '<b>re2c:flags:w</b>' and '<b>re2c:flags:u</b>'.
+inplace configurations, especially '<b>re2c:flags:e</b>', '<b>re2c:flags:w</b>',
+'<b>re2c:flags:x</b>', '<b>re2c:flags:u</b>' and '<b>re2c:flags:8</b>'.
That way it is possible to create the same scanner multiple times for different
character types, different input mechanisms or different output mechanisms.
The '<b>/*!use:re2c</b>' blocks can also contain additional rules that will be
"-e --ecb Generate a parser that supports EBCDIC. The generated code\n"
" can deal with any character up to 0xFF. In this mode re2c\n"
" assumes that input character size is 1 byte. This switch is\n"
- " incompatible with -w, -u, -x, -8 and -r\n"
+ " incompatible with -w, -u, -x and -8\n"
"\n"
"-f --storable-state Generate a scanner that supports storable states.\n"
"\n"
"-o of --output=of Specify the output file (of) instead of stdout\n"
"\n"
"-r --reusable Allow reuse of scanner definitions.\n"
- " This cannot be used together with -e switch.\n"
"\n"
"-s --nested-ifs Generate nested ifs for some switches. Many compilers\n"
" need this assist to generate better code.\n"
return 2;
}
- if (rFlag && encoding.isEBCDIC())
- {
- std::cerr << "re2c: error: Cannot combine -e with -r switch\n";
- return 2;
- }
-
if (encoding.isBad())
{
std::cerr << "re2c: error: Only one of switches -e, -w, -x, -u and -8 must be set\n";
'\fB/*!rules:re2c\fP'. In this mode no '\fB/*!re2c\fP' block and exactly one
'\fB/*!rules:re2c\fP' must be present. The rules are being saved and used by
every '\fB/*!use:re2c\fP' block that follows. These blocks can contain
-inplace configurations, especially '\fBre2c:flags:w\fP' and '\fBre2c:flags:u\fP'.
+inplace configurations, especially '\fBre2c:flags:e\fP', '\fBre2c:flags:w\fP',
+'\fBre2c:flags:x\fP', '\fBre2c:flags:u\fP' and '\fBre2c:flags:8\fP'.
That way it is possible to create the same scanner multiple times for different
character types, different input mechanisms or different output mechanisms.
The '\fB/*!use:re2c\fP' blocks can also contain additional rules that will be
--- /dev/null
+/* Generated by re2c */
+EBCDIC:
+
+{
+ YYCTYPE yych;
+
+ if (YYLIMIT <= YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ if (yych == 0x81) goto yy4;
+ ++YYCURSOR;
+ {return DEFAULT;}
+yy4:
+ ++YYCURSOR;
+ {return 0;}
+}
+
+
+UCS2:
+
+{
+ YYCTYPE yych;
+ if (YYLIMIT <= YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ if (yych >= 0xFFFF) goto yy10;
+ ++YYCURSOR;
+ {return DEFAULT;}
+yy10:
+ ++YYCURSOR;
+ {return 0;}
+}
+
+
+UTF16:
+
+{
+ YYCTYPE yych;
+ if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ if (yych == 0xDBFF) goto yy16;
+ ++YYCURSOR;
+yy15:
+ {return DEFAULT;}
+yy16:
+ yych = *++YYCURSOR;
+ if (yych != 0xDFFF) goto yy15;
+ ++YYCURSOR;
+ {return 0;}
+}
+
+
+UTF32:
+
+{
+ YYCTYPE yych;
+ if (YYLIMIT <= YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ if (yych >= 0x0010FFFF) goto yy23;
+ ++YYCURSOR;
+ {return DEFAULT;}
+yy23:
+ ++YYCURSOR;
+ {return 0;}
+}
+
+
+UTF8:
+
+{
+ YYCTYPE yych;
+ if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
+ yych = *YYCURSOR;
+ if (yych == 0xF4) goto yy29;
+ ++YYCURSOR;
+yy28:
+ {return DEFAULT;}
+yy29:
+ yych = *(YYMARKER = ++YYCURSOR);
+ if (yych != 0x8F) goto yy28;
+ yych = *++YYCURSOR;
+ if (yych == 0xBF) goto yy32;
+yy31:
+ YYCURSOR = YYMARKER;
+ goto yy28;
+yy32:
+ yych = *++YYCURSOR;
+ if (yych != 0xBF) goto yy31;
+ ++YYCURSOR;
+ {return 0;}
+}
+
+
+ASCII:
+
+{
+ YYCTYPE yych;
+ if (YYLIMIT <= YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ if (yych == 'a') goto yy39;
+ ++YYCURSOR;
+ {return DEFAULT;}
+yy39:
+ ++YYCURSOR;
+ {return 0;}
+}
+
--- /dev/null
+EBCDIC:
+/*!re2c
+ re2c:flags:e = 1;
+ "a" {return 0;}
+ * {return DEFAULT;}
+*/
+
+UCS2:
+/*!re2c
+ re2c:flags:e = 0;
+ re2c:flags:w = 1;
+ "\uFFFF" {return 0;}
+ * {return DEFAULT;}
+*/
+
+UTF16:
+/*!re2c
+ re2c:flags:w = 0;
+ re2c:flags:x = 1;
+ "\U0010FFFF" {return 0;}
+ * {return DEFAULT;}
+*/
+
+UTF32:
+/*!re2c
+ re2c:flags:x = 0;
+ re2c:flags:u = 1;
+ "\U0010FFFF" {return 0;}
+ * {return DEFAULT;}
+*/
+
+UTF8:
+/*!re2c
+ re2c:flags:u = 0;
+ re2c:flags:8 = 1;
+ "\U0010FFFF" {return 0;}
+ * {return DEFAULT;}
+*/
+
+ASCII:
+/*!re2c
+ re2c:flags:8 = 0;
+ "a" {return 0;}
+ * {return DEFAULT;}
+*/