encoding.setUTF32();
else
encoding.unsetUTF32();
+ if (encoding.isBad())
+ fatal("Cannot set '-u' switch: please reset '-e', '-w' and '-8' switches at first.\n");
}
else if (cfg.to_string() == "flags:w")
{
encoding.setUTF16();
else
encoding.unsetUTF16();
+ if (encoding.isBad())
+ fatal("Cannot set '-w' switch: please reset '-e', '-u' and '-8' switches at first.\n");
}
else if (cfg.to_string() == "flags:8")
{
encoding.setUTF8();
else
encoding.unsetUTF8();
+ if (encoding.isBad())
+ fatal("Cannot set '-8' switch: please reset '-e', '-w' and '-u' switches at first.\n");
}
else
{
class Enc
{
// Supported encodings.
- //
- // UTF32_16 mode is necessary for inplace configurations like:
- // re2c:flags:u = 1;
- // re2c:flags:w = 1;
- // which are for some strange reason considered valid.
- // (see test 're2c/test/repeat-07.gir.re' for example)
enum type_t
{ ASCII = 0x00000000u
, EBCDIC = 0x00000001u
case ASCII: return ASCII_SYMBOLS;
case EBCDIC: return EBCDIC_SYMBOLS;
case UTF16: return UTF16_SYMBOLS;
- case UTF32:
- case UTF32_16: return UTF32_SYMBOLS;
+ case UTF32: return UTF32_SYMBOLS;
case UTF8: return UTF8_SYMBOLS;
default: return BAD;
}
case ASCII: return ASCII_CHARS;
case EBCDIC: return EBCDIC_CHARS;
case UTF16: return UTF16_CHARS;
- case UTF32:
- case UTF32_16: return UTF32_CHARS;
+ case UTF32: return UTF32_CHARS;
case UTF8: return UTF8_CHARS;
default: return BAD;
}
case EBCDIC: return 1;
case UTF16: return 2;
case UTF32:
- case UTF32_16:
case UTF8: return 4;
default: return BAD;
}
case EBCDIC:
case UTF8: return 1;
case UTF16: return 2;
- case UTF32:
- case UTF32_16: return 4;
+ case UTF32: return 4;
default: return BAD;
}
}
-// This test returns 'true' for all valid
-// encoding types except UTF32_16
+// This test returns 'true' for all valid encoding types
inline bool Enc::isBad() const
{
// test if 'type' is a power of 2
case EBCDIC: return asc2ebc[c & 0xFF];
case UTF16:
case UTF32:
- case UTF32_16:
case UTF8: return c;
default: return BAD;
}
case EBCDIC: return ebc2asc[c & 0xFF];
case UTF16:
case UTF32:
- case UTF32_16:
case UTF8: return c;
default: return BAD;
}
if (encoding.isBad())
{
- std::cerr << "re2c: error: Cannot combine -8 with -w or -u or -e switch\n";
+ std::cerr << "re2c: error: Only one of switches -8, -w, -u and -e must be set\n";
return 2;
}
{
/*!use:re2c
+re2c:flags:w = 0;
re2c:flags:u = 1;
-re2c:flags:w = 1;
re2c:define:YYCTYPE = 'unsigned int';
re2c:define:YYFILL = 'fill3';
--- /dev/null
+re2c: error: line 52, column 17: Cannot set '-u' switch: please reset '-e', '-w' and '-8' switches at first.
+
--- /dev/null
+// multiple scanners, additional rules, char width change
+
+void scan(unsigned char* in)
+{
+/*!rules:re2c
+
+"a" := return "a";
+"b" := return "b";
+"c" := return "c";
+"d" := return "d";
+
+re2c:indent:top = 1;
+
+*//*!use:re2c
+
+re2c:flags:u = 0;
+re2c:flags:w = 0;
+
+re2c:define:YYCTYPE = 'unsigned char';
+re2c:define:YYFILL = 'fill1';
+re2c:define:YYCURSOR = 'cursor1';
+re2c:define:YYLIMIT = 'limit1';
+
+"1" := return "1";
+. := return ".";
+
+*/
+}
+
+void scan(unsigned short* in)
+{
+/*!use:re2c
+
+re2c:flags:u = 0;
+re2c:flags:w = 1;
+
+re2c:define:YYCTYPE = 'unsigned short';
+re2c:define:YYFILL = 'fill2';
+re2c:define:YYCURSOR = 'cursor2';
+re2c:define:YYLIMIT = 'limit2';
+
+"2" := return "2";
+. := return ".";
+
+*/
+}
+
+void scan(unsigned int* in)
+{
+/*!use:re2c
+
+re2c:flags:u = 1;
+re2c:flags:w = 1;
+
+re2c:define:YYCTYPE = 'unsigned int';
+re2c:define:YYFILL = 'fill3';
+re2c:define:YYCURSOR = 'cursor3';
+re2c:define:YYLIMIT = 'limit3';
+
+"3" := return "3";
+. := return ".";
+
+*/
+}