From: helly Date: Fri, 28 Nov 2008 09:47:25 +0000 (+0000) Subject: - Fixed #2102138 Duplicate case labels on EBCDIC. X-Git-Tag: 0.13.6~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02b13e6b4e75dc8b13b6a6d519787817ed808a67;p=re2c - Fixed #2102138 Duplicate case labels on EBCDIC. --- diff --git a/re2c/CHANGELOG b/re2c/CHANGELOG index 490ff667..7b7c4199 100644 --- a/re2c/CHANGELOG +++ b/re2c/CHANGELOG @@ -2,6 +2,7 @@ Version 0.13.6 (2008-??-??) --------------------------- - Fixed inplace configuration in -e mode. - Fixed #2186718 Unescaped backslash in file name of #line directive. +- Fixed #2102138 Duplicate case labels on EBCDIC. - Fixed #2088583 Compile problemon AIX. - Fixed #2038610 Ebcdic problem. diff --git a/re2c/actions.cc b/re2c/actions.cc index dca7247b..2e38afe4 100644 --- a/re2c/actions.cc +++ b/re2c/actions.cc @@ -528,7 +528,7 @@ uint Scanner::unescape(SubStr &s) const if ((c = *s.str++) != '\\' || s.len == 0) { - return xlat(c); + return c; } s.len--; @@ -707,24 +707,24 @@ uint Scanner::unescape(SubStr &s) const } default: - return xlat(c); + return c; } } -std::string& Scanner::unescape(SubStr& str_in, std::string& str_out) const +std::string& Scanner::unescape(SubStr& str_in, std::string& str_out, bool translate) const { str_out.clear(); while(str_in.len) { uint c = unescape(str_in); - + if (c > 0xFF) { fatal(str_in.ofs(), "Illegal character"); } - str_out += static_cast(c); + str_out += static_cast(translate ? xlat(c) : c); } return str_out; @@ -767,12 +767,9 @@ Range * Scanner::getRange(SubStr &s) const return r; } } - - lb = xlb; - ub = xub; } - return new Range(lb, ub + 1); + return new Range(xlat(lb), xlat(ub) + 1); } RegExp * Scanner::matchChar(uint c) const @@ -788,10 +785,10 @@ RegExp * Scanner::strToRE(SubStr s) const if (s.len == 0) return new NullOp; - RegExp *re = matchChar(unescape(s)); + RegExp *re = matchChar(xlat(unescape(s))); while (s.len > 0) - re = new CatOp(re, matchChar(unescape(s))); + re = new CatOp(re, matchChar(xlat(unescape(s)))); return re; } @@ -816,7 +813,7 @@ RegExp * Scanner::strToCaseInsensitiveRE(SubStr s) const } else { - re = matchChar(c); + re = matchChar(xlat(c)); } while (s.len > 0) @@ -831,7 +828,7 @@ RegExp * Scanner::strToCaseInsensitiveRE(SubStr s) const } else { - re = new CatOp(re, matchChar(c)); + re = new CatOp(re, matchChar(xlat(c))); } } diff --git a/re2c/bug2102138-test.sh b/re2c/bug2102138-test.sh new file mode 100755 index 00000000..ff0e399f --- /dev/null +++ b/re2c/bug2102138-test.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +make && \ +for n in $(find test -name '*2102138*.re'|sed 's,.re,,'); do + ./run_tests.sh ${n}.re + test -f ${n}.c.temp && mv -f ${n}.c.temp ${n}.c + gcc ${n}.c -o ${n}.o + ./${n}.o >${n}.out + diff -du ${n}.txt ${n}.out >${n}.cc.diff && echo "OK" || echo "FAIL" +done \ No newline at end of file diff --git a/re2c/code.cc b/re2c/code.cc index f239f8b9..d7438951 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -329,7 +329,7 @@ void BitMap::gen(std::ostream &o, uint ind, uint lb, uint ub) if (yybmHexTable) { - prtHex(o, bm[j], false); + prtHex(o, bm[j]); } else { @@ -917,6 +917,10 @@ static bool genCases(std::ostream &o, uint ind, uint lb, Span *s, bool &newLine, o << indent(ind) << "case "; prtChOrHex(o, lb); o << ":"; + if (dFlag && eFlag && lb < 256u && isprint(talx[lb])) + { + o << " /* " << std::string(1, talx[lb]) << " */"; + } } newLine = false; used = true; @@ -1283,7 +1287,7 @@ void Go::genGoto(std::ostream &o, uint ind, const State *from, const State *next o << "if (" << mapCodeName["yybm"] << "[" << b->i << "+" << sYych << "] & "; if (yybmHexTable) { - prtHex(o, b->m, false); + prtHex(o, b->m); } else { @@ -2296,15 +2300,7 @@ void Scanner::config(const Str& cfg, const Str& val) && (val.str[0] == '"' || val.str[0] == '\'')) { SubStr tmp(val.str + 1, val.len - 2); - if (eFlag) { - re2c::xlat = asc2asc; - re2c::talx = asc2asc; - } - unescape(tmp, strVal); - if (eFlag) { - re2c::xlat = asc2ebc; - re2c::talx = ebc2asc; - } + unescape(tmp, strVal, false); } else { diff --git a/re2c/dfa.cc b/re2c/dfa.cc index 3bbd5765..474065b0 100644 --- a/re2c/dfa.cc +++ b/re2c/dfa.cc @@ -8,11 +8,15 @@ namespace re2c { -void prtChOrHex(std::ostream& o, uint c, bool useTalx) +void prtChOrHex(std::ostream& o, uint c) { - uint oc = eFlag && !wFlag && useTalx ? re2c::talx[c] : c; - - if ((oc < 256) && (isprint(oc) || isspace(oc))) + if (eFlag && !wFlag) + { + if (DFlag) o << '"'; + prtHex(o, c); + if (DFlag) o << '"'; + } + else if ((c < 256u) && (isprint(c) || isspace(c))) { o << (DFlag ? '"' : '\''); prtCh(o, c); @@ -26,9 +30,9 @@ void prtChOrHex(std::ostream& o, uint c, bool useTalx) } } -void prtHex(std::ostream& o, uint c, bool useTalx) +void prtHex(std::ostream& o, uint c) { - uint oc = eFlag && !wFlag && useTalx ? re2c::talx[c] : c; + int oc = (int)(c); if (re2c::uFlag) { @@ -58,9 +62,15 @@ void prtHex(std::ostream& o, uint c, bool useTalx) } } -void prtCh(std::ostream& o, uint c, bool useTalx) +void prtCh(std::ostream& o, uint c) { - uint oc = eFlag && !wFlag && useTalx ? re2c::talx[c] : c; + if (eFlag && !wFlag) + { + prtHex(o, c); + return; + } + + int oc = (int)(c); switch (oc) { diff --git a/re2c/dfa.h b/re2c/dfa.h index f2932cef..9262508b 100644 --- a/re2c/dfa.h +++ b/re2c/dfa.h @@ -9,9 +9,9 @@ namespace re2c { -extern void prtCh(std::ostream&, uint, bool useTalx = true); -extern void prtHex(std::ostream&, uint, bool useTalx = true); -extern void prtChOrHex(std::ostream&, uint, bool useTalx = true); +extern void prtCh(std::ostream&, uint); +extern void prtHex(std::ostream&, uint); +extern void prtChOrHex(std::ostream&, uint); extern void printSpan(std::ostream&, uint, uint); class DFA; diff --git a/re2c/htdocs/index.html b/re2c/htdocs/index.html index 0acde993..db4955b3 100755 --- a/re2c/htdocs/index.html +++ b/re2c/htdocs/index.html @@ -84,6 +84,7 @@ fixes which were incorporated. 2008-??-??: 0.13.6
  • Fixed inplace configuration in -e mode.
  • +
  • Fixed #2102138 Duplicate case labels on EBCDIC.
  • Fixed #2186718 Unescaped backslash in file name of #line directive.
  • Fixed #2088583 Compile problemon AIX.
  • Fixed #2038610 Ebcdic problem.
  • diff --git a/re2c/scanner.h b/re2c/scanner.h index 3e59d3a0..82b48d50 100644 --- a/re2c/scanner.h +++ b/re2c/scanner.h @@ -72,7 +72,7 @@ public: uint xlat(uint c) const; uint unescape(SubStr &s) const; - std::string& unescape(SubStr& str_in, std::string& str_out) const; + std::string& unescape(SubStr& str_in, std::string& str_out, bool translate) const; Range * getRange(SubStr &s) const; RegExp * matchChar(uint c) const; diff --git a/re2c/test/bug1711240.ei.c b/re2c/test/bug1711240.ei.c new file mode 100755 index 00000000..93a6d129 --- /dev/null +++ b/re2c/test/bug1711240.ei.c @@ -0,0 +1,260 @@ +/* Generated by re2c */ +char scan(const unsigned char *s) +{ + +{ + YYCTYPE yych; + + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9A: + case 0x9B: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + case 0xC0: + case 0xC1: + case 0xC2: + case 0xC3: + case 0xC4: + case 0xC5: + case 0xC6: + case 0xC7: + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD5: + case 0xD6: + case 0xD7: + case 0xD8: + case 0xD9: + case 0xDA: + case 0xDB: + case 0xDC: + case 0xDD: + case 0xDE: + case 0xDF: goto yy9; + case 0x07: goto yy7; + case 0x61: goto yy5; + case 0x7F: goto yy3; + default: goto yy2; + } +yy2: +yy3: + ++YYCURSOR; + { + return '"'; + } +yy5: + ++YYCURSOR; + { + return '\x2F'; + } +yy7: + ++YYCURSOR; + { + return '\x7F'; + } +yy9: + ++YYCURSOR; + { + return '\0'; + } +} + +} diff --git a/re2c/test/bug1711240.ei.re b/re2c/test/bug1711240.ei.re new file mode 100755 index 00000000..a6065e7b --- /dev/null +++ b/re2c/test/bug1711240.ei.re @@ -0,0 +1,21 @@ +char scan(const unsigned char *s) +{ +/*!re2c + '"' + { + return '"'; + } + "\x2F" + { + return '\x2F'; + } + "\x7F" + { + return '\x7F'; + } + [^] + { + return '\0'; + } +*/ +} diff --git a/re2c/test/bug1711240.eis.c b/re2c/test/bug1711240.eis.c index 762c693d..bef2a48a 100644 --- a/re2c/test/bug1711240.eis.c +++ b/re2c/test/bug1711240.eis.c @@ -7,12 +7,13 @@ char scan(const unsigned char *s) if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych <= '=') { - if (yych == 0x07) goto yy5; - goto yy7; + if (yych <= 0x61) { + if (yych == 0x07) goto yy7; + if (yych <= 0x60) goto yy9; + goto yy5; } else { - if (yych <= '"') goto yy3; - if (yych <= 0xFF) goto yy7; + if (yych == 0x7F) goto yy3; + if (yych <= 0xDF) goto yy9; } yy3: ++YYCURSOR; @@ -25,6 +26,11 @@ yy5: return '\x2F'; } yy7: + ++YYCURSOR; + { + return '\x7F'; + } +yy9: ++YYCURSOR; { return '\0'; diff --git a/re2c/test/bug2102138a.ei.c b/re2c/test/bug2102138a.ei.c new file mode 100755 index 00000000..1324fde5 --- /dev/null +++ b/re2c/test/bug2102138a.ei.c @@ -0,0 +1,1067 @@ +/* Generated by re2c */ +#include + +int scan(const unsigned char *cr) +{ + unsigned char ch; + +{ + unsigned char ch; + + ch = *cr; + switch (ch) { + case 0x00: goto yy2; + case 0x01: goto yy4; + case 0x02: goto yy6; + case 0x03: goto yy8; + case 0x04: goto yy314; + case 0x05: goto yy20; + case 0x06: goto yy270; + case 0x07: goto yy256; + case 0x08: goto yy304; + case 0x09: goto yy284; + case 0x0A: goto yy286; + case 0x0B: goto yy24; + case 0x0C: goto yy26; + case 0x0D: goto yy28; + case 0x0E: goto yy30; + case 0x0F: goto yy32; + case 0x10: goto yy34; + case 0x11: goto yy36; + case 0x12: goto yy38; + case 0x13: goto yy40; + case 0x14: goto yy316; + case 0x15: goto yy268; + case 0x16: goto yy18; + case 0x17: goto yy272; + case 0x18: goto yy50; + case 0x19: goto yy52; + case 0x1A: goto yy294; + case 0x1B: goto yy288; + case 0x1C: goto yy58; + case 0x1D: goto yy60; + case 0x1E: goto yy62; + case 0x1F: goto yy64; + case 0x20: goto yy258; + case 0x21: goto yy260; + case 0x22: goto yy262; + case 0x23: goto yy264; + case 0x24: goto yy266; + case 0x25: goto yy22; + case 0x26: goto yy48; + case 0x27: goto yy56; + case 0x28: goto yy274; + case 0x29: goto yy276; + case 0x2A: goto yy278; + case 0x2B: goto yy280; + case 0x2C: goto yy282; + case 0x2D: goto yy12; + case 0x2E: goto yy14; + case 0x2F: goto yy16; + case 0x30: goto yy290; + case 0x31: goto yy292; + case 0x32: goto yy46; + case 0x33: goto yy296; + case 0x34: goto yy298; + case 0x35: goto yy300; + case 0x36: goto yy302; + case 0x37: goto yy10; + case 0x38: goto yy306; + case 0x39: goto yy308; + case 0x3A: goto yy310; + case 0x3B: goto yy312; + case 0x3C: goto yy42; + case 0x3D: goto yy44; + case 0x3E: goto yy318; + case 0x3F: goto yy54; + case 0x40: goto yy66; + case 0x41: goto yy322; + case 0x42: goto yy454; + case 0x43: goto yy458; + case 0x44: goto yy450; + case 0x45: goto yy452; + case 0x46: goto yy456; + case 0x47: goto yy460; + case 0x48: goto yy464; + case 0x49: goto yy484; + case 0x4A: goto yy326; + case 0x4B: goto yy94; + case 0x4C: goto yy122; + case 0x4D: goto yy82; + case 0x4E: goto yy88; + case 0x4F: goto yy250; + case 0x50: goto yy78; + case 0x51: goto yy468; + case 0x52: goto yy470; + case 0x53: goto yy472; + case 0x54: goto yy466; + case 0x55: goto yy476; + case 0x56: goto yy478; + case 0x57: goto yy480; + case 0x58: goto yy474; + case 0x59: goto yy448; + case 0x5A: goto yy68; + case 0x5B: goto yy74; + case 0x5C: goto yy86; + case 0x5D: goto yy84; + case 0x5E: goto yy120; + case 0x5F: goto yy346; + case 0x60: goto yy92; + case 0x61: goto yy96; + case 0x62: goto yy390; + case 0x63: goto yy394; + case 0x64: goto yy386; + case 0x65: goto yy388; + case 0x66: goto yy392; + case 0x67: goto yy396; + case 0x68: goto yy400; + case 0x69: goto yy420; + case 0x6A: goto yy334; + case 0x6B: goto yy90; + case 0x6C: goto yy76; + case 0x6D: goto yy192; + case 0x6E: goto yy126; + case 0x6F: goto yy128; + case 0x70: goto yy498; + case 0x71: goto yy404; + case 0x72: goto yy406; + case 0x73: goto yy408; + case 0x74: goto yy402; + case 0x75: goto yy412; + case 0x76: goto yy414; + case 0x77: goto yy416; + case 0x78: goto yy410; + case 0x79: goto yy194; + case 0x7A: goto yy118; + case 0x7B: goto yy72; + case 0x7C: goto yy130; + case 0x7D: goto yy80; + case 0x7E: goto yy124; + case 0x7F: goto yy70; + case 0x80: goto yy434; + case 0x81: goto yy196; + case 0x82: goto yy198; + case 0x83: goto yy200; + case 0x84: goto yy202; + case 0x85: goto yy204; + case 0x86: goto yy206; + case 0x87: goto yy208; + case 0x88: goto yy210; + case 0x89: goto yy212; + case 0x8A: goto yy344; + case 0x8B: goto yy376; + case 0x8C: goto yy482; + case 0x8D: goto yy508; + case 0x8E: goto yy446; + case 0x8F: goto yy356; + case 0x90: goto yy354; + case 0x91: goto yy214; + case 0x92: goto yy216; + case 0x93: goto yy218; + case 0x94: goto yy220; + case 0x95: goto yy222; + case 0x96: goto yy224; + case 0x97: goto yy226; + case 0x98: goto yy228; + case 0x99: goto yy230; + case 0x9A: goto yy342; + case 0x9B: goto yy374; + case 0x9C: goto yy462; + case 0x9D: goto yy370; + case 0x9E: goto yy398; + case 0x9F: goto yy330; + case 0xA0: goto yy364; + case 0xA1: goto yy254; + case 0xA2: goto yy232; + case 0xA3: goto yy234; + case 0xA4: goto yy236; + case 0xA5: goto yy238; + case 0xA6: goto yy240; + case 0xA7: goto yy242; + case 0xA8: goto yy244; + case 0xA9: goto yy246; + case 0xAA: goto yy324; + case 0xAB: goto yy384; + case 0xAC: goto yy418; + case 0xAD: goto yy444; + case 0xAE: goto yy510; + case 0xAF: goto yy350; + case 0xB0: goto yy190; + case 0xB1: goto yy328; + case 0xB2: goto yy332; + case 0xB3: goto yy368; + case 0xB4: goto yy340; + case 0xB5: goto yy336; + case 0xB6: goto yy366; + case 0xB7: goto yy378; + case 0xB8: goto yy380; + case 0xB9: goto yy382; + case 0xBA: goto yy184; + case 0xBB: goto yy188; + case 0xBC: goto yy352; + case 0xBD: goto yy338; + case 0xBE: goto yy362; + case 0xBF: goto yy432; + case 0xC0: goto yy248; + case 0xC1: goto yy132; + case 0xC2: goto yy134; + case 0xC3: goto yy136; + case 0xC4: goto yy138; + case 0xC5: goto yy140; + case 0xC6: goto yy142; + case 0xC7: goto yy144; + case 0xC8: goto yy146; + case 0xC9: goto yy148; + case 0xCA: goto yy348; + case 0xCB: goto yy490; + case 0xCC: goto yy494; + case 0xCD: goto yy486; + case 0xCE: goto yy488; + case 0xCF: goto yy492; + case 0xD0: goto yy252; + case 0xD1: goto yy150; + case 0xD2: goto yy152; + case 0xD3: goto yy154; + case 0xD4: goto yy156; + case 0xD5: goto yy158; + case 0xD6: goto yy160; + case 0xD7: goto yy162; + case 0xD8: goto yy164; + case 0xD9: goto yy166; + case 0xDA: goto yy372; + case 0xDB: goto yy504; + case 0xDC: goto yy506; + case 0xDD: goto yy500; + case 0xDE: goto yy502; + case 0xDF: goto yy512; + case 0xE0: goto yy186; + case 0xE1: goto yy496; + case 0xE2: goto yy168; + case 0xE3: goto yy170; + case 0xE4: goto yy172; + case 0xE5: goto yy174; + case 0xE6: goto yy176; + case 0xE7: goto yy178; + case 0xE8: goto yy180; + case 0xE9: goto yy182; + case 0xEA: goto yy358; + case 0xEB: goto yy426; + case 0xEC: goto yy430; + case 0xED: goto yy422; + case 0xEE: goto yy424; + case 0xEF: goto yy428; + case 0xF0: goto yy98; + case 0xF1: goto yy100; + case 0xF2: goto yy102; + case 0xF3: goto yy104; + case 0xF4: goto yy106; + case 0xF5: goto yy108; + case 0xF6: goto yy110; + case 0xF7: goto yy112; + case 0xF8: goto yy114; + case 0xF9: goto yy116; + case 0xFA: goto yy360; + case 0xFB: goto yy440; + case 0xFC: goto yy442; + case 0xFD: goto yy436; + case 0xFE: goto yy438; + default: goto yy320; + } +yy2: + ++cr; + return 0x00; +yy4: + ++cr; + return 0x01; +yy6: + ++cr; + return 0x02; +yy8: + ++cr; + return 0x03; +yy10: + ++cr; + return 0x04; +yy12: + ++cr; + return 0x05; +yy14: + ++cr; + return 0x06; +yy16: + ++cr; + return 0x07; +yy18: + ++cr; + return 0x08; +yy20: + ++cr; + return 0x09; +yy22: + ++cr; + return 0x0A; +yy24: + ++cr; + return 0x0B; +yy26: + ++cr; + return 0x0C; +yy28: + ++cr; + return 0x0D; +yy30: + ++cr; + return 0x0E; +yy32: + ++cr; + return 0x0F; +yy34: + ++cr; + return 0x10; +yy36: + ++cr; + return 0x11; +yy38: + ++cr; + return 0x12; +yy40: + ++cr; + return 0x13; +yy42: + ++cr; + return 0x14; +yy44: + ++cr; + return 0x15; +yy46: + ++cr; + return 0x16; +yy48: + ++cr; + return 0x17; +yy50: + ++cr; + return 0x18; +yy52: + ++cr; + return 0x19; +yy54: + ++cr; + return 0x1A; +yy56: + ++cr; + return 0x1B; +yy58: + ++cr; + return 0x1C; +yy60: + ++cr; + return 0x1D; +yy62: + ++cr; + return 0x1E; +yy64: + ++cr; + return 0x1F; +yy66: + ++cr; + return 0x20; +yy68: + ++cr; + return 0x21; +yy70: + ++cr; + return 0x22; +yy72: + ++cr; + return 0x23; +yy74: + ++cr; + return 0x24; +yy76: + ++cr; + return 0x25; +yy78: + ++cr; + return 0x26; +yy80: + ++cr; + return 0x27; +yy82: + ++cr; + return 0x28; +yy84: + ++cr; + return 0x29; +yy86: + ++cr; + return 0x2A; +yy88: + ++cr; + return 0x2B; +yy90: + ++cr; + return 0x2C; +yy92: + ++cr; + return 0x2D; +yy94: + ++cr; + return 0x2E; +yy96: + ++cr; + return 0x2F; +yy98: + ++cr; + return 0x30; +yy100: + ++cr; + return 0x31; +yy102: + ++cr; + return 0x32; +yy104: + ++cr; + return 0x33; +yy106: + ++cr; + return 0x34; +yy108: + ++cr; + return 0x35; +yy110: + ++cr; + return 0x36; +yy112: + ++cr; + return 0x37; +yy114: + ++cr; + return 0x38; +yy116: + ++cr; + return 0x39; +yy118: + ++cr; + return 0x3A; +yy120: + ++cr; + return 0x3B; +yy122: + ++cr; + return 0x3C; +yy124: + ++cr; + return 0x3D; +yy126: + ++cr; + return 0x3E; +yy128: + ++cr; + return 0x3F; +yy130: + ++cr; + return 0x40; +yy132: + ++cr; + return 0x41; +yy134: + ++cr; + return 0x42; +yy136: + ++cr; + return 0x43; +yy138: + ++cr; + return 0x44; +yy140: + ++cr; + return 0x45; +yy142: + ++cr; + return 0x46; +yy144: + ++cr; + return 0x47; +yy146: + ++cr; + return 0x48; +yy148: + ++cr; + return 0x49; +yy150: + ++cr; + return 0x4A; +yy152: + ++cr; + return 0x4B; +yy154: + ++cr; + return 0x4C; +yy156: + ++cr; + return 0x4D; +yy158: + ++cr; + return 0x4E; +yy160: + ++cr; + return 0x4F; +yy162: + ++cr; + return 0x50; +yy164: + ++cr; + return 0x51; +yy166: + ++cr; + return 0x52; +yy168: + ++cr; + return 0x53; +yy170: + ++cr; + return 0x54; +yy172: + ++cr; + return 0x55; +yy174: + ++cr; + return 0x56; +yy176: + ++cr; + return 0x57; +yy178: + ++cr; + return 0x58; +yy180: + ++cr; + return 0x59; +yy182: + ++cr; + return 0x5A; +yy184: + ++cr; + return 0x5B; +yy186: + ++cr; + return 0x5C; +yy188: + ++cr; + return 0x5D; +yy190: + ++cr; + return 0x5E; +yy192: + ++cr; + return 0x5F; +yy194: + ++cr; + return 0x60; +yy196: + ++cr; + return 0x61; +yy198: + ++cr; + return 0x62; +yy200: + ++cr; + return 0x63; +yy202: + ++cr; + return 0x64; +yy204: + ++cr; + return 0x65; +yy206: + ++cr; + return 0x66; +yy208: + ++cr; + return 0x67; +yy210: + ++cr; + return 0x68; +yy212: + ++cr; + return 0x69; +yy214: + ++cr; + return 0x6A; +yy216: + ++cr; + return 0x6B; +yy218: + ++cr; + return 0x6C; +yy220: + ++cr; + return 0x6D; +yy222: + ++cr; + return 0x6E; +yy224: + ++cr; + return 0x6F; +yy226: + ++cr; + return 0x70; +yy228: + ++cr; + return 0x71; +yy230: + ++cr; + return 0x72; +yy232: + ++cr; + return 0x73; +yy234: + ++cr; + return 0x74; +yy236: + ++cr; + return 0x75; +yy238: + ++cr; + return 0x76; +yy240: + ++cr; + return 0x77; +yy242: + ++cr; + return 0x78; +yy244: + ++cr; + return 0x79; +yy246: + ++cr; + return 0x7A; +yy248: + ++cr; + return 0x7B; +yy250: + ++cr; + return 0x7C; +yy252: + ++cr; + return 0x7D; +yy254: + ++cr; + return 0x7E; +yy256: + ++cr; + return 0x7F; +yy258: + ++cr; + return 0x80; +yy260: + ++cr; + return 0x81; +yy262: + ++cr; + return 0x82; +yy264: + ++cr; + return 0x83; +yy266: + ++cr; + return 0x84; +yy268: + ++cr; + return 0x85; +yy270: + ++cr; + return 0x86; +yy272: + ++cr; + return 0x87; +yy274: + ++cr; + return 0x88; +yy276: + ++cr; + return 0x89; +yy278: + ++cr; + return 0x8A; +yy280: + ++cr; + return 0x8B; +yy282: + ++cr; + return 0x8C; +yy284: + ++cr; + return 0x8D; +yy286: + ++cr; + return 0x8E; +yy288: + ++cr; + return 0x8F; +yy290: + ++cr; + return 0x90; +yy292: + ++cr; + return 0x91; +yy294: + ++cr; + return 0x92; +yy296: + ++cr; + return 0x93; +yy298: + ++cr; + return 0x94; +yy300: + ++cr; + return 0x95; +yy302: + ++cr; + return 0x96; +yy304: + ++cr; + return 0x97; +yy306: + ++cr; + return 0x98; +yy308: + ++cr; + return 0x99; +yy310: + ++cr; + return 0x9A; +yy312: + ++cr; + return 0x9B; +yy314: + ++cr; + return 0x9C; +yy316: + ++cr; + return 0x9D; +yy318: + ++cr; + return 0x9E; +yy320: + ++cr; + return 0x9F; +yy322: + ++cr; + return 0xA0; +yy324: + ++cr; + return 0xA1; +yy326: + ++cr; + return 0xA2; +yy328: + ++cr; + return 0xA3; +yy330: + ++cr; + return 0xA4; +yy332: + ++cr; + return 0xA5; +yy334: + ++cr; + return 0xA6; +yy336: + ++cr; + return 0xA7; +yy338: + ++cr; + return 0xA8; +yy340: + ++cr; + return 0xA9; +yy342: + ++cr; + return 0xAA; +yy344: + ++cr; + return 0xAB; +yy346: + ++cr; + return 0xAC; +yy348: + ++cr; + return 0xAD; +yy350: + ++cr; + return 0xAE; +yy352: + ++cr; + return 0xAF; +yy354: + ++cr; + return 0xB0; +yy356: + ++cr; + return 0xB1; +yy358: + ++cr; + return 0xB2; +yy360: + ++cr; + return 0xB3; +yy362: + ++cr; + return 0xB4; +yy364: + ++cr; + return 0xB5; +yy366: + ++cr; + return 0xB6; +yy368: + ++cr; + return 0xB7; +yy370: + ++cr; + return 0xB8; +yy372: + ++cr; + return 0xB9; +yy374: + ++cr; + return 0xBA; +yy376: + ++cr; + return 0xBB; +yy378: + ++cr; + return 0xBC; +yy380: + ++cr; + return 0xBD; +yy382: + ++cr; + return 0xBE; +yy384: + ++cr; + return 0xBF; +yy386: + ++cr; + return 0xC0; +yy388: + ++cr; + return 0xC1; +yy390: + ++cr; + return 0xC2; +yy392: + ++cr; + return 0xC3; +yy394: + ++cr; + return 0xC4; +yy396: + ++cr; + return 0xC5; +yy398: + ++cr; + return 0xC6; +yy400: + ++cr; + return 0xC7; +yy402: + ++cr; + return 0xC8; +yy404: + ++cr; + return 0xC9; +yy406: + ++cr; + return 0xCA; +yy408: + ++cr; + return 0xCB; +yy410: + ++cr; + return 0xCC; +yy412: + ++cr; + return 0xCD; +yy414: + ++cr; + return 0xCE; +yy416: + ++cr; + return 0xCF; +yy418: + ++cr; + return 0xD0; +yy420: + ++cr; + return 0xD1; +yy422: + ++cr; + return 0xD2; +yy424: + ++cr; + return 0xD3; +yy426: + ++cr; + return 0xD4; +yy428: + ++cr; + return 0xD5; +yy430: + ++cr; + return 0xD6; +yy432: + ++cr; + return 0xD7; +yy434: + ++cr; + return 0xD8; +yy436: + ++cr; + return 0xD9; +yy438: + ++cr; + return 0xDA; +yy440: + ++cr; + return 0xDB; +yy442: + ++cr; + return 0xDC; +yy444: + ++cr; + return 0xDD; +yy446: + ++cr; + return 0xDE; +yy448: + ++cr; + return 0xDF; +yy450: + ++cr; + return 0xE0; +yy452: + ++cr; + return 0xE1; +yy454: + ++cr; + return 0xE2; +yy456: + ++cr; + return 0xE3; +yy458: + ++cr; + return 0xE4; +yy460: + ++cr; + return 0xE5; +yy462: + ++cr; + return 0xE6; +yy464: + ++cr; + return 0xE7; +yy466: + ++cr; + return 0xE8; +yy468: + ++cr; + return 0xE9; +yy470: + ++cr; + return 0xEA; +yy472: + ++cr; + return 0xEB; +yy474: + ++cr; + return 0xEC; +yy476: + ++cr; + return 0xED; +yy478: + ++cr; + return 0xEE; +yy480: + ++cr; + return 0xEF; +yy482: + ++cr; + return 0xF0; +yy484: + ++cr; + return 0xF1; +yy486: + ++cr; + return 0xF2; +yy488: + ++cr; + return 0xF3; +yy490: + ++cr; + return 0xF4; +yy492: + ++cr; + return 0xF5; +yy494: + ++cr; + return 0xF6; +yy496: + ++cr; + return 0xF7; +yy498: + ++cr; + return 0xF8; +yy500: + ++cr; + return 0xF9; +yy502: + ++cr; + return 0xFA; +yy504: + ++cr; + return 0xFB; +yy506: + ++cr; + return 0xFC; +yy508: + ++cr; + return 0xFD; +yy510: + ++cr; + return 0xFE; +yy512: + ++cr; + return 0xFF; +} + +} + +int main(int argc, char** argv) { + unsigned char buf[2]; + unsigned int ch = 0; + buf[1] = 0u; + + printf("const uint ebc2asc[256] =\n"); + printf(" { /* Based on ISO 8859/1 and Code Page 37 */\n"); + for (;;) { + if (ch % 16 == 0) { + printf(" "); + } + buf[0] = ch++; + printf("0x%02x", scan(buf)); + if (ch == 256) { + printf("\n"); + break; + } + if (ch % 16 == 0) { + printf(",\n"); + } else { + printf(", "); + } + } + printf(" };\n"); + return 0; +} diff --git a/re2c/test/bug2102138a.ei.re b/re2c/test/bug2102138a.ei.re new file mode 100755 index 00000000..04e17552 --- /dev/null +++ b/re2c/test/bug2102138a.ei.re @@ -0,0 +1,314 @@ +#include + +int scan(const unsigned char *cr) +{ + unsigned char ch; +/*!re2c + +re2c:define:YYCTYPE = "unsigned char"; +re2c:define:YYCURSOR = cr; +re2c:define:YYFILL = fill; +re2c:variable:yych = ch; +re2c:yyfill:enable = 0; + +"\x00" := return 0x00; +"\x01" := return 0x01; +"\x02" := return 0x02; +"\x03" := return 0x03; +"\x04" := return 0x04; +"\x05" := return 0x05; +"\x06" := return 0x06; +"\x07" := return 0x07; +"\x08" := return 0x08; +"\x09" := return 0x09; +"\x0A" := return 0x0A; +"\x0B" := return 0x0B; +"\x0C" := return 0x0C; +"\x0D" := return 0x0D; +"\x0E" := return 0x0E; +"\x0F" := return 0x0F; + +"\x10" := return 0x10; +"\x11" := return 0x11; +"\x12" := return 0x12; +"\x13" := return 0x13; +"\x14" := return 0x14; +"\x15" := return 0x15; +"\x16" := return 0x16; +"\x17" := return 0x17; +"\x18" := return 0x18; +"\x19" := return 0x19; +"\x1A" := return 0x1A; +"\x1B" := return 0x1B; +"\x1C" := return 0x1C; +"\x1D" := return 0x1D; +"\x1E" := return 0x1E; +"\x1F" := return 0x1F; + +" " := return 0x20; +"!" := return 0x21; +"\"" := return 0x22; +"#" := return 0x23; +"$" := return 0x24; +"%" := return 0x25; +"&" := return 0x26; +"'" := return 0x27; +"(" := return 0x28; +")" := return 0x29; +"*" := return 0x2A; +"+" := return 0x2B; +"," := return 0x2C; +"-" := return 0x2D; +"." := return 0x2E; +"/" := return 0x2F; + +"0" := return 0x30; +"1" := return 0x31; +"2" := return 0x32; +"3" := return 0x33; +"4" := return 0x34; +"5" := return 0x35; +"6" := return 0x36; +"7" := return 0x37; +"8" := return 0x38; +"9" := return 0x39; +":" := return 0x3A; +";" := return 0x3B; +"<" := return 0x3C; +"=" := return 0x3D; +">" := return 0x3E; +"?" := return 0x3F; + +"@" := return 0x40; +"A" := return 0x41; +"B" := return 0x42; +"C" := return 0x43; +"D" := return 0x44; +"E" := return 0x45; +"F" := return 0x46; +"G" := return 0x47; +"H" := return 0x48; +"I" := return 0x49; +"J" := return 0x4A; +"K" := return 0x4B; +"L" := return 0x4C; +"M" := return 0x4D; +"N" := return 0x4E; +"O" := return 0x4F; + +"P" := return 0x50; +"Q" := return 0x51; +"R" := return 0x52; +"S" := return 0x53; +"T" := return 0x54; +"U" := return 0x55; +"V" := return 0x56; +"W" := return 0x57; +"X" := return 0x58; +"Y" := return 0x59; +"Z" := return 0x5A; +"[" := return 0x5B; +"\\" := return 0x5C; +"]" := return 0x5D; +"^" := return 0x5E; +"_" := return 0x5F; + +"`" := return 0x60; +"a" := return 0x61; +"b" := return 0x62; +"c" := return 0x63; +"d" := return 0x64; +"e" := return 0x65; +"f" := return 0x66; +"g" := return 0x67; +"h" := return 0x68; +"i" := return 0x69; +"j" := return 0x6A; +"k" := return 0x6B; +"l" := return 0x6C; +"m" := return 0x6D; +"n" := return 0x6E; +"o" := return 0x6F; + +"p" := return 0x70; +"q" := return 0x71; +"r" := return 0x72; +"s" := return 0x73; +"t" := return 0x74; +"u" := return 0x75; +"v" := return 0x76; +"w" := return 0x77; +"x" := return 0x78; +"y" := return 0x79; +"z" := return 0x7A; +"{" := return 0x7B; +"|" := return 0x7C; +"}" := return 0x7D; +"~" := return 0x7E; +"\x7F" := return 0x7F; + +"\x80" := return 0x80; +"\x81" := return 0x81; +"\x82" := return 0x82; +"\x83" := return 0x83; +"\x84" := return 0x84; +"\x85" := return 0x85; +"\x86" := return 0x86; +"\x87" := return 0x87; +"\x88" := return 0x88; +"\x89" := return 0x89; +"\x8A" := return 0x8A; +"\x8B" := return 0x8B; +"\x8C" := return 0x8C; +"\x8D" := return 0x8D; +"\x8E" := return 0x8E; +"\x8F" := return 0x8F; + +"\x90" := return 0x90; +"\x91" := return 0x91; +"\x92" := return 0x92; +"\x93" := return 0x93; +"\x94" := return 0x94; +"\x95" := return 0x95; +"\x96" := return 0x96; +"\x97" := return 0x97; +"\x98" := return 0x98; +"\x99" := return 0x99; +"\x9A" := return 0x9A; +"\x9B" := return 0x9B; +"\x9C" := return 0x9C; +"\x9D" := return 0x9D; +"\x9E" := return 0x9E; +"\x9F" := return 0x9F; + +"\xA0" := return 0xA0; +"\xA1" := return 0xA1; +"\xA2" := return 0xA2; +"\xA3" := return 0xA3; +"\xA4" := return 0xA4; +"\xA5" := return 0xA5; +"\xA6" := return 0xA6; +"\xA7" := return 0xA7; +"\xA8" := return 0xA8; +"\xA9" := return 0xA9; +"\xAA" := return 0xAA; +"\xAB" := return 0xAB; +"\xAC" := return 0xAC; +"\xAD" := return 0xAD; +"\xAE" := return 0xAE; +"\xAF" := return 0xAF; + +"\xB0" := return 0xB0; +"\xB1" := return 0xB1; +"\xB2" := return 0xB2; +"\xB3" := return 0xB3; +"\xB4" := return 0xB4; +"\xB5" := return 0xB5; +"\xB6" := return 0xB6; +"\xB7" := return 0xB7; +"\xB8" := return 0xB8; +"\xB9" := return 0xB9; +"\xBA" := return 0xBA; +"\xBB" := return 0xBB; +"\xBC" := return 0xBC; +"\xBD" := return 0xBD; +"\xBE" := return 0xBE; +"\xBF" := return 0xBF; + +"\xC0" := return 0xC0; +"\xC1" := return 0xC1; +"\xC2" := return 0xC2; +"\xC3" := return 0xC3; +"\xC4" := return 0xC4; +"\xC5" := return 0xC5; +"\xC6" := return 0xC6; +"\xC7" := return 0xC7; +"\xC8" := return 0xC8; +"\xC9" := return 0xC9; +"\xCA" := return 0xCA; +"\xCB" := return 0xCB; +"\xCC" := return 0xCC; +"\xCD" := return 0xCD; +"\xCE" := return 0xCE; +"\xCF" := return 0xCF; + +"\xD0" := return 0xD0; +"\xD1" := return 0xD1; +"\xD2" := return 0xD2; +"\xD3" := return 0xD3; +"\xD4" := return 0xD4; +"\xD5" := return 0xD5; +"\xD6" := return 0xD6; +"\xD7" := return 0xD7; +"\xD8" := return 0xD8; +"\xD9" := return 0xD9; +"\xDA" := return 0xDA; +"\xDB" := return 0xDB; +"\xDC" := return 0xDC; +"\xDD" := return 0xDD; +"\xDE" := return 0xDE; +"\xDF" := return 0xDF; + +"\xE0" := return 0xE0; +"\xE1" := return 0xE1; +"\xE2" := return 0xE2; +"\xE3" := return 0xE3; +"\xE4" := return 0xE4; +"\xE5" := return 0xE5; +"\xE6" := return 0xE6; +"\xE7" := return 0xE7; +"\xE8" := return 0xE8; +"\xE9" := return 0xE9; +"\xEA" := return 0xEA; +"\xEB" := return 0xEB; +"\xEC" := return 0xEC; +"\xED" := return 0xED; +"\xEE" := return 0xEE; +"\xEF" := return 0xEF; + +"\xF0" := return 0xF0; +"\xF1" := return 0xF1; +"\xF2" := return 0xF2; +"\xF3" := return 0xF3; +"\xF4" := return 0xF4; +"\xF5" := return 0xF5; +"\xF6" := return 0xF6; +"\xF7" := return 0xF7; +"\xF8" := return 0xF8; +"\xF9" := return 0xF9; +"\xFA" := return 0xFA; +"\xFB" := return 0xFB; +"\xFC" := return 0xFC; +"\xFD" := return 0xFD; +"\xFE" := return 0xFE; +"\xFF" := return 0xFF; + +*/ +} + +int main(int argc, char** argv) { + unsigned char buf[2]; + unsigned int ch = 0; + buf[1] = 0u; + + printf("const uint ebc2asc[256] =\n"); + printf(" { /* Based on ISO 8859/1 and Code Page 37 */\n"); + for (;;) { + if (ch % 16 == 0) { + printf(" "); + } + buf[0] = ch++; + printf("0x%02x", scan(buf)); + if (ch == 256) { + printf("\n"); + break; + } + if (ch % 16 == 0) { + printf(",\n"); + } else { + printf(", "); + } + } + printf(" };\n"); + return 0; +} diff --git a/re2c/test/bug2102138a.ei.txt b/re2c/test/bug2102138a.ei.txt new file mode 100644 index 00000000..e952201b --- /dev/null +++ b/re2c/test/bug2102138a.ei.txt @@ -0,0 +1,19 @@ +const uint ebc2asc[256] = + { /* Based on ISO 8859/1 and Code Page 37 */ + 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f, 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x0a, 0x17, 0x1b, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, + 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, + 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, + 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, + 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, + 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, + 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xde, 0xb1, + 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, + 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xfe, 0xae, + 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7, + 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, + 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, + 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f + }; diff --git a/re2c/test/bug2102138b.ei.c b/re2c/test/bug2102138b.ei.c new file mode 100755 index 00000000..1324fde5 --- /dev/null +++ b/re2c/test/bug2102138b.ei.c @@ -0,0 +1,1067 @@ +/* Generated by re2c */ +#include + +int scan(const unsigned char *cr) +{ + unsigned char ch; + +{ + unsigned char ch; + + ch = *cr; + switch (ch) { + case 0x00: goto yy2; + case 0x01: goto yy4; + case 0x02: goto yy6; + case 0x03: goto yy8; + case 0x04: goto yy314; + case 0x05: goto yy20; + case 0x06: goto yy270; + case 0x07: goto yy256; + case 0x08: goto yy304; + case 0x09: goto yy284; + case 0x0A: goto yy286; + case 0x0B: goto yy24; + case 0x0C: goto yy26; + case 0x0D: goto yy28; + case 0x0E: goto yy30; + case 0x0F: goto yy32; + case 0x10: goto yy34; + case 0x11: goto yy36; + case 0x12: goto yy38; + case 0x13: goto yy40; + case 0x14: goto yy316; + case 0x15: goto yy268; + case 0x16: goto yy18; + case 0x17: goto yy272; + case 0x18: goto yy50; + case 0x19: goto yy52; + case 0x1A: goto yy294; + case 0x1B: goto yy288; + case 0x1C: goto yy58; + case 0x1D: goto yy60; + case 0x1E: goto yy62; + case 0x1F: goto yy64; + case 0x20: goto yy258; + case 0x21: goto yy260; + case 0x22: goto yy262; + case 0x23: goto yy264; + case 0x24: goto yy266; + case 0x25: goto yy22; + case 0x26: goto yy48; + case 0x27: goto yy56; + case 0x28: goto yy274; + case 0x29: goto yy276; + case 0x2A: goto yy278; + case 0x2B: goto yy280; + case 0x2C: goto yy282; + case 0x2D: goto yy12; + case 0x2E: goto yy14; + case 0x2F: goto yy16; + case 0x30: goto yy290; + case 0x31: goto yy292; + case 0x32: goto yy46; + case 0x33: goto yy296; + case 0x34: goto yy298; + case 0x35: goto yy300; + case 0x36: goto yy302; + case 0x37: goto yy10; + case 0x38: goto yy306; + case 0x39: goto yy308; + case 0x3A: goto yy310; + case 0x3B: goto yy312; + case 0x3C: goto yy42; + case 0x3D: goto yy44; + case 0x3E: goto yy318; + case 0x3F: goto yy54; + case 0x40: goto yy66; + case 0x41: goto yy322; + case 0x42: goto yy454; + case 0x43: goto yy458; + case 0x44: goto yy450; + case 0x45: goto yy452; + case 0x46: goto yy456; + case 0x47: goto yy460; + case 0x48: goto yy464; + case 0x49: goto yy484; + case 0x4A: goto yy326; + case 0x4B: goto yy94; + case 0x4C: goto yy122; + case 0x4D: goto yy82; + case 0x4E: goto yy88; + case 0x4F: goto yy250; + case 0x50: goto yy78; + case 0x51: goto yy468; + case 0x52: goto yy470; + case 0x53: goto yy472; + case 0x54: goto yy466; + case 0x55: goto yy476; + case 0x56: goto yy478; + case 0x57: goto yy480; + case 0x58: goto yy474; + case 0x59: goto yy448; + case 0x5A: goto yy68; + case 0x5B: goto yy74; + case 0x5C: goto yy86; + case 0x5D: goto yy84; + case 0x5E: goto yy120; + case 0x5F: goto yy346; + case 0x60: goto yy92; + case 0x61: goto yy96; + case 0x62: goto yy390; + case 0x63: goto yy394; + case 0x64: goto yy386; + case 0x65: goto yy388; + case 0x66: goto yy392; + case 0x67: goto yy396; + case 0x68: goto yy400; + case 0x69: goto yy420; + case 0x6A: goto yy334; + case 0x6B: goto yy90; + case 0x6C: goto yy76; + case 0x6D: goto yy192; + case 0x6E: goto yy126; + case 0x6F: goto yy128; + case 0x70: goto yy498; + case 0x71: goto yy404; + case 0x72: goto yy406; + case 0x73: goto yy408; + case 0x74: goto yy402; + case 0x75: goto yy412; + case 0x76: goto yy414; + case 0x77: goto yy416; + case 0x78: goto yy410; + case 0x79: goto yy194; + case 0x7A: goto yy118; + case 0x7B: goto yy72; + case 0x7C: goto yy130; + case 0x7D: goto yy80; + case 0x7E: goto yy124; + case 0x7F: goto yy70; + case 0x80: goto yy434; + case 0x81: goto yy196; + case 0x82: goto yy198; + case 0x83: goto yy200; + case 0x84: goto yy202; + case 0x85: goto yy204; + case 0x86: goto yy206; + case 0x87: goto yy208; + case 0x88: goto yy210; + case 0x89: goto yy212; + case 0x8A: goto yy344; + case 0x8B: goto yy376; + case 0x8C: goto yy482; + case 0x8D: goto yy508; + case 0x8E: goto yy446; + case 0x8F: goto yy356; + case 0x90: goto yy354; + case 0x91: goto yy214; + case 0x92: goto yy216; + case 0x93: goto yy218; + case 0x94: goto yy220; + case 0x95: goto yy222; + case 0x96: goto yy224; + case 0x97: goto yy226; + case 0x98: goto yy228; + case 0x99: goto yy230; + case 0x9A: goto yy342; + case 0x9B: goto yy374; + case 0x9C: goto yy462; + case 0x9D: goto yy370; + case 0x9E: goto yy398; + case 0x9F: goto yy330; + case 0xA0: goto yy364; + case 0xA1: goto yy254; + case 0xA2: goto yy232; + case 0xA3: goto yy234; + case 0xA4: goto yy236; + case 0xA5: goto yy238; + case 0xA6: goto yy240; + case 0xA7: goto yy242; + case 0xA8: goto yy244; + case 0xA9: goto yy246; + case 0xAA: goto yy324; + case 0xAB: goto yy384; + case 0xAC: goto yy418; + case 0xAD: goto yy444; + case 0xAE: goto yy510; + case 0xAF: goto yy350; + case 0xB0: goto yy190; + case 0xB1: goto yy328; + case 0xB2: goto yy332; + case 0xB3: goto yy368; + case 0xB4: goto yy340; + case 0xB5: goto yy336; + case 0xB6: goto yy366; + case 0xB7: goto yy378; + case 0xB8: goto yy380; + case 0xB9: goto yy382; + case 0xBA: goto yy184; + case 0xBB: goto yy188; + case 0xBC: goto yy352; + case 0xBD: goto yy338; + case 0xBE: goto yy362; + case 0xBF: goto yy432; + case 0xC0: goto yy248; + case 0xC1: goto yy132; + case 0xC2: goto yy134; + case 0xC3: goto yy136; + case 0xC4: goto yy138; + case 0xC5: goto yy140; + case 0xC6: goto yy142; + case 0xC7: goto yy144; + case 0xC8: goto yy146; + case 0xC9: goto yy148; + case 0xCA: goto yy348; + case 0xCB: goto yy490; + case 0xCC: goto yy494; + case 0xCD: goto yy486; + case 0xCE: goto yy488; + case 0xCF: goto yy492; + case 0xD0: goto yy252; + case 0xD1: goto yy150; + case 0xD2: goto yy152; + case 0xD3: goto yy154; + case 0xD4: goto yy156; + case 0xD5: goto yy158; + case 0xD6: goto yy160; + case 0xD7: goto yy162; + case 0xD8: goto yy164; + case 0xD9: goto yy166; + case 0xDA: goto yy372; + case 0xDB: goto yy504; + case 0xDC: goto yy506; + case 0xDD: goto yy500; + case 0xDE: goto yy502; + case 0xDF: goto yy512; + case 0xE0: goto yy186; + case 0xE1: goto yy496; + case 0xE2: goto yy168; + case 0xE3: goto yy170; + case 0xE4: goto yy172; + case 0xE5: goto yy174; + case 0xE6: goto yy176; + case 0xE7: goto yy178; + case 0xE8: goto yy180; + case 0xE9: goto yy182; + case 0xEA: goto yy358; + case 0xEB: goto yy426; + case 0xEC: goto yy430; + case 0xED: goto yy422; + case 0xEE: goto yy424; + case 0xEF: goto yy428; + case 0xF0: goto yy98; + case 0xF1: goto yy100; + case 0xF2: goto yy102; + case 0xF3: goto yy104; + case 0xF4: goto yy106; + case 0xF5: goto yy108; + case 0xF6: goto yy110; + case 0xF7: goto yy112; + case 0xF8: goto yy114; + case 0xF9: goto yy116; + case 0xFA: goto yy360; + case 0xFB: goto yy440; + case 0xFC: goto yy442; + case 0xFD: goto yy436; + case 0xFE: goto yy438; + default: goto yy320; + } +yy2: + ++cr; + return 0x00; +yy4: + ++cr; + return 0x01; +yy6: + ++cr; + return 0x02; +yy8: + ++cr; + return 0x03; +yy10: + ++cr; + return 0x04; +yy12: + ++cr; + return 0x05; +yy14: + ++cr; + return 0x06; +yy16: + ++cr; + return 0x07; +yy18: + ++cr; + return 0x08; +yy20: + ++cr; + return 0x09; +yy22: + ++cr; + return 0x0A; +yy24: + ++cr; + return 0x0B; +yy26: + ++cr; + return 0x0C; +yy28: + ++cr; + return 0x0D; +yy30: + ++cr; + return 0x0E; +yy32: + ++cr; + return 0x0F; +yy34: + ++cr; + return 0x10; +yy36: + ++cr; + return 0x11; +yy38: + ++cr; + return 0x12; +yy40: + ++cr; + return 0x13; +yy42: + ++cr; + return 0x14; +yy44: + ++cr; + return 0x15; +yy46: + ++cr; + return 0x16; +yy48: + ++cr; + return 0x17; +yy50: + ++cr; + return 0x18; +yy52: + ++cr; + return 0x19; +yy54: + ++cr; + return 0x1A; +yy56: + ++cr; + return 0x1B; +yy58: + ++cr; + return 0x1C; +yy60: + ++cr; + return 0x1D; +yy62: + ++cr; + return 0x1E; +yy64: + ++cr; + return 0x1F; +yy66: + ++cr; + return 0x20; +yy68: + ++cr; + return 0x21; +yy70: + ++cr; + return 0x22; +yy72: + ++cr; + return 0x23; +yy74: + ++cr; + return 0x24; +yy76: + ++cr; + return 0x25; +yy78: + ++cr; + return 0x26; +yy80: + ++cr; + return 0x27; +yy82: + ++cr; + return 0x28; +yy84: + ++cr; + return 0x29; +yy86: + ++cr; + return 0x2A; +yy88: + ++cr; + return 0x2B; +yy90: + ++cr; + return 0x2C; +yy92: + ++cr; + return 0x2D; +yy94: + ++cr; + return 0x2E; +yy96: + ++cr; + return 0x2F; +yy98: + ++cr; + return 0x30; +yy100: + ++cr; + return 0x31; +yy102: + ++cr; + return 0x32; +yy104: + ++cr; + return 0x33; +yy106: + ++cr; + return 0x34; +yy108: + ++cr; + return 0x35; +yy110: + ++cr; + return 0x36; +yy112: + ++cr; + return 0x37; +yy114: + ++cr; + return 0x38; +yy116: + ++cr; + return 0x39; +yy118: + ++cr; + return 0x3A; +yy120: + ++cr; + return 0x3B; +yy122: + ++cr; + return 0x3C; +yy124: + ++cr; + return 0x3D; +yy126: + ++cr; + return 0x3E; +yy128: + ++cr; + return 0x3F; +yy130: + ++cr; + return 0x40; +yy132: + ++cr; + return 0x41; +yy134: + ++cr; + return 0x42; +yy136: + ++cr; + return 0x43; +yy138: + ++cr; + return 0x44; +yy140: + ++cr; + return 0x45; +yy142: + ++cr; + return 0x46; +yy144: + ++cr; + return 0x47; +yy146: + ++cr; + return 0x48; +yy148: + ++cr; + return 0x49; +yy150: + ++cr; + return 0x4A; +yy152: + ++cr; + return 0x4B; +yy154: + ++cr; + return 0x4C; +yy156: + ++cr; + return 0x4D; +yy158: + ++cr; + return 0x4E; +yy160: + ++cr; + return 0x4F; +yy162: + ++cr; + return 0x50; +yy164: + ++cr; + return 0x51; +yy166: + ++cr; + return 0x52; +yy168: + ++cr; + return 0x53; +yy170: + ++cr; + return 0x54; +yy172: + ++cr; + return 0x55; +yy174: + ++cr; + return 0x56; +yy176: + ++cr; + return 0x57; +yy178: + ++cr; + return 0x58; +yy180: + ++cr; + return 0x59; +yy182: + ++cr; + return 0x5A; +yy184: + ++cr; + return 0x5B; +yy186: + ++cr; + return 0x5C; +yy188: + ++cr; + return 0x5D; +yy190: + ++cr; + return 0x5E; +yy192: + ++cr; + return 0x5F; +yy194: + ++cr; + return 0x60; +yy196: + ++cr; + return 0x61; +yy198: + ++cr; + return 0x62; +yy200: + ++cr; + return 0x63; +yy202: + ++cr; + return 0x64; +yy204: + ++cr; + return 0x65; +yy206: + ++cr; + return 0x66; +yy208: + ++cr; + return 0x67; +yy210: + ++cr; + return 0x68; +yy212: + ++cr; + return 0x69; +yy214: + ++cr; + return 0x6A; +yy216: + ++cr; + return 0x6B; +yy218: + ++cr; + return 0x6C; +yy220: + ++cr; + return 0x6D; +yy222: + ++cr; + return 0x6E; +yy224: + ++cr; + return 0x6F; +yy226: + ++cr; + return 0x70; +yy228: + ++cr; + return 0x71; +yy230: + ++cr; + return 0x72; +yy232: + ++cr; + return 0x73; +yy234: + ++cr; + return 0x74; +yy236: + ++cr; + return 0x75; +yy238: + ++cr; + return 0x76; +yy240: + ++cr; + return 0x77; +yy242: + ++cr; + return 0x78; +yy244: + ++cr; + return 0x79; +yy246: + ++cr; + return 0x7A; +yy248: + ++cr; + return 0x7B; +yy250: + ++cr; + return 0x7C; +yy252: + ++cr; + return 0x7D; +yy254: + ++cr; + return 0x7E; +yy256: + ++cr; + return 0x7F; +yy258: + ++cr; + return 0x80; +yy260: + ++cr; + return 0x81; +yy262: + ++cr; + return 0x82; +yy264: + ++cr; + return 0x83; +yy266: + ++cr; + return 0x84; +yy268: + ++cr; + return 0x85; +yy270: + ++cr; + return 0x86; +yy272: + ++cr; + return 0x87; +yy274: + ++cr; + return 0x88; +yy276: + ++cr; + return 0x89; +yy278: + ++cr; + return 0x8A; +yy280: + ++cr; + return 0x8B; +yy282: + ++cr; + return 0x8C; +yy284: + ++cr; + return 0x8D; +yy286: + ++cr; + return 0x8E; +yy288: + ++cr; + return 0x8F; +yy290: + ++cr; + return 0x90; +yy292: + ++cr; + return 0x91; +yy294: + ++cr; + return 0x92; +yy296: + ++cr; + return 0x93; +yy298: + ++cr; + return 0x94; +yy300: + ++cr; + return 0x95; +yy302: + ++cr; + return 0x96; +yy304: + ++cr; + return 0x97; +yy306: + ++cr; + return 0x98; +yy308: + ++cr; + return 0x99; +yy310: + ++cr; + return 0x9A; +yy312: + ++cr; + return 0x9B; +yy314: + ++cr; + return 0x9C; +yy316: + ++cr; + return 0x9D; +yy318: + ++cr; + return 0x9E; +yy320: + ++cr; + return 0x9F; +yy322: + ++cr; + return 0xA0; +yy324: + ++cr; + return 0xA1; +yy326: + ++cr; + return 0xA2; +yy328: + ++cr; + return 0xA3; +yy330: + ++cr; + return 0xA4; +yy332: + ++cr; + return 0xA5; +yy334: + ++cr; + return 0xA6; +yy336: + ++cr; + return 0xA7; +yy338: + ++cr; + return 0xA8; +yy340: + ++cr; + return 0xA9; +yy342: + ++cr; + return 0xAA; +yy344: + ++cr; + return 0xAB; +yy346: + ++cr; + return 0xAC; +yy348: + ++cr; + return 0xAD; +yy350: + ++cr; + return 0xAE; +yy352: + ++cr; + return 0xAF; +yy354: + ++cr; + return 0xB0; +yy356: + ++cr; + return 0xB1; +yy358: + ++cr; + return 0xB2; +yy360: + ++cr; + return 0xB3; +yy362: + ++cr; + return 0xB4; +yy364: + ++cr; + return 0xB5; +yy366: + ++cr; + return 0xB6; +yy368: + ++cr; + return 0xB7; +yy370: + ++cr; + return 0xB8; +yy372: + ++cr; + return 0xB9; +yy374: + ++cr; + return 0xBA; +yy376: + ++cr; + return 0xBB; +yy378: + ++cr; + return 0xBC; +yy380: + ++cr; + return 0xBD; +yy382: + ++cr; + return 0xBE; +yy384: + ++cr; + return 0xBF; +yy386: + ++cr; + return 0xC0; +yy388: + ++cr; + return 0xC1; +yy390: + ++cr; + return 0xC2; +yy392: + ++cr; + return 0xC3; +yy394: + ++cr; + return 0xC4; +yy396: + ++cr; + return 0xC5; +yy398: + ++cr; + return 0xC6; +yy400: + ++cr; + return 0xC7; +yy402: + ++cr; + return 0xC8; +yy404: + ++cr; + return 0xC9; +yy406: + ++cr; + return 0xCA; +yy408: + ++cr; + return 0xCB; +yy410: + ++cr; + return 0xCC; +yy412: + ++cr; + return 0xCD; +yy414: + ++cr; + return 0xCE; +yy416: + ++cr; + return 0xCF; +yy418: + ++cr; + return 0xD0; +yy420: + ++cr; + return 0xD1; +yy422: + ++cr; + return 0xD2; +yy424: + ++cr; + return 0xD3; +yy426: + ++cr; + return 0xD4; +yy428: + ++cr; + return 0xD5; +yy430: + ++cr; + return 0xD6; +yy432: + ++cr; + return 0xD7; +yy434: + ++cr; + return 0xD8; +yy436: + ++cr; + return 0xD9; +yy438: + ++cr; + return 0xDA; +yy440: + ++cr; + return 0xDB; +yy442: + ++cr; + return 0xDC; +yy444: + ++cr; + return 0xDD; +yy446: + ++cr; + return 0xDE; +yy448: + ++cr; + return 0xDF; +yy450: + ++cr; + return 0xE0; +yy452: + ++cr; + return 0xE1; +yy454: + ++cr; + return 0xE2; +yy456: + ++cr; + return 0xE3; +yy458: + ++cr; + return 0xE4; +yy460: + ++cr; + return 0xE5; +yy462: + ++cr; + return 0xE6; +yy464: + ++cr; + return 0xE7; +yy466: + ++cr; + return 0xE8; +yy468: + ++cr; + return 0xE9; +yy470: + ++cr; + return 0xEA; +yy472: + ++cr; + return 0xEB; +yy474: + ++cr; + return 0xEC; +yy476: + ++cr; + return 0xED; +yy478: + ++cr; + return 0xEE; +yy480: + ++cr; + return 0xEF; +yy482: + ++cr; + return 0xF0; +yy484: + ++cr; + return 0xF1; +yy486: + ++cr; + return 0xF2; +yy488: + ++cr; + return 0xF3; +yy490: + ++cr; + return 0xF4; +yy492: + ++cr; + return 0xF5; +yy494: + ++cr; + return 0xF6; +yy496: + ++cr; + return 0xF7; +yy498: + ++cr; + return 0xF8; +yy500: + ++cr; + return 0xF9; +yy502: + ++cr; + return 0xFA; +yy504: + ++cr; + return 0xFB; +yy506: + ++cr; + return 0xFC; +yy508: + ++cr; + return 0xFD; +yy510: + ++cr; + return 0xFE; +yy512: + ++cr; + return 0xFF; +} + +} + +int main(int argc, char** argv) { + unsigned char buf[2]; + unsigned int ch = 0; + buf[1] = 0u; + + printf("const uint ebc2asc[256] =\n"); + printf(" { /* Based on ISO 8859/1 and Code Page 37 */\n"); + for (;;) { + if (ch % 16 == 0) { + printf(" "); + } + buf[0] = ch++; + printf("0x%02x", scan(buf)); + if (ch == 256) { + printf("\n"); + break; + } + if (ch % 16 == 0) { + printf(",\n"); + } else { + printf(", "); + } + } + printf(" };\n"); + return 0; +} diff --git a/re2c/test/bug2102138b.ei.re b/re2c/test/bug2102138b.ei.re new file mode 100755 index 00000000..566a690e --- /dev/null +++ b/re2c/test/bug2102138b.ei.re @@ -0,0 +1,314 @@ +#include + +int scan(const unsigned char *cr) +{ + unsigned char ch; +/*!re2c + +re2c:define:YYCTYPE = "unsigned char"; +re2c:define:YYCURSOR = cr; +re2c:define:YYFILL = fill; +re2c:variable:yych = ch; +re2c:yyfill:enable = 0; + +"\x00" := return 0x00; +"\x01" := return 0x01; +"\x02" := return 0x02; +"\x03" := return 0x03; +"\x04" := return 0x04; +"\x05" := return 0x05; +"\x06" := return 0x06; +"\x07" := return 0x07; +"\x08" := return 0x08; +"\x09" := return 0x09; +"\x0A" := return 0x0A; +"\x0B" := return 0x0B; +"\x0C" := return 0x0C; +"\x0D" := return 0x0D; +"\x0E" := return 0x0E; +"\x0F" := return 0x0F; + +"\x10" := return 0x10; +"\x11" := return 0x11; +"\x12" := return 0x12; +"\x13" := return 0x13; +"\x14" := return 0x14; +"\x15" := return 0x15; +"\x16" := return 0x16; +"\x17" := return 0x17; +"\x18" := return 0x18; +"\x19" := return 0x19; +"\x1A" := return 0x1A; +"\x1B" := return 0x1B; +"\x1C" := return 0x1C; +"\x1D" := return 0x1D; +"\x1E" := return 0x1E; +"\x1F" := return 0x1F; + +"\x20" := return 0x20; +"\x21" := return 0x21; +"\x22" := return 0x22; +"\x23" := return 0x23; +"\x24" := return 0x24; +"\x25" := return 0x25; +"\x26" := return 0x26; +"\x27" := return 0x27; +"\x28" := return 0x28; +"\x29" := return 0x29; +"\x2A" := return 0x2A; +"\x2B" := return 0x2B; +"\x2C" := return 0x2C; +"\x2D" := return 0x2D; +"\x2E" := return 0x2E; +"\x2F" := return 0x2F; + +"\x30" := return 0x30; +"\x31" := return 0x31; +"\x32" := return 0x32; +"\x33" := return 0x33; +"\x34" := return 0x34; +"\x35" := return 0x35; +"\x36" := return 0x36; +"\x37" := return 0x37; +"\x38" := return 0x38; +"\x39" := return 0x39; +"\x3A" := return 0x3A; +"\x3B" := return 0x3B; +"\x3C" := return 0x3C; +"\x3D" := return 0x3D; +"\x3E" := return 0x3E; +"\x3F" := return 0x3F; + +"\x40" := return 0x40; +"\x41" := return 0x41; +"\x42" := return 0x42; +"\x43" := return 0x43; +"\x44" := return 0x44; +"\x45" := return 0x45; +"\x46" := return 0x46; +"\x47" := return 0x47; +"\x48" := return 0x48; +"\x49" := return 0x49; +"\x4A" := return 0x4A; +"\x4B" := return 0x4B; +"\x4C" := return 0x4C; +"\x4D" := return 0x4D; +"\x4E" := return 0x4E; +"\x4F" := return 0x4F; + +"\x50" := return 0x50; +"\x51" := return 0x51; +"\x52" := return 0x52; +"\x53" := return 0x53; +"\x54" := return 0x54; +"\x55" := return 0x55; +"\x56" := return 0x56; +"\x57" := return 0x57; +"\x58" := return 0x58; +"\x59" := return 0x59; +"\x5A" := return 0x5A; +"\x5B" := return 0x5B; +"\x5C" := return 0x5C; +"\x5D" := return 0x5D; +"\x5E" := return 0x5E; +"\x5F" := return 0x5F; + +"\x60" := return 0x60; +"\x61" := return 0x61; +"\x62" := return 0x62; +"\x63" := return 0x63; +"\x64" := return 0x64; +"\x65" := return 0x65; +"\x66" := return 0x66; +"\x67" := return 0x67; +"\x68" := return 0x68; +"\x69" := return 0x69; +"\x6A" := return 0x6A; +"\x6B" := return 0x6B; +"\x6C" := return 0x6C; +"\x6D" := return 0x6D; +"\x6E" := return 0x6E; +"\x6F" := return 0x6F; + +"\x70" := return 0x70; +"\x71" := return 0x71; +"\x72" := return 0x72; +"\x73" := return 0x73; +"\x74" := return 0x74; +"\x75" := return 0x75; +"\x76" := return 0x76; +"\x77" := return 0x77; +"\x78" := return 0x78; +"\x79" := return 0x79; +"\x7A" := return 0x7A; +"\x7B" := return 0x7B; +"\x7C" := return 0x7C; +"\x7D" := return 0x7D; +"\x7E" := return 0x7E; +"\x7F" := return 0x7F; + +"\x80" := return 0x80; +"\x81" := return 0x81; +"\x82" := return 0x82; +"\x83" := return 0x83; +"\x84" := return 0x84; +"\x85" := return 0x85; +"\x86" := return 0x86; +"\x87" := return 0x87; +"\x88" := return 0x88; +"\x89" := return 0x89; +"\x8A" := return 0x8A; +"\x8B" := return 0x8B; +"\x8C" := return 0x8C; +"\x8D" := return 0x8D; +"\x8E" := return 0x8E; +"\x8F" := return 0x8F; + +"\x90" := return 0x90; +"\x91" := return 0x91; +"\x92" := return 0x92; +"\x93" := return 0x93; +"\x94" := return 0x94; +"\x95" := return 0x95; +"\x96" := return 0x96; +"\x97" := return 0x97; +"\x98" := return 0x98; +"\x99" := return 0x99; +"\x9A" := return 0x9A; +"\x9B" := return 0x9B; +"\x9C" := return 0x9C; +"\x9D" := return 0x9D; +"\x9E" := return 0x9E; +"\x9F" := return 0x9F; + +"\xA0" := return 0xA0; +"\xA1" := return 0xA1; +"\xA2" := return 0xA2; +"\xA3" := return 0xA3; +"\xA4" := return 0xA4; +"\xA5" := return 0xA5; +"\xA6" := return 0xA6; +"\xA7" := return 0xA7; +"\xA8" := return 0xA8; +"\xA9" := return 0xA9; +"\xAA" := return 0xAA; +"\xAB" := return 0xAB; +"\xAC" := return 0xAC; +"\xAD" := return 0xAD; +"\xAE" := return 0xAE; +"\xAF" := return 0xAF; + +"\xB0" := return 0xB0; +"\xB1" := return 0xB1; +"\xB2" := return 0xB2; +"\xB3" := return 0xB3; +"\xB4" := return 0xB4; +"\xB5" := return 0xB5; +"\xB6" := return 0xB6; +"\xB7" := return 0xB7; +"\xB8" := return 0xB8; +"\xB9" := return 0xB9; +"\xBA" := return 0xBA; +"\xBB" := return 0xBB; +"\xBC" := return 0xBC; +"\xBD" := return 0xBD; +"\xBE" := return 0xBE; +"\xBF" := return 0xBF; + +"\xC0" := return 0xC0; +"\xC1" := return 0xC1; +"\xC2" := return 0xC2; +"\xC3" := return 0xC3; +"\xC4" := return 0xC4; +"\xC5" := return 0xC5; +"\xC6" := return 0xC6; +"\xC7" := return 0xC7; +"\xC8" := return 0xC8; +"\xC9" := return 0xC9; +"\xCA" := return 0xCA; +"\xCB" := return 0xCB; +"\xCC" := return 0xCC; +"\xCD" := return 0xCD; +"\xCE" := return 0xCE; +"\xCF" := return 0xCF; + +"\xD0" := return 0xD0; +"\xD1" := return 0xD1; +"\xD2" := return 0xD2; +"\xD3" := return 0xD3; +"\xD4" := return 0xD4; +"\xD5" := return 0xD5; +"\xD6" := return 0xD6; +"\xD7" := return 0xD7; +"\xD8" := return 0xD8; +"\xD9" := return 0xD9; +"\xDA" := return 0xDA; +"\xDB" := return 0xDB; +"\xDC" := return 0xDC; +"\xDD" := return 0xDD; +"\xDE" := return 0xDE; +"\xDF" := return 0xDF; + +"\xE0" := return 0xE0; +"\xE1" := return 0xE1; +"\xE2" := return 0xE2; +"\xE3" := return 0xE3; +"\xE4" := return 0xE4; +"\xE5" := return 0xE5; +"\xE6" := return 0xE6; +"\xE7" := return 0xE7; +"\xE8" := return 0xE8; +"\xE9" := return 0xE9; +"\xEA" := return 0xEA; +"\xEB" := return 0xEB; +"\xEC" := return 0xEC; +"\xED" := return 0xED; +"\xEE" := return 0xEE; +"\xEF" := return 0xEF; + +"\xF0" := return 0xF0; +"\xF1" := return 0xF1; +"\xF2" := return 0xF2; +"\xF3" := return 0xF3; +"\xF4" := return 0xF4; +"\xF5" := return 0xF5; +"\xF6" := return 0xF6; +"\xF7" := return 0xF7; +"\xF8" := return 0xF8; +"\xF9" := return 0xF9; +"\xFA" := return 0xFA; +"\xFB" := return 0xFB; +"\xFC" := return 0xFC; +"\xFD" := return 0xFD; +"\xFE" := return 0xFE; +"\xFF" := return 0xFF; + +*/ +} + +int main(int argc, char** argv) { + unsigned char buf[2]; + unsigned int ch = 0; + buf[1] = 0u; + + printf("const uint ebc2asc[256] =\n"); + printf(" { /* Based on ISO 8859/1 and Code Page 37 */\n"); + for (;;) { + if (ch % 16 == 0) { + printf(" "); + } + buf[0] = ch++; + printf("0x%02x", scan(buf)); + if (ch == 256) { + printf("\n"); + break; + } + if (ch % 16 == 0) { + printf(",\n"); + } else { + printf(", "); + } + } + printf(" };\n"); + return 0; +} diff --git a/re2c/test/bug2102138b.ei.txt b/re2c/test/bug2102138b.ei.txt new file mode 100644 index 00000000..e952201b --- /dev/null +++ b/re2c/test/bug2102138b.ei.txt @@ -0,0 +1,19 @@ +const uint ebc2asc[256] = + { /* Based on ISO 8859/1 and Code Page 37 */ + 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f, 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x0a, 0x17, 0x1b, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, + 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, + 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, + 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, + 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, + 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, + 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xde, 0xb1, + 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, + 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xfe, 0xae, + 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7, + 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, + 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, + 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f + }; diff --git a/re2c/test/bug2102138c.i.c b/re2c/test/bug2102138c.i.c new file mode 100755 index 00000000..a639f492 --- /dev/null +++ b/re2c/test/bug2102138c.i.c @@ -0,0 +1,1067 @@ +/* Generated by re2c */ +#include + +int scan(const unsigned char *cr) +{ + unsigned char ch; + +{ + unsigned char ch; + + ch = *cr; + switch (ch) { + case 0x00: goto yy2; + case 0x01: goto yy4; + case 0x02: goto yy6; + case 0x03: goto yy8; + case 0x04: goto yy10; + case 0x05: goto yy12; + case 0x06: goto yy14; + case 0x07: goto yy16; + case 0x08: goto yy18; + case '\t': goto yy20; + case '\n': goto yy22; + case '\v': goto yy24; + case '\f': goto yy26; + case '\r': goto yy28; + case 0x0E: goto yy30; + case 0x0F: goto yy32; + case 0x10: goto yy34; + case 0x11: goto yy36; + case 0x12: goto yy38; + case 0x13: goto yy40; + case 0x14: goto yy42; + case 0x15: goto yy44; + case 0x16: goto yy46; + case 0x17: goto yy48; + case 0x18: goto yy50; + case 0x19: goto yy52; + case 0x1A: goto yy54; + case 0x1B: goto yy56; + case 0x1C: goto yy58; + case 0x1D: goto yy60; + case 0x1E: goto yy62; + case 0x1F: goto yy64; + case ' ': goto yy66; + case '!': goto yy68; + case '"': goto yy70; + case '#': goto yy72; + case '$': goto yy74; + case '%': goto yy76; + case '&': goto yy78; + case '\'': goto yy80; + case '(': goto yy82; + case ')': goto yy84; + case '*': goto yy86; + case '+': goto yy88; + case ',': goto yy90; + case '-': goto yy92; + case '.': goto yy94; + case '/': goto yy96; + case '0': goto yy98; + case '1': goto yy100; + case '2': goto yy102; + case '3': goto yy104; + case '4': goto yy106; + case '5': goto yy108; + case '6': goto yy110; + case '7': goto yy112; + case '8': goto yy114; + case '9': goto yy116; + case ':': goto yy118; + case ';': goto yy120; + case '<': goto yy122; + case '=': goto yy124; + case '>': goto yy126; + case '?': goto yy128; + case '@': goto yy130; + case 'A': goto yy132; + case 'B': goto yy134; + case 'C': goto yy136; + case 'D': goto yy138; + case 'E': goto yy140; + case 'F': goto yy142; + case 'G': goto yy144; + case 'H': goto yy146; + case 'I': goto yy148; + case 'J': goto yy150; + case 'K': goto yy152; + case 'L': goto yy154; + case 'M': goto yy156; + case 'N': goto yy158; + case 'O': goto yy160; + case 'P': goto yy162; + case 'Q': goto yy164; + case 'R': goto yy166; + case 'S': goto yy168; + case 'T': goto yy170; + case 'U': goto yy172; + case 'V': goto yy174; + case 'W': goto yy176; + case 'X': goto yy178; + case 'Y': goto yy180; + case 'Z': goto yy182; + case '[': goto yy184; + case '\\': goto yy186; + case ']': goto yy188; + case '^': goto yy190; + case '_': goto yy192; + case '`': goto yy194; + case 'a': goto yy196; + case 'b': goto yy198; + case 'c': goto yy200; + case 'd': goto yy202; + case 'e': goto yy204; + case 'f': goto yy206; + case 'g': goto yy208; + case 'h': goto yy210; + case 'i': goto yy212; + case 'j': goto yy214; + case 'k': goto yy216; + case 'l': goto yy218; + case 'm': goto yy220; + case 'n': goto yy222; + case 'o': goto yy224; + case 'p': goto yy226; + case 'q': goto yy228; + case 'r': goto yy230; + case 's': goto yy232; + case 't': goto yy234; + case 'u': goto yy236; + case 'v': goto yy238; + case 'w': goto yy240; + case 'x': goto yy242; + case 'y': goto yy244; + case 'z': goto yy246; + case '{': goto yy248; + case '|': goto yy250; + case '}': goto yy252; + case '~': goto yy254; + case 0x7F: goto yy256; + case 0x80: goto yy258; + case 0x81: goto yy260; + case 0x82: goto yy262; + case 0x83: goto yy264; + case 0x84: goto yy266; + case 0x85: goto yy268; + case 0x86: goto yy270; + case 0x87: goto yy272; + case 0x88: goto yy274; + case 0x89: goto yy276; + case 0x8A: goto yy278; + case 0x8B: goto yy280; + case 0x8C: goto yy282; + case 0x8D: goto yy284; + case 0x8E: goto yy286; + case 0x8F: goto yy288; + case 0x90: goto yy290; + case 0x91: goto yy292; + case 0x92: goto yy294; + case 0x93: goto yy296; + case 0x94: goto yy298; + case 0x95: goto yy300; + case 0x96: goto yy302; + case 0x97: goto yy304; + case 0x98: goto yy306; + case 0x99: goto yy308; + case 0x9A: goto yy310; + case 0x9B: goto yy312; + case 0x9C: goto yy314; + case 0x9D: goto yy316; + case 0x9E: goto yy318; + case 0x9F: goto yy320; + case 0xA0: goto yy322; + case 0xA1: goto yy324; + case 0xA2: goto yy326; + case 0xA3: goto yy328; + case 0xA4: goto yy330; + case 0xA5: goto yy332; + case 0xA6: goto yy334; + case 0xA7: goto yy336; + case 0xA8: goto yy338; + case 0xA9: goto yy340; + case 0xAA: goto yy342; + case 0xAB: goto yy344; + case 0xAC: goto yy346; + case 0xAD: goto yy348; + case 0xAE: goto yy350; + case 0xAF: goto yy352; + case 0xB0: goto yy354; + case 0xB1: goto yy356; + case 0xB2: goto yy358; + case 0xB3: goto yy360; + case 0xB4: goto yy362; + case 0xB5: goto yy364; + case 0xB6: goto yy366; + case 0xB7: goto yy368; + case 0xB8: goto yy370; + case 0xB9: goto yy372; + case 0xBA: goto yy374; + case 0xBB: goto yy376; + case 0xBC: goto yy378; + case 0xBD: goto yy380; + case 0xBE: goto yy382; + case 0xBF: goto yy384; + case 0xC0: goto yy386; + case 0xC1: goto yy388; + case 0xC2: goto yy390; + case 0xC3: goto yy392; + case 0xC4: goto yy394; + case 0xC5: goto yy396; + case 0xC6: goto yy398; + case 0xC7: goto yy400; + case 0xC8: goto yy402; + case 0xC9: goto yy404; + case 0xCA: goto yy406; + case 0xCB: goto yy408; + case 0xCC: goto yy410; + case 0xCD: goto yy412; + case 0xCE: goto yy414; + case 0xCF: goto yy416; + case 0xD0: goto yy418; + case 0xD1: goto yy420; + case 0xD2: goto yy422; + case 0xD3: goto yy424; + case 0xD4: goto yy426; + case 0xD5: goto yy428; + case 0xD6: goto yy430; + case 0xD7: goto yy432; + case 0xD8: goto yy434; + case 0xD9: goto yy436; + case 0xDA: goto yy438; + case 0xDB: goto yy440; + case 0xDC: goto yy442; + case 0xDD: goto yy444; + case 0xDE: goto yy446; + case 0xDF: goto yy448; + case 0xE0: goto yy450; + case 0xE1: goto yy452; + case 0xE2: goto yy454; + case 0xE3: goto yy456; + case 0xE4: goto yy458; + case 0xE5: goto yy460; + case 0xE6: goto yy462; + case 0xE7: goto yy464; + case 0xE8: goto yy466; + case 0xE9: goto yy468; + case 0xEA: goto yy470; + case 0xEB: goto yy472; + case 0xEC: goto yy474; + case 0xED: goto yy476; + case 0xEE: goto yy478; + case 0xEF: goto yy480; + case 0xF0: goto yy482; + case 0xF1: goto yy484; + case 0xF2: goto yy486; + case 0xF3: goto yy488; + case 0xF4: goto yy490; + case 0xF5: goto yy492; + case 0xF6: goto yy494; + case 0xF7: goto yy496; + case 0xF8: goto yy498; + case 0xF9: goto yy500; + case 0xFA: goto yy502; + case 0xFB: goto yy504; + case 0xFC: goto yy506; + case 0xFD: goto yy508; + case 0xFE: goto yy510; + default: goto yy512; + } +yy2: + ++cr; + return 0x00; +yy4: + ++cr; + return 0x01; +yy6: + ++cr; + return 0x02; +yy8: + ++cr; + return 0x03; +yy10: + ++cr; + return 0x04; +yy12: + ++cr; + return 0x05; +yy14: + ++cr; + return 0x06; +yy16: + ++cr; + return 0x07; +yy18: + ++cr; + return 0x08; +yy20: + ++cr; + return 0x09; +yy22: + ++cr; + return 0x0A; +yy24: + ++cr; + return 0x0B; +yy26: + ++cr; + return 0x0C; +yy28: + ++cr; + return 0x0D; +yy30: + ++cr; + return 0x0E; +yy32: + ++cr; + return 0x0F; +yy34: + ++cr; + return 0x10; +yy36: + ++cr; + return 0x11; +yy38: + ++cr; + return 0x12; +yy40: + ++cr; + return 0x13; +yy42: + ++cr; + return 0x14; +yy44: + ++cr; + return 0x15; +yy46: + ++cr; + return 0x16; +yy48: + ++cr; + return 0x17; +yy50: + ++cr; + return 0x18; +yy52: + ++cr; + return 0x19; +yy54: + ++cr; + return 0x1A; +yy56: + ++cr; + return 0x1B; +yy58: + ++cr; + return 0x1C; +yy60: + ++cr; + return 0x1D; +yy62: + ++cr; + return 0x1E; +yy64: + ++cr; + return 0x1F; +yy66: + ++cr; + return 0x20; +yy68: + ++cr; + return 0x21; +yy70: + ++cr; + return 0x22; +yy72: + ++cr; + return 0x23; +yy74: + ++cr; + return 0x24; +yy76: + ++cr; + return 0x25; +yy78: + ++cr; + return 0x26; +yy80: + ++cr; + return 0x27; +yy82: + ++cr; + return 0x28; +yy84: + ++cr; + return 0x29; +yy86: + ++cr; + return 0x2A; +yy88: + ++cr; + return 0x2B; +yy90: + ++cr; + return 0x2C; +yy92: + ++cr; + return 0x2D; +yy94: + ++cr; + return 0x2E; +yy96: + ++cr; + return 0x2F; +yy98: + ++cr; + return 0x30; +yy100: + ++cr; + return 0x31; +yy102: + ++cr; + return 0x32; +yy104: + ++cr; + return 0x33; +yy106: + ++cr; + return 0x34; +yy108: + ++cr; + return 0x35; +yy110: + ++cr; + return 0x36; +yy112: + ++cr; + return 0x37; +yy114: + ++cr; + return 0x38; +yy116: + ++cr; + return 0x39; +yy118: + ++cr; + return 0x3A; +yy120: + ++cr; + return 0x3B; +yy122: + ++cr; + return 0x3C; +yy124: + ++cr; + return 0x3D; +yy126: + ++cr; + return 0x3E; +yy128: + ++cr; + return 0x3F; +yy130: + ++cr; + return 0x40; +yy132: + ++cr; + return 0x41; +yy134: + ++cr; + return 0x42; +yy136: + ++cr; + return 0x43; +yy138: + ++cr; + return 0x44; +yy140: + ++cr; + return 0x45; +yy142: + ++cr; + return 0x46; +yy144: + ++cr; + return 0x47; +yy146: + ++cr; + return 0x48; +yy148: + ++cr; + return 0x49; +yy150: + ++cr; + return 0x4A; +yy152: + ++cr; + return 0x4B; +yy154: + ++cr; + return 0x4C; +yy156: + ++cr; + return 0x4D; +yy158: + ++cr; + return 0x4E; +yy160: + ++cr; + return 0x4F; +yy162: + ++cr; + return 0x50; +yy164: + ++cr; + return 0x51; +yy166: + ++cr; + return 0x52; +yy168: + ++cr; + return 0x53; +yy170: + ++cr; + return 0x54; +yy172: + ++cr; + return 0x55; +yy174: + ++cr; + return 0x56; +yy176: + ++cr; + return 0x57; +yy178: + ++cr; + return 0x58; +yy180: + ++cr; + return 0x59; +yy182: + ++cr; + return 0x5A; +yy184: + ++cr; + return 0x5B; +yy186: + ++cr; + return 0x5C; +yy188: + ++cr; + return 0x5D; +yy190: + ++cr; + return 0x5E; +yy192: + ++cr; + return 0x5F; +yy194: + ++cr; + return 0x60; +yy196: + ++cr; + return 0x61; +yy198: + ++cr; + return 0x62; +yy200: + ++cr; + return 0x63; +yy202: + ++cr; + return 0x64; +yy204: + ++cr; + return 0x65; +yy206: + ++cr; + return 0x66; +yy208: + ++cr; + return 0x67; +yy210: + ++cr; + return 0x68; +yy212: + ++cr; + return 0x69; +yy214: + ++cr; + return 0x6A; +yy216: + ++cr; + return 0x6B; +yy218: + ++cr; + return 0x6C; +yy220: + ++cr; + return 0x6D; +yy222: + ++cr; + return 0x6E; +yy224: + ++cr; + return 0x6F; +yy226: + ++cr; + return 0x70; +yy228: + ++cr; + return 0x71; +yy230: + ++cr; + return 0x72; +yy232: + ++cr; + return 0x73; +yy234: + ++cr; + return 0x74; +yy236: + ++cr; + return 0x75; +yy238: + ++cr; + return 0x76; +yy240: + ++cr; + return 0x77; +yy242: + ++cr; + return 0x78; +yy244: + ++cr; + return 0x79; +yy246: + ++cr; + return 0x7A; +yy248: + ++cr; + return 0x7B; +yy250: + ++cr; + return 0x7C; +yy252: + ++cr; + return 0x7D; +yy254: + ++cr; + return 0x7E; +yy256: + ++cr; + return 0x7F; +yy258: + ++cr; + return 0x80; +yy260: + ++cr; + return 0x81; +yy262: + ++cr; + return 0x82; +yy264: + ++cr; + return 0x83; +yy266: + ++cr; + return 0x84; +yy268: + ++cr; + return 0x85; +yy270: + ++cr; + return 0x86; +yy272: + ++cr; + return 0x87; +yy274: + ++cr; + return 0x88; +yy276: + ++cr; + return 0x89; +yy278: + ++cr; + return 0x8A; +yy280: + ++cr; + return 0x8B; +yy282: + ++cr; + return 0x8C; +yy284: + ++cr; + return 0x8D; +yy286: + ++cr; + return 0x8E; +yy288: + ++cr; + return 0x8F; +yy290: + ++cr; + return 0x90; +yy292: + ++cr; + return 0x91; +yy294: + ++cr; + return 0x92; +yy296: + ++cr; + return 0x93; +yy298: + ++cr; + return 0x94; +yy300: + ++cr; + return 0x95; +yy302: + ++cr; + return 0x96; +yy304: + ++cr; + return 0x97; +yy306: + ++cr; + return 0x98; +yy308: + ++cr; + return 0x99; +yy310: + ++cr; + return 0x9A; +yy312: + ++cr; + return 0x9B; +yy314: + ++cr; + return 0x9C; +yy316: + ++cr; + return 0x9D; +yy318: + ++cr; + return 0x9E; +yy320: + ++cr; + return 0x9F; +yy322: + ++cr; + return 0xA0; +yy324: + ++cr; + return 0xA1; +yy326: + ++cr; + return 0xA2; +yy328: + ++cr; + return 0xA3; +yy330: + ++cr; + return 0xA4; +yy332: + ++cr; + return 0xA5; +yy334: + ++cr; + return 0xA6; +yy336: + ++cr; + return 0xA7; +yy338: + ++cr; + return 0xA8; +yy340: + ++cr; + return 0xA9; +yy342: + ++cr; + return 0xAA; +yy344: + ++cr; + return 0xAB; +yy346: + ++cr; + return 0xAC; +yy348: + ++cr; + return 0xAD; +yy350: + ++cr; + return 0xAE; +yy352: + ++cr; + return 0xAF; +yy354: + ++cr; + return 0xB0; +yy356: + ++cr; + return 0xB1; +yy358: + ++cr; + return 0xB2; +yy360: + ++cr; + return 0xB3; +yy362: + ++cr; + return 0xB4; +yy364: + ++cr; + return 0xB5; +yy366: + ++cr; + return 0xB6; +yy368: + ++cr; + return 0xB7; +yy370: + ++cr; + return 0xB8; +yy372: + ++cr; + return 0xB9; +yy374: + ++cr; + return 0xBA; +yy376: + ++cr; + return 0xBB; +yy378: + ++cr; + return 0xBC; +yy380: + ++cr; + return 0xBD; +yy382: + ++cr; + return 0xBE; +yy384: + ++cr; + return 0xBF; +yy386: + ++cr; + return 0xC0; +yy388: + ++cr; + return 0xC1; +yy390: + ++cr; + return 0xC2; +yy392: + ++cr; + return 0xC3; +yy394: + ++cr; + return 0xC4; +yy396: + ++cr; + return 0xC5; +yy398: + ++cr; + return 0xC6; +yy400: + ++cr; + return 0xC7; +yy402: + ++cr; + return 0xC8; +yy404: + ++cr; + return 0xC9; +yy406: + ++cr; + return 0xCA; +yy408: + ++cr; + return 0xCB; +yy410: + ++cr; + return 0xCC; +yy412: + ++cr; + return 0xCD; +yy414: + ++cr; + return 0xCE; +yy416: + ++cr; + return 0xCF; +yy418: + ++cr; + return 0xD0; +yy420: + ++cr; + return 0xD1; +yy422: + ++cr; + return 0xD2; +yy424: + ++cr; + return 0xD3; +yy426: + ++cr; + return 0xD4; +yy428: + ++cr; + return 0xD5; +yy430: + ++cr; + return 0xD6; +yy432: + ++cr; + return 0xD7; +yy434: + ++cr; + return 0xD8; +yy436: + ++cr; + return 0xD9; +yy438: + ++cr; + return 0xDA; +yy440: + ++cr; + return 0xDB; +yy442: + ++cr; + return 0xDC; +yy444: + ++cr; + return 0xDD; +yy446: + ++cr; + return 0xDE; +yy448: + ++cr; + return 0xDF; +yy450: + ++cr; + return 0xE0; +yy452: + ++cr; + return 0xE1; +yy454: + ++cr; + return 0xE2; +yy456: + ++cr; + return 0xE3; +yy458: + ++cr; + return 0xE4; +yy460: + ++cr; + return 0xE5; +yy462: + ++cr; + return 0xE6; +yy464: + ++cr; + return 0xE7; +yy466: + ++cr; + return 0xE8; +yy468: + ++cr; + return 0xE9; +yy470: + ++cr; + return 0xEA; +yy472: + ++cr; + return 0xEB; +yy474: + ++cr; + return 0xEC; +yy476: + ++cr; + return 0xED; +yy478: + ++cr; + return 0xEE; +yy480: + ++cr; + return 0xEF; +yy482: + ++cr; + return 0xF0; +yy484: + ++cr; + return 0xF1; +yy486: + ++cr; + return 0xF2; +yy488: + ++cr; + return 0xF3; +yy490: + ++cr; + return 0xF4; +yy492: + ++cr; + return 0xF5; +yy494: + ++cr; + return 0xF6; +yy496: + ++cr; + return 0xF7; +yy498: + ++cr; + return 0xF8; +yy500: + ++cr; + return 0xF9; +yy502: + ++cr; + return 0xFA; +yy504: + ++cr; + return 0xFB; +yy506: + ++cr; + return 0xFC; +yy508: + ++cr; + return 0xFD; +yy510: + ++cr; + return 0xFE; +yy512: + ++cr; + return 0xFF; +} + +} + +int main(int argc, char** argv) { + unsigned char buf[2]; + unsigned int ch = 0; + buf[1] = 0u; + + printf("const uint asc2asc[256] =\n"); + printf(" {\n"); + for (;;) { + if (ch % 16 == 0) { + printf(" "); + } + buf[0] = ch++; + printf("0x%02x", scan(buf)); + if (ch == 256) { + printf("\n"); + break; + } + if (ch % 16 == 0) { + printf(",\n"); + } else { + printf(", "); + } + } + printf(" };\n"); + return 0; +} diff --git a/re2c/test/bug2102138c.i.re b/re2c/test/bug2102138c.i.re new file mode 100755 index 00000000..5833bb89 --- /dev/null +++ b/re2c/test/bug2102138c.i.re @@ -0,0 +1,314 @@ +#include + +int scan(const unsigned char *cr) +{ + unsigned char ch; +/*!re2c + +re2c:define:YYCTYPE = "unsigned char"; +re2c:define:YYCURSOR = cr; +re2c:define:YYFILL = fill; +re2c:variable:yych = ch; +re2c:yyfill:enable = 0; + +"\x00" := return 0x00; +"\x01" := return 0x01; +"\x02" := return 0x02; +"\x03" := return 0x03; +"\x04" := return 0x04; +"\x05" := return 0x05; +"\x06" := return 0x06; +"\x07" := return 0x07; +"\x08" := return 0x08; +"\x09" := return 0x09; +"\x0A" := return 0x0A; +"\x0B" := return 0x0B; +"\x0C" := return 0x0C; +"\x0D" := return 0x0D; +"\x0E" := return 0x0E; +"\x0F" := return 0x0F; + +"\x10" := return 0x10; +"\x11" := return 0x11; +"\x12" := return 0x12; +"\x13" := return 0x13; +"\x14" := return 0x14; +"\x15" := return 0x15; +"\x16" := return 0x16; +"\x17" := return 0x17; +"\x18" := return 0x18; +"\x19" := return 0x19; +"\x1A" := return 0x1A; +"\x1B" := return 0x1B; +"\x1C" := return 0x1C; +"\x1D" := return 0x1D; +"\x1E" := return 0x1E; +"\x1F" := return 0x1F; + +" " := return 0x20; +"!" := return 0x21; +"\"" := return 0x22; +"#" := return 0x23; +"$" := return 0x24; +"%" := return 0x25; +"&" := return 0x26; +"'" := return 0x27; +"(" := return 0x28; +")" := return 0x29; +"*" := return 0x2A; +"+" := return 0x2B; +"," := return 0x2C; +"-" := return 0x2D; +"." := return 0x2E; +"/" := return 0x2F; + +"0" := return 0x30; +"1" := return 0x31; +"2" := return 0x32; +"3" := return 0x33; +"4" := return 0x34; +"5" := return 0x35; +"6" := return 0x36; +"7" := return 0x37; +"8" := return 0x38; +"9" := return 0x39; +":" := return 0x3A; +";" := return 0x3B; +"<" := return 0x3C; +"=" := return 0x3D; +">" := return 0x3E; +"?" := return 0x3F; + +"@" := return 0x40; +"A" := return 0x41; +"B" := return 0x42; +"C" := return 0x43; +"D" := return 0x44; +"E" := return 0x45; +"F" := return 0x46; +"G" := return 0x47; +"H" := return 0x48; +"I" := return 0x49; +"J" := return 0x4A; +"K" := return 0x4B; +"L" := return 0x4C; +"M" := return 0x4D; +"N" := return 0x4E; +"O" := return 0x4F; + +"P" := return 0x50; +"Q" := return 0x51; +"R" := return 0x52; +"S" := return 0x53; +"T" := return 0x54; +"U" := return 0x55; +"V" := return 0x56; +"W" := return 0x57; +"X" := return 0x58; +"Y" := return 0x59; +"Z" := return 0x5A; +"[" := return 0x5B; +"\\" := return 0x5C; +"]" := return 0x5D; +"^" := return 0x5E; +"_" := return 0x5F; + +"`" := return 0x60; +"a" := return 0x61; +"b" := return 0x62; +"c" := return 0x63; +"d" := return 0x64; +"e" := return 0x65; +"f" := return 0x66; +"g" := return 0x67; +"h" := return 0x68; +"i" := return 0x69; +"j" := return 0x6A; +"k" := return 0x6B; +"l" := return 0x6C; +"m" := return 0x6D; +"n" := return 0x6E; +"o" := return 0x6F; + +"p" := return 0x70; +"q" := return 0x71; +"r" := return 0x72; +"s" := return 0x73; +"t" := return 0x74; +"u" := return 0x75; +"v" := return 0x76; +"w" := return 0x77; +"x" := return 0x78; +"y" := return 0x79; +"z" := return 0x7A; +"{" := return 0x7B; +"|" := return 0x7C; +"}" := return 0x7D; +"~" := return 0x7E; +"\x7F" := return 0x7F; + +"\x80" := return 0x80; +"\x81" := return 0x81; +"\x82" := return 0x82; +"\x83" := return 0x83; +"\x84" := return 0x84; +"\x85" := return 0x85; +"\x86" := return 0x86; +"\x87" := return 0x87; +"\x88" := return 0x88; +"\x89" := return 0x89; +"\x8A" := return 0x8A; +"\x8B" := return 0x8B; +"\x8C" := return 0x8C; +"\x8D" := return 0x8D; +"\x8E" := return 0x8E; +"\x8F" := return 0x8F; + +"\x90" := return 0x90; +"\x91" := return 0x91; +"\x92" := return 0x92; +"\x93" := return 0x93; +"\x94" := return 0x94; +"\x95" := return 0x95; +"\x96" := return 0x96; +"\x97" := return 0x97; +"\x98" := return 0x98; +"\x99" := return 0x99; +"\x9A" := return 0x9A; +"\x9B" := return 0x9B; +"\x9C" := return 0x9C; +"\x9D" := return 0x9D; +"\x9E" := return 0x9E; +"\x9F" := return 0x9F; + +"\xA0" := return 0xA0; +"\xA1" := return 0xA1; +"\xA2" := return 0xA2; +"\xA3" := return 0xA3; +"\xA4" := return 0xA4; +"\xA5" := return 0xA5; +"\xA6" := return 0xA6; +"\xA7" := return 0xA7; +"\xA8" := return 0xA8; +"\xA9" := return 0xA9; +"\xAA" := return 0xAA; +"\xAB" := return 0xAB; +"\xAC" := return 0xAC; +"\xAD" := return 0xAD; +"\xAE" := return 0xAE; +"\xAF" := return 0xAF; + +"\xB0" := return 0xB0; +"\xB1" := return 0xB1; +"\xB2" := return 0xB2; +"\xB3" := return 0xB3; +"\xB4" := return 0xB4; +"\xB5" := return 0xB5; +"\xB6" := return 0xB6; +"\xB7" := return 0xB7; +"\xB8" := return 0xB8; +"\xB9" := return 0xB9; +"\xBA" := return 0xBA; +"\xBB" := return 0xBB; +"\xBC" := return 0xBC; +"\xBD" := return 0xBD; +"\xBE" := return 0xBE; +"\xBF" := return 0xBF; + +"\xC0" := return 0xC0; +"\xC1" := return 0xC1; +"\xC2" := return 0xC2; +"\xC3" := return 0xC3; +"\xC4" := return 0xC4; +"\xC5" := return 0xC5; +"\xC6" := return 0xC6; +"\xC7" := return 0xC7; +"\xC8" := return 0xC8; +"\xC9" := return 0xC9; +"\xCA" := return 0xCA; +"\xCB" := return 0xCB; +"\xCC" := return 0xCC; +"\xCD" := return 0xCD; +"\xCE" := return 0xCE; +"\xCF" := return 0xCF; + +"\xD0" := return 0xD0; +"\xD1" := return 0xD1; +"\xD2" := return 0xD2; +"\xD3" := return 0xD3; +"\xD4" := return 0xD4; +"\xD5" := return 0xD5; +"\xD6" := return 0xD6; +"\xD7" := return 0xD7; +"\xD8" := return 0xD8; +"\xD9" := return 0xD9; +"\xDA" := return 0xDA; +"\xDB" := return 0xDB; +"\xDC" := return 0xDC; +"\xDD" := return 0xDD; +"\xDE" := return 0xDE; +"\xDF" := return 0xDF; + +"\xE0" := return 0xE0; +"\xE1" := return 0xE1; +"\xE2" := return 0xE2; +"\xE3" := return 0xE3; +"\xE4" := return 0xE4; +"\xE5" := return 0xE5; +"\xE6" := return 0xE6; +"\xE7" := return 0xE7; +"\xE8" := return 0xE8; +"\xE9" := return 0xE9; +"\xEA" := return 0xEA; +"\xEB" := return 0xEB; +"\xEC" := return 0xEC; +"\xED" := return 0xED; +"\xEE" := return 0xEE; +"\xEF" := return 0xEF; + +"\xF0" := return 0xF0; +"\xF1" := return 0xF1; +"\xF2" := return 0xF2; +"\xF3" := return 0xF3; +"\xF4" := return 0xF4; +"\xF5" := return 0xF5; +"\xF6" := return 0xF6; +"\xF7" := return 0xF7; +"\xF8" := return 0xF8; +"\xF9" := return 0xF9; +"\xFA" := return 0xFA; +"\xFB" := return 0xFB; +"\xFC" := return 0xFC; +"\xFD" := return 0xFD; +"\xFE" := return 0xFE; +"\xFF" := return 0xFF; + +*/ +} + +int main(int argc, char** argv) { + unsigned char buf[2]; + unsigned int ch = 0; + buf[1] = 0u; + + printf("const uint asc2asc[256] =\n"); + printf(" {\n"); + for (;;) { + if (ch % 16 == 0) { + printf(" "); + } + buf[0] = ch++; + printf("0x%02x", scan(buf)); + if (ch == 256) { + printf("\n"); + break; + } + if (ch % 16 == 0) { + printf(",\n"); + } else { + printf(", "); + } + } + printf(" };\n"); + return 0; +} diff --git a/re2c/test/bug2102138c.i.txt b/re2c/test/bug2102138c.i.txt new file mode 100644 index 00000000..b8f235e1 --- /dev/null +++ b/re2c/test/bug2102138c.i.txt @@ -0,0 +1,19 @@ +const uint asc2asc[256] = + { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff + }; diff --git a/re2c/test/calc_001.dei.c b/re2c/test/calc_001.dei.c new file mode 100755 index 00000000..736cfc6c --- /dev/null +++ b/re2c/test/calc_001.dei.c @@ -0,0 +1,369 @@ +/* Generated by re2c */ +/* re2c lesson 001_upn_calculator, calc_001, (c) M. Boerger 2006 - 2007 */ + +#include +#include +#include + +int scan(char *s, int l) +{ + char *p = s; + char *q = 0; +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l) +#define YYMARKER q +#define YYFILL(n) + + for(;;) + { + + { + YYCTYPE yych; + + YYDEBUG(0, *YYCURSOR); + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + YYDEBUG(-1, yych); + switch (yych) { + case 0x00: goto yy12; + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: /* */ + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: /* . */ + case 0x4C: /* < */ + case 0x4D: /* ( */ + case 0x4F: /* | */ + case 0x50: /* & */ + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: /* ! */ + case 0x5B: /* $ */ + case 0x5C: /* * */ + case 0x5D: /* ) */ + case 0x5E: /* ; */ + case 0x5F: + case 0x61: /* / */ + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: /* , */ + case 0x6C: /* % */ + case 0x6D: /* _ */ + case 0x6E: /* > */ + case 0x6F: /* ? */ + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: /* ` */ + case 0x7A: /* : */ + case 0x7B: /* # */ + case 0x7C: /* @ */ + case 0x7D: /* ' */ + case 0x7E: /* = */ + case 0x7F: /* " */ + case 0x80: + case 0x81: /* a */ + case 0x82: /* b */ + case 0x83: /* c */ + case 0x84: /* d */ + case 0x85: /* e */ + case 0x86: /* f */ + case 0x87: /* g */ + case 0x88: /* h */ + case 0x89: /* i */ + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + case 0x90: + case 0x91: /* j */ + case 0x92: /* k */ + case 0x93: /* l */ + case 0x94: /* m */ + case 0x95: /* n */ + case 0x96: /* o */ + case 0x97: /* p */ + case 0x98: /* q */ + case 0x99: /* r */ + case 0x9A: + case 0x9B: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + case 0xA0: + case 0xA1: /* ~ */ + case 0xA2: /* s */ + case 0xA3: /* t */ + case 0xA4: /* u */ + case 0xA5: /* v */ + case 0xA6: /* w */ + case 0xA7: /* x */ + case 0xA8: /* y */ + case 0xA9: /* z */ + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: /* ^ */ + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: /* [ */ + case 0xBB: /* ] */ + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + case 0xC0: /* { */ + case 0xC1: /* A */ + case 0xC2: /* B */ + case 0xC3: /* C */ + case 0xC4: /* D */ + case 0xC5: /* E */ + case 0xC6: /* F */ + case 0xC7: /* G */ + case 0xC8: /* H */ + case 0xC9: /* I */ + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: /* } */ + case 0xD1: /* J */ + case 0xD2: /* K */ + case 0xD3: /* L */ + case 0xD4: /* M */ + case 0xD5: /* N */ + case 0xD6: /* O */ + case 0xD7: /* P */ + case 0xD8: /* Q */ + case 0xD9: /* R */ + case 0xDA: + case 0xDB: + case 0xDC: + case 0xDD: + case 0xDE: + case 0xDF: goto yy14; + case 0x4E: /* + */ goto yy8; + case 0x60: /* - */ goto yy10; + case 0xF0: /* 0 */ goto yy3; + case 0xF1: /* 1 */ + case 0xF2: /* 2 */ + case 0xF3: /* 3 */ + case 0xF4: /* 4 */ + case 0xF5: /* 5 */ + case 0xF6: /* 6 */ + case 0xF7: /* 7 */ + case 0xF8: /* 8 */ + case 0xF9: /* 9 */ goto yy5; + default: goto yy2; + } +yy2: + YYDEBUG(2, *YYCURSOR); +yy3: + YYDEBUG(3, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(-1, yych); + switch ((yych = *YYCURSOR)) { + case 0xF0: /* 0 */ + case 0xF1: /* 1 */ + case 0xF2: /* 2 */ + case 0xF3: /* 3 */ + case 0xF4: /* 4 */ + case 0xF5: /* 5 */ + case 0xF6: /* 6 */ + case 0xF7: /* 7 */ + case 0xF8: /* 8 */ + case 0xF9: /* 9 */ goto yy16; + default: goto yy4; + } +yy4: + YYDEBUG(4, *YYCURSOR); + { printf("Num\n"); continue; } +yy5: + YYDEBUG(5, *YYCURSOR); + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(6, *YYCURSOR); + YYDEBUG(-1, yych); + switch (yych) { + case 0xF0: /* 0 */ + case 0xF1: /* 1 */ + case 0xF2: /* 2 */ + case 0xF3: /* 3 */ + case 0xF4: /* 4 */ + case 0xF5: /* 5 */ + case 0xF6: /* 6 */ + case 0xF7: /* 7 */ + case 0xF8: /* 8 */ + case 0xF9: /* 9 */ goto yy5; + default: goto yy7; + } +yy7: + YYDEBUG(7, *YYCURSOR); + { printf("Num\n"); continue; } +yy8: + YYDEBUG(8, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(9, *YYCURSOR); + { printf("+\n"); continue; } +yy10: + YYDEBUG(10, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(11, *YYCURSOR); + { printf("-\n"); continue; } +yy12: + YYDEBUG(12, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(13, *YYCURSOR); + { printf("EOF\n"); return 0; } +yy14: + YYDEBUG(14, *YYCURSOR); + ++YYCURSOR; + YYDEBUG(15, *YYCURSOR); + { printf("ERR\n"); return 1; } +yy16: + YYDEBUG(16, *YYCURSOR); + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(17, *YYCURSOR); + YYDEBUG(-1, yych); + switch (yych) { + case 0xF0: /* 0 */ + case 0xF1: /* 1 */ + case 0xF2: /* 2 */ + case 0xF3: /* 3 */ + case 0xF4: /* 4 */ + case 0xF5: /* 5 */ + case 0xF6: /* 6 */ + case 0xF7: /* 7 */ + case 0xF8: /* 8 */ + case 0xF9: /* 9 */ goto yy16; + default: goto yy18; + } +yy18: + YYDEBUG(18, *YYCURSOR); + { printf("Oct\n"); continue; } + } + + } +} + +int main(int argc, char **argv) +{ + if (argc > 1) + { + return scan(argv[1], strlen(argv[1])); + } + else + { + fprintf(stderr, "%s \n", argv[0]); + return 1; + } +} diff --git a/re2c/test/calc_001.dei.re b/re2c/test/calc_001.dei.re new file mode 100755 index 00000000..fe8d3ae1 --- /dev/null +++ b/re2c/test/calc_001.dei.re @@ -0,0 +1,84 @@ +/* re2c lesson 001_upn_calculator, calc_001, (c) M. Boerger 2006 - 2007 */ +/*!ignore:re2c + +- basic interface for string reading + + . We define the macros YYCTYPE, YYCURSOR, YYLIMIT, YYMARKER, YYFILL + . YYCTYPE is the type re2c operates on or in other words the type that + it generates code for. While it is not a big difference when we were + using 'unsigned char' here we would need to run re2c with option -w + to fully support types with sieof() > 1. + . YYCURSOR is used internally and holds the current scanner position. In + expression handlers, the code blocks after re2c expressions, this can be + used to identify the end of the token. + . YYMARKER is not always being used so we set an initial value to avoid + a compiler warning. Here we could also omit it compleley. + . YYLIMIT stores the end of the input. Unfortunatley we have to use strlen() + in this lesson. In the next example we see one way to get rid of it. + . We use a 'for(;;)'-loop around the scanner block. We could have used a + 'while(1)'-loop instead but some compilers generate a warning for it. + . To make the output more readable we use 're2c:indent:top' scanner + configuration that configures re2c to prepend a single tab (the default) + to the beginning of each output line. + . The following lines are expressions and for each expression we output the + token name and continue the scanner loop. + . The second last token detects the end of our input, the terminating zero in + our input string. In other scanners detecting the end of input may vary. + For example binary code may contain \0 as valid input. + . The last expression accepts any input character. It tells re2c to accept + the opposit of the empty range. This includes numbers and our tokens but + as re2c goes from top to botton when evaluating the expressions this is no + problem. + . The first three rules show that re2c actually prioritizes the expressions + from top to bottom. Octal number require a starting "0" and the actual + number. Normal numbers start with a digit greater 0. And zero is finally a + special case. A single "0" is detected by the last rule of this set. And + valid ocal number is already being detected by the first rule. This even + includes multi "0" sequences that in octal notation also means zero. + Another way would be to only use two rules: + "0" [0-9]+ + "0" | ( [1-9] [0-9]* ) + A full description of re2c rule syntax can be found in the manual. +*/ + +#include +#include +#include + +int scan(char *s, int l) +{ + char *p = s; + char *q = 0; +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l) +#define YYMARKER q +#define YYFILL(n) + + for(;;) + { +/*!re2c + re2c:indent:top = 2; + "0"[0-9]+ { printf("Oct\n"); continue; } + [1-9][0-9]* { printf("Num\n"); continue; } + "0" { printf("Num\n"); continue; } + "+" { printf("+\n"); continue; } + "-" { printf("-\n"); continue; } + "\000" { printf("EOF\n"); return 0; } + [^] { printf("ERR\n"); return 1; } +*/ + } +} + +int main(int argc, char **argv) +{ + if (argc > 1) + { + return scan(argv[1], strlen(argv[1])); + } + else + { + fprintf(stderr, "%s \n", argv[0]); + return 1; + } +} diff --git a/re2c/test/calc_001.ei.c b/re2c/test/calc_001.ei.c new file mode 100755 index 00000000..e8904140 --- /dev/null +++ b/re2c/test/calc_001.ei.c @@ -0,0 +1,347 @@ +/* Generated by re2c */ +/* re2c lesson 001_upn_calculator, calc_001, (c) M. Boerger 2006 - 2007 */ + +#include +#include +#include + +int scan(char *s, int l) +{ + char *p = s; + char *q = 0; +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l) +#define YYMARKER q +#define YYFILL(n) + + for(;;) + { + + { + YYCTYPE yych; + + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + switch (yych) { + case 0x00: goto yy12; + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x09: + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + case 0x29: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x76: + case 0x77: + case 0x78: + case 0x79: + case 0x7A: + case 0x7B: + case 0x7C: + case 0x7D: + case 0x7E: + case 0x7F: + case 0x80: + case 0x81: + case 0x82: + case 0x83: + case 0x84: + case 0x85: + case 0x86: + case 0x87: + case 0x88: + case 0x89: + case 0x8A: + case 0x8B: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9A: + case 0x9B: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + case 0xA0: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA4: + case 0xA5: + case 0xA6: + case 0xA7: + case 0xA8: + case 0xA9: + case 0xAA: + case 0xAB: + case 0xAC: + case 0xAD: + case 0xAE: + case 0xAF: + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + case 0xC0: + case 0xC1: + case 0xC2: + case 0xC3: + case 0xC4: + case 0xC5: + case 0xC6: + case 0xC7: + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD5: + case 0xD6: + case 0xD7: + case 0xD8: + case 0xD9: + case 0xDA: + case 0xDB: + case 0xDC: + case 0xDD: + case 0xDE: + case 0xDF: goto yy14; + case 0x4E: goto yy8; + case 0x60: goto yy10; + case 0xF0: goto yy3; + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: goto yy5; + default: goto yy2; + } +yy2: +yy3: + ++YYCURSOR; + switch ((yych = *YYCURSOR)) { + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: goto yy16; + default: goto yy4; + } +yy4: + { printf("Num\n"); continue; } +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: goto yy5; + default: goto yy7; + } +yy7: + { printf("Num\n"); continue; } +yy8: + ++YYCURSOR; + { printf("+\n"); continue; } +yy10: + ++YYCURSOR; + { printf("-\n"); continue; } +yy12: + ++YYCURSOR; + { printf("EOF\n"); return 0; } +yy14: + ++YYCURSOR; + { printf("ERR\n"); return 1; } +yy16: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 0xF0: + case 0xF1: + case 0xF2: + case 0xF3: + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + case 0xF8: + case 0xF9: goto yy16; + default: goto yy18; + } +yy18: + { printf("Oct\n"); continue; } + } + + } +} + +int main(int argc, char **argv) +{ + if (argc > 1) + { + return scan(argv[1], strlen(argv[1])); + } + else + { + fprintf(stderr, "%s \n", argv[0]); + return 1; + } +} diff --git a/re2c/test/calc_001.ei.re b/re2c/test/calc_001.ei.re new file mode 100755 index 00000000..fe8d3ae1 --- /dev/null +++ b/re2c/test/calc_001.ei.re @@ -0,0 +1,84 @@ +/* re2c lesson 001_upn_calculator, calc_001, (c) M. Boerger 2006 - 2007 */ +/*!ignore:re2c + +- basic interface for string reading + + . We define the macros YYCTYPE, YYCURSOR, YYLIMIT, YYMARKER, YYFILL + . YYCTYPE is the type re2c operates on or in other words the type that + it generates code for. While it is not a big difference when we were + using 'unsigned char' here we would need to run re2c with option -w + to fully support types with sieof() > 1. + . YYCURSOR is used internally and holds the current scanner position. In + expression handlers, the code blocks after re2c expressions, this can be + used to identify the end of the token. + . YYMARKER is not always being used so we set an initial value to avoid + a compiler warning. Here we could also omit it compleley. + . YYLIMIT stores the end of the input. Unfortunatley we have to use strlen() + in this lesson. In the next example we see one way to get rid of it. + . We use a 'for(;;)'-loop around the scanner block. We could have used a + 'while(1)'-loop instead but some compilers generate a warning for it. + . To make the output more readable we use 're2c:indent:top' scanner + configuration that configures re2c to prepend a single tab (the default) + to the beginning of each output line. + . The following lines are expressions and for each expression we output the + token name and continue the scanner loop. + . The second last token detects the end of our input, the terminating zero in + our input string. In other scanners detecting the end of input may vary. + For example binary code may contain \0 as valid input. + . The last expression accepts any input character. It tells re2c to accept + the opposit of the empty range. This includes numbers and our tokens but + as re2c goes from top to botton when evaluating the expressions this is no + problem. + . The first three rules show that re2c actually prioritizes the expressions + from top to bottom. Octal number require a starting "0" and the actual + number. Normal numbers start with a digit greater 0. And zero is finally a + special case. A single "0" is detected by the last rule of this set. And + valid ocal number is already being detected by the first rule. This even + includes multi "0" sequences that in octal notation also means zero. + Another way would be to only use two rules: + "0" [0-9]+ + "0" | ( [1-9] [0-9]* ) + A full description of re2c rule syntax can be found in the manual. +*/ + +#include +#include +#include + +int scan(char *s, int l) +{ + char *p = s; + char *q = 0; +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l) +#define YYMARKER q +#define YYFILL(n) + + for(;;) + { +/*!re2c + re2c:indent:top = 2; + "0"[0-9]+ { printf("Oct\n"); continue; } + [1-9][0-9]* { printf("Num\n"); continue; } + "0" { printf("Num\n"); continue; } + "+" { printf("+\n"); continue; } + "-" { printf("-\n"); continue; } + "\000" { printf("EOF\n"); return 0; } + [^] { printf("ERR\n"); return 1; } +*/ + } +} + +int main(int argc, char **argv) +{ + if (argc > 1) + { + return scan(argv[1], strlen(argv[1])); + } + else + { + fprintf(stderr, "%s \n", argv[0]); + return 1; + } +} diff --git a/re2c/test/config11.ei.c b/re2c/test/config11.ei.c index 9f0e26f3..7b79581d 100755 --- a/re2c/test/config11.ei.c +++ b/re2c/test/config11.ei.c @@ -9,8 +9,8 @@ unsigned char scan(const unsigned char *s) ch = *cr; switch (ch) { - case 'a': goto yy3; - case 'b': goto yy5; + case 0x81: goto yy3; + case 0x82: goto yy5; default: goto yy2; } yy2: