From 12ccfd898c86ecebf5fae9b3171bbd18e3a898d1 Mon Sep 17 00:00:00 2001 From: helly Date: Mon, 24 Mar 2008 01:05:08 +0000 Subject: [PATCH] - Added re2c:flags:w and re2c:flags:u inplace configurations. - Changed -r flag to accept only 'rules:re2c' and 'use:re2c' blocks. --- re2c/CHANGELOG | 2 + re2c/actions.cc | 6 +- re2c/bootstrap/parser.cc | 60 ++- re2c/bootstrap/scanner.cc | 929 +++++++++++++++++++----------------- re2c/code.cc | 41 +- re2c/dfa.cc | 2 + re2c/dfa.h | 6 + re2c/htdocs/index.html | 2 + re2c/htdocs/manual.html | 6 +- re2c/parser.y | 60 ++- re2c/re.h | 2 +- re2c/re2c.1.in | 6 +- re2c/scanner.h | 3 +- re2c/scanner.re | 24 +- re2c/test/cond_error_10.c.c | 2 +- re2c/test/cond_error_11.c.c | 2 +- re2c/test/repeat-00.cgi.c | 2 +- re2c/test/repeat-00.cgi.re | 19 +- re2c/test/repeat-01.cgir.c | 159 ++---- re2c/test/repeat-01.cgir.re | 17 +- re2c/test/repeat-02.cgir.c | 159 ++---- re2c/test/repeat-02.cgir.re | 17 +- re2c/test/repeat-03.cgir.c | 2 +- re2c/test/repeat-03.cgir.re | 4 +- re2c/test/repeat-04.cgir.c | 2 +- re2c/test/repeat-04.cgir.re | 12 +- re2c/test/repeat-05.cgir.c | 1 + re2c/test/repeat-05.cgir.re | 10 + 28 files changed, 794 insertions(+), 763 deletions(-) create mode 100755 re2c/test/repeat-05.cgir.c create mode 100755 re2c/test/repeat-05.cgir.re diff --git a/re2c/CHANGELOG b/re2c/CHANGELOG index 9d074004..2c9e573a 100644 --- a/re2c/CHANGELOG +++ b/re2c/CHANGELOG @@ -2,6 +2,8 @@ Version 0.13.4 (2008-??-??) --------------------------- - Added re2c:yyfill:check inplace configuration. - Added re2c:define:YYSETSTATE:naked inplace configuration. +- Added re2c:flags:w and re2c:flags:u inplace configurations. +- Changed -r flag to accept only 'rules:re2c' and 'use:re2c' blocks. Version 0.13.3 (2008-03-14) --------------------------- diff --git a/re2c/actions.cc b/re2c/actions.cc index c733b8eb..dca7247b 100644 --- a/re2c/actions.cc +++ b/re2c/actions.cc @@ -1017,7 +1017,7 @@ CharSet::~CharSet() delete[] ptn; } -DFA* genCode(std::ostream& o, uint& ind, RegExp *re, const RegExpMap* specMap, const std::string& condName, bool isLastCond, bool &bPrologBrace) +DFA* genCode(RegExp *re) { CharSet cs; uint j; @@ -1064,9 +1064,7 @@ DFA* genCode(std::ostream& o, uint& ind, RegExp *re, const RegExpMap* specMap, c } } - DFA *dfa = new DFA(ins, re->size, 0, nRealChars, rep); - dfa->emit(o, ind, specMap, condName, isLastCond, bPrologBrace); - return dfa; + return new DFA(ins, re->size, 0, nRealChars, rep); } } // end namespace re2c diff --git a/re2c/bootstrap/parser.cc b/re2c/bootstrap/parser.cc index 85c17963..56d08932 100644 --- a/re2c/bootstrap/parser.cc +++ b/re2c/bootstrap/parser.cc @@ -1551,7 +1551,7 @@ yyreduce: { if (parseMode == Scanner::Reuse) { - in->fatal("Rules not allowed in 'repeat:re2c' block"); + in->fatal("rules not allowed in 'use:re2c' block"); } } break; @@ -2191,21 +2191,22 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) o << " */\n"; o << sourceFileInfo; + bool uFlagOld = uFlag; + bool wFlagOld = wFlag; + uint nRealCharsOld = nRealChars; + while ((parseMode = i.echo()) != Scanner::Stop) { bool bPrologBrace = false; - if (rFlag && parseMode == Scanner::Parse && (dfa || dfa_map.size())) + if (rFlag && parseMode == Scanner::Rules && (dfa || dfa_map.size())) { - in->fatal("Cannot have another 're2c' block after a block containing rules"); + in->fatal("cannot have a second 'rules:re2c' block"); } - in->set_in_parse(true); - yyparse(); - in->set_in_parse(false); if (parseMode == Scanner::Reuse) { if (!dfa && dfa_map.empty()) { - in->fatal("Got 'repeat:re2c' without 're2c'"); + in->fatal("got 'use:re2c' without 'rules:re2c'"); } } else @@ -2215,6 +2216,30 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) delete dfa; dfa = NULL; } + dfa_map.clear(); + } + in->set_in_parse(true); + yyparse(); + in->set_in_parse(false); + if (rFlag) + { + uint nRealCharsLast = nRealChars; + if (uFlag) + { + nRealChars = 0x110000; /* 17 times w-Flag */ + } + else if (wFlag) + { + nRealChars = (1<<16); /* 0x10000 */ + } + else + { + nRealChars = (1<<8); /* 0x100 */ + } + if (nRealCharsLast != nRealChars) + { + /* Char width changed, so we need to regenerate the dfa. */ + } } if (cFlag) { @@ -2282,7 +2307,12 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) yySetupRule = ""; } } - dfa_map[it->first] = genCode(o, topIndent, it->second.second, &specMap, it->first, !--nCount, bPrologBrace); + dfa_map[it->first] = genCode(it->second.second); + dfa_map[it->first]->prepare(); + if (!rFlag) + { + dfa_map[it->first]->emit(o, topIndent, &specMap, it->first, !--nCount, bPrologBrace); + } } } if (!h && !bTypesDone) @@ -2290,7 +2320,7 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) genTypes(typesInline, 0, specMap); } } - else if (spec) + else if (spec || dfa) { if (parseMode == Scanner::Reuse) { @@ -2298,15 +2328,21 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) } else { - dfa = genCode(o, topIndent, spec, NULL, "", 0, bPrologBrace); + dfa = genCode(spec); + dfa->prepare(); if (!rFlag) { + dfa->emit(o, topIndent, NULL, "", 0, bPrologBrace); delete dfa; dfa = NULL; } } } o << sourceFileInfo; + /* restore original char handling mode*/ + uFlag = uFlagOld; + wFlag = wFlagOld; + nRealChars = nRealCharsOld; } if (cFlag) @@ -2316,7 +2352,7 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) { if (itRuleSetup->first != "*" && specMap.find(itRuleSetup->first) == specMap.end()) { - in->fatalf_at(itRuleSetup->second.first, "Setup for non existing rule '%s' found", itRuleSetup->first.c_str()); + in->fatalf_at(itRuleSetup->second.first, "setup for non existing rule '%s' found", itRuleSetup->first.c_str()); } } if (specMap.size() < ruleSetupMap.size()) @@ -2327,7 +2363,7 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) { line = itRuleSetup->second.first; } - in->fatalf_at(line, "Setup for all rules with '*' not possible when all rules are setup explicitly"); + in->fatalf_at(line, "setup for all rules with '*' not possible when all rules are setup explicitly"); } } diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc index 8bd084e2..8b7c3490 100644 --- a/re2c/bootstrap/scanner.cc +++ b/re2c/bootstrap/scanner.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.4.dev on Sat Mar 22 17:57:39 2008 */ +/* Generated by re2c 0.13.4.dev on Mon Mar 24 01:44:05 2008 */ /* $Id$ */ #include #include @@ -216,36 +216,55 @@ yy16: case 'g': goto yy20; case 'i': goto yy19; case 'm': goto yy21; - case 'r': goto yy22; + case 'r': goto yy23; case 't': goto yy18; + case 'u': goto yy22; default: goto yy13; } yy18: yych = *++YYCURSOR; - if (yych == 'y') goto yy69; + if (yych == 'y') goto yy78; goto yy13; yy19: yych = *++YYCURSOR; - if (yych == 'g') goto yy58; + if (yych == 'g') goto yy67; goto yy13; yy20: yych = *++YYCURSOR; - if (yych == 'e') goto yy45; + if (yych == 'e') goto yy54; goto yy13; yy21: yych = *++YYCURSOR; - if (yych == 'a') goto yy37; + if (yych == 'a') goto yy46; goto yy13; yy22: yych = *++YYCURSOR; - if (yych != 'e') goto yy13; + if (yych == 's') goto yy38; + goto yy13; +yy23: yych = *++YYCURSOR; - if (yych == '2') goto yy25; - if (yych != 'p') goto yy13; + if (yych == 'e') goto yy24; + if (yych == 'u') goto yy25; + goto yy13; +yy24: yych = *++YYCURSOR; - if (yych == 'e') goto yy28; + if (yych == '2') goto yy35; goto yy13; yy25: + yych = *++YYCURSOR; + if (yych != 'l') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != 's') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; yych = *++YYCURSOR; if (yych != 'c') goto yy13; ++YYCURSOR; @@ -254,6 +273,26 @@ yy25: { mapCodeName.clear(); } + else + { + fatal("found 'reules:re2c' block without -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + tok = cursor; + RETURN(Rules); + } +yy35: + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + if (rFlag) + { + fatal("found standard 're2c' block while using -r flag"); + } if (bUsedYYMaxFill && bSinglePass) { fatal("found scanner block after YYMAXFILL declaration"); @@ -265,11 +304,9 @@ yy25: tok = cursor; RETURN(Parse); } -yy28: +yy38: yych = *++YYCURSOR; - if (yych != 'a') goto yy13; - yych = *++YYCURSOR; - if (yych != 't') goto yy13; + if (yych != 'e') goto yy13; yych = *++YYCURSOR; if (yych != ':') goto yy13; yych = *++YYCURSOR; @@ -284,7 +321,7 @@ yy28: { if (!rFlag) { - fatal("Cannot reuse scanner definition without -r flag"); + fatal("found 'use:re2c' block without -r flag"); } next_label = 0; next_fill_index = 0; @@ -297,12 +334,12 @@ yy28: } if (!DFlag) { - out.write((const char*)(tok), (const char*)(&cursor[-14]) - (const char*)(tok)); + out.write((const char*)(tok), (const char*)(&cursor[-11]) - (const char*)(tok)); } tok = cursor; RETURN(Reuse); } -yy37: +yy46: yych = *++YYCURSOR; if (yych != 'x') goto yy13; yych = *++YYCURSOR; @@ -330,7 +367,7 @@ yy37: bUsedYYMaxFill = true; goto echo; } -yy45: +yy54: yych = *++YYCURSOR; if (yych != 't') goto yy13; yych = *++YYCURSOR; @@ -360,7 +397,7 @@ yy45: ignore_eoc = true; goto echo; } -yy58: +yy67: yych = *++YYCURSOR; if (yych != 'n') goto yy13; yych = *++YYCURSOR; @@ -385,7 +422,7 @@ yy58: ignore_eoc = true; goto echo; } -yy69: +yy78: yych = *++YYCURSOR; if (yych != 'p') goto yy13; yych = *++YYCURSOR; @@ -484,104 +521,104 @@ scan: if (yych <= '/') { if (yych <= '"') { if (yych <= '\f') { - if (yych <= 0x08) goto yy108; - if (yych <= '\t') goto yy103; - if (yych <= '\n') goto yy105; - goto yy108; + if (yych <= 0x08) goto yy117; + if (yych <= '\t') goto yy112; + if (yych <= '\n') goto yy114; + goto yy117; } else { if (yych <= 0x1F) { - if (yych <= '\r') goto yy107; - goto yy108; + if (yych <= '\r') goto yy116; + goto yy117; } else { - if (yych <= ' ') goto yy103; - if (yych <= '!') goto yy108; - goto yy89; + if (yych <= ' ') goto yy112; + if (yych <= '!') goto yy117; + goto yy98; } } } else { if (yych <= '*') { - if (yych <= '&') goto yy108; - if (yych <= '\'') goto yy91; - if (yych <= ')') goto yy96; - goto yy87; + if (yych <= '&') goto yy117; + if (yych <= '\'') goto yy100; + if (yych <= ')') goto yy105; + goto yy96; } else { if (yych <= ',') { - if (yych <= '+') goto yy97; - goto yy96; + if (yych <= '+') goto yy106; + goto yy105; } else { - if (yych <= '-') goto yy108; - if (yych <= '.') goto yy101; - goto yy85; + if (yych <= '-') goto yy117; + if (yych <= '.') goto yy110; + goto yy94; } } } } else { if (yych <= '[') { if (yych <= '<') { - if (yych <= '9') goto yy108; - if (yych <= ':') goto yy83; - if (yych <= ';') goto yy96; - goto yy95; + if (yych <= '9') goto yy117; + if (yych <= ':') goto yy92; + if (yych <= ';') goto yy105; + goto yy104; } else { if (yych <= '?') { - if (yych <= '>') goto yy96; - goto yy97; + if (yych <= '>') goto yy105; + goto yy106; } else { - if (yych <= '@') goto yy108; - if (yych <= 'Z') goto yy100; - goto yy93; + if (yych <= '@') goto yy117; + if (yych <= 'Z') goto yy109; + goto yy102; } } } else { if (yych <= 'q') { if (yych <= '^') { - if (yych <= '\\') goto yy96; - goto yy108; + if (yych <= '\\') goto yy105; + goto yy117; } else { - if (yych == '`') goto yy108; - goto yy100; + if (yych == '`') goto yy117; + goto yy109; } } else { if (yych <= 'z') { - if (yych <= 'r') goto yy99; - goto yy100; + if (yych <= 'r') goto yy108; + goto yy109; } else { - if (yych <= '{') goto yy81; - if (yych <= '|') goto yy96; - goto yy108; + if (yych <= '{') goto yy90; + if (yych <= '|') goto yy105; + goto yy117; } } } } -yy81: +yy90: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '@') { if (yych <= '/') { - if (yych == ',') goto yy178; + if (yych == ',') goto yy187; } else { - if (yych <= '0') goto yy175; - if (yych <= '9') goto yy176; + if (yych <= '0') goto yy184; + if (yych <= '9') goto yy185; } } else { if (yych <= '_') { - if (yych <= 'Z') goto yy173; - if (yych >= '_') goto yy173; + if (yych <= 'Z') goto yy182; + if (yych >= '_') goto yy182; } else { - if (yych <= '`') goto yy82; - if (yych <= 'z') goto yy173; + if (yych <= '`') goto yy91; + if (yych <= 'z') goto yy182; } } -yy82: +yy91: { depth = 1; goto code; } -yy83: +yy92: YYCTXMARKER = YYCURSOR + 1; ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy169; -yy84: + if ((yych = *YYCURSOR) == '=') goto yy178; +yy93: { std::ostringstream msg; msg << "unexpected character: "; @@ -589,137 +626,137 @@ yy84: fatal(msg.str().c_str()); goto scan; } -yy85: +yy94: ++YYCURSOR; - if ((yych = *YYCURSOR) == '*') goto yy167; -yy86: + if ((yych = *YYCURSOR) == '*') goto yy176; +yy95: { RETURN(*tok); } -yy87: +yy96: ++YYCURSOR; - if ((yych = *YYCURSOR) == '/') goto yy165; + if ((yych = *YYCURSOR) == '/') goto yy174; { yylval.op = *tok; RETURN(STAR); } -yy89: +yy98: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych != '\n') goto yy161; -yy90: + if (yych != '\n') goto yy170; +yy99: { fatal("unterminated string constant (missing \")"); } -yy91: +yy100: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych != '\n') goto yy156; -yy92: + if (yych != '\n') goto yy165; +yy101: { fatal("unterminated string constant (missing ')"); } -yy93: +yy102: yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy94; - if (yych == '^') goto yy147; - goto yy146; -yy94: + if (yych == '\n') goto yy103; + if (yych == '^') goto yy156; + goto yy155; +yy103: { fatal("unterminated range (missing ])"); } -yy95: +yy104: yyaccept = 4; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '!') goto yy136; - if (yych == '>') goto yy138; - goto yy86; -yy96: + if (yych == '!') goto yy145; + if (yych == '>') goto yy147; + goto yy95; +yy105: yych = *++YYCURSOR; - goto yy86; -yy97: + goto yy95; +yy106: ++YYCURSOR; { yylval.op = *tok; RETURN(CLOSE); } -yy99: +yy108: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; - if (yych == 'e') goto yy124; - goto yy113; -yy100: + if (yych == 'e') goto yy133; + goto yy122; +yy109: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; - goto yy113; -yy101: + goto yy122; +yy110: ++YYCURSOR; { cur = cursor; yylval.regexp = mkDot(); return RANGE; } -yy103: +yy112: ++YYCURSOR; yych = *YYCURSOR; - goto yy111; -yy104: + goto yy120; +yy113: { goto scan; } -yy105: +yy114: ++YYCURSOR; -yy106: +yy115: { if(cursor == eof) RETURN(0); pos = cursor; cline++; goto scan; } -yy107: +yy116: yych = *++YYCURSOR; - if (yych == '\n') goto yy109; - goto yy84; -yy108: + if (yych == '\n') goto yy118; + goto yy93; +yy117: yych = *++YYCURSOR; - goto yy84; -yy109: + goto yy93; +yy118: yych = *++YYCURSOR; - goto yy106; -yy110: + goto yy115; +yy119: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy111: +yy120: if (yybm[0+yych] & 4) { - goto yy110; + goto yy119; } - goto yy104; -yy112: + goto yy113; +yy121: YYCTXMARKER = YYCURSOR + 1; ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; -yy113: +yy122: if (yybm[0+yych] & 8) { - goto yy112; + goto yy121; } if (yych <= ' ') { - if (yych == '\t') goto yy116; - if (yych <= 0x1F) goto yy115; - goto yy116; + if (yych == '\t') goto yy125; + if (yych <= 0x1F) goto yy124; + goto yy125; } else { if (yych <= ',') { - if (yych <= '+') goto yy115; - goto yy117; + if (yych <= '+') goto yy124; + goto yy126; } else { - if (yych <= '<') goto yy115; - if (yych <= '>') goto yy117; - goto yy115; + if (yych <= '<') goto yy124; + if (yych <= '>') goto yy126; + goto yy124; } } -yy114: +yy123: YYCURSOR = YYCTXMARKER; { if (!FFlag) { @@ -740,22 +777,22 @@ yy114: return STRING; } } -yy115: +yy124: yych = *++YYCURSOR; - goto yy114; -yy116: + goto yy123; +yy125: yych = *++YYCURSOR; - goto yy122; -yy117: + goto yy131; +yy126: ++YYCURSOR; -yy118: +yy127: YYCURSOR = YYCTXMARKER; { cur = ptr > tok ? ptr - 1 : cursor; yylval.symbol = Symbol::find(token()); return ID; } -yy119: +yy128: ++YYCURSOR; YYCURSOR = YYCTXMARKER; { @@ -770,65 +807,65 @@ yy119: return ID; } } -yy121: +yy130: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy122: +yy131: if (yych <= ' ') { - if (yych == '\t') goto yy121; - if (yych <= 0x1F) goto yy119; - goto yy121; + if (yych == '\t') goto yy130; + if (yych <= 0x1F) goto yy128; + goto yy130; } else { if (yych <= ',') { - if (yych <= '+') goto yy119; + if (yych <= '+') goto yy128; } else { - if (yych <= '<') goto yy119; - if (yych >= '?') goto yy119; + if (yych <= '<') goto yy128; + if (yych >= '?') goto yy128; } } yych = *++YYCURSOR; - goto yy118; -yy124: + goto yy127; +yy133: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; - if (yych != '2') goto yy113; + if (yych != '2') goto yy122; YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; - if (yych != 'c') goto yy113; + if (yych != 'c') goto yy122; YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; - if (yych != ':') goto yy113; + if (yych != ':') goto yy122; yych = *++YYCURSOR; if (yych <= '^') { - if (yych <= '@') goto yy114; - if (yych >= '[') goto yy114; + if (yych <= '@') goto yy123; + if (yych >= '[') goto yy123; } else { - if (yych == '`') goto yy114; - if (yych >= '{') goto yy114; + if (yych == '`') goto yy123; + if (yych >= '{') goto yy123; } -yy128: +yy137: yyaccept = 5; YYMARKER = ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '@') { if (yych <= '9') { - if (yych >= '0') goto yy128; + if (yych >= '0') goto yy137; } else { - if (yych <= ':') goto yy133; - if (yych >= '@') goto yy131; + if (yych <= ':') goto yy142; + if (yych >= '@') goto yy140; } } else { if (yych <= '_') { - if (yych <= 'Z') goto yy128; - if (yych >= '_') goto yy128; + if (yych <= 'Z') goto yy137; + if (yych >= '_') goto yy137; } else { - if (yych <= '`') goto yy130; - if (yych <= 'z') goto yy128; + if (yych <= '`') goto yy139; + if (yych <= 'z') goto yy137; } } -yy130: +yy139: { cur = cursor; tok+= 5; /* skip "re2c:" */ @@ -836,184 +873,184 @@ yy130: yylval.str = new Str(token()); return CONFIG; } -yy131: +yy140: yych = *++YYCURSOR; if (yych <= '^') { - if (yych <= '@') goto yy132; - if (yych <= 'Z') goto yy134; + if (yych <= '@') goto yy141; + if (yych <= 'Z') goto yy143; } else { - if (yych == '`') goto yy132; - if (yych <= 'z') goto yy134; + if (yych == '`') goto yy141; + if (yych <= 'z') goto yy143; } -yy132: +yy141: YYCURSOR = YYMARKER; if (yyaccept <= 3) { if (yyaccept <= 1) { if (yyaccept <= 0) { - goto yy82; + goto yy91; } else { - goto yy90; + goto yy99; } } else { if (yyaccept <= 2) { - goto yy92; + goto yy101; } else { - goto yy94; + goto yy103; } } } else { if (yyaccept <= 5) { if (yyaccept <= 4) { - goto yy86; + goto yy95; } else { - goto yy130; + goto yy139; } } else { - goto yy179; + goto yy188; } } -yy133: +yy142: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '^') { - if (yych <= '@') goto yy132; - if (yych <= 'Z') goto yy128; - goto yy132; + if (yych <= '@') goto yy141; + if (yych <= 'Z') goto yy137; + goto yy141; } else { - if (yych == '`') goto yy132; - if (yych <= 'z') goto yy128; - goto yy132; + if (yych == '`') goto yy141; + if (yych <= 'z') goto yy137; + goto yy141; } -yy134: +yy143: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= 'Z') { - if (yych <= '/') goto yy130; - if (yych <= '9') goto yy134; - if (yych <= '@') goto yy130; - goto yy134; + if (yych <= '/') goto yy139; + if (yych <= '9') goto yy143; + if (yych <= '@') goto yy139; + goto yy143; } else { if (yych <= '_') { - if (yych <= '^') goto yy130; - goto yy134; + if (yych <= '^') goto yy139; + goto yy143; } else { - if (yych <= '`') goto yy130; - if (yych <= 'z') goto yy134; - goto yy130; + if (yych <= '`') goto yy139; + if (yych <= 'z') goto yy143; + goto yy139; } } -yy136: +yy145: ++YYCURSOR; { RETURN(SETUP); } -yy138: +yy147: YYCTXMARKER = YYCURSOR + 1; yych = *++YYCURSOR; - goto yy140; -yy139: + goto yy149; +yy148: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; -yy140: +yy149: if (yych <= '9') { if (yych <= '\t') { - if (yych <= 0x08) goto yy132; - goto yy139; + if (yych <= 0x08) goto yy141; + goto yy148; } else { - if (yych == ' ') goto yy139; - goto yy132; + if (yych == ' ') goto yy148; + goto yy141; } } else { if (yych <= '=') { - if (yych <= ':') goto yy144; - if (yych <= '<') goto yy132; - goto yy143; + if (yych <= ':') goto yy153; + if (yych <= '<') goto yy141; + goto yy152; } else { - if (yych != '{') goto yy132; + if (yych != '{') goto yy141; } } -yy141: +yy150: ++YYCURSOR; YYCURSOR = YYCTXMARKER; { RETURN(NOCOND); } -yy143: +yy152: yych = *++YYCURSOR; - if (yych == '>') goto yy141; - goto yy132; -yy144: + if (yych == '>') goto yy150; + goto yy141; +yy153: yych = *++YYCURSOR; - if (yych == '=') goto yy141; - goto yy132; -yy145: + if (yych == '=') goto yy150; + goto yy141; +yy154: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy146: +yy155: if (yybm[0+yych] & 16) { - goto yy145; + goto yy154; } - if (yych <= '[') goto yy132; - if (yych <= '\\') goto yy149; - goto yy150; -yy147: + if (yych <= '[') goto yy141; + if (yych <= '\\') goto yy158; + goto yy159; +yy156: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '[') { - if (yych == '\n') goto yy132; - goto yy147; + if (yych == '\n') goto yy141; + goto yy156; } else { - if (yych <= '\\') goto yy152; - if (yych <= ']') goto yy153; - goto yy147; + if (yych <= '\\') goto yy161; + if (yych <= ']') goto yy162; + goto yy156; } -yy149: +yy158: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy132; - goto yy145; -yy150: + if (yych == '\n') goto yy141; + goto yy154; +yy159: ++YYCURSOR; { cur = cursor; yylval.regexp = ranToRE(token()); return RANGE; } -yy152: +yy161: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy132; - goto yy147; -yy153: + if (yych == '\n') goto yy141; + goto yy156; +yy162: ++YYCURSOR; { cur = cursor; yylval.regexp = invToRE(token()); return RANGE; } -yy155: +yy164: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy156: +yy165: if (yybm[0+yych] & 32) { - goto yy155; + goto yy164; } - if (yych <= '&') goto yy132; - if (yych <= '\'') goto yy158; + if (yych <= '&') goto yy141; + if (yych <= '\'') goto yy167; ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy132; - goto yy155; -yy158: + if (yych == '\n') goto yy141; + goto yy164; +yy167: ++YYCURSOR; { cur = cursor; @@ -1027,22 +1064,22 @@ yy158: } return STRING; } -yy160: +yy169: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy161: +yy170: if (yybm[0+yych] & 64) { - goto yy160; + goto yy169; } - if (yych <= '!') goto yy132; - if (yych <= '"') goto yy163; + if (yych <= '!') goto yy141; + if (yych <= '"') goto yy172; ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy132; - goto yy160; -yy163: + if (yych == '\n') goto yy141; + goto yy169; +yy172: ++YYCURSOR; { cur = cursor; @@ -1056,120 +1093,120 @@ yy163: } return STRING; } -yy165: +yy174: ++YYCURSOR; { tok = cursor; RETURN(0); } -yy167: +yy176: ++YYCURSOR; { depth = 1; goto comment; } -yy169: +yy178: ++YYCURSOR; - if ((yych = *YYCURSOR) == '>') goto yy171; + if ((yych = *YYCURSOR) == '>') goto yy180; { cur = cursor; tok+= 2; /* skip ":=" */ depth = 0; goto code; } -yy171: +yy180: ++YYCURSOR; YYCURSOR = YYCTXMARKER; { RETURN(*tok); } -yy173: +yy182: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '^') { if (yych <= '9') { - if (yych <= '/') goto yy132; - goto yy173; + if (yych <= '/') goto yy141; + goto yy182; } else { - if (yych <= '@') goto yy132; - if (yych <= 'Z') goto yy173; - goto yy132; + if (yych <= '@') goto yy141; + if (yych <= 'Z') goto yy182; + goto yy141; } } else { if (yych <= 'z') { - if (yych == '`') goto yy132; - goto yy173; + if (yych == '`') goto yy141; + goto yy182; } else { - if (yych == '}') goto yy192; - goto yy132; + if (yych == '}') goto yy201; + goto yy141; } } -yy175: +yy184: yych = *++YYCURSOR; - if (yych == ',') goto yy189; - goto yy177; -yy176: + if (yych == ',') goto yy198; + goto yy186; +yy185: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; -yy177: +yy186: if (yybm[0+yych] & 128) { - goto yy176; + goto yy185; } - if (yych == ',') goto yy182; - if (yych == '}') goto yy180; - goto yy132; -yy178: + if (yych == ',') goto yy191; + if (yych == '}') goto yy189; + goto yy141; +yy187: ++YYCURSOR; -yy179: +yy188: { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -yy180: +yy189: ++YYCURSOR; { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = atoi((char *)tok+1); RETURN(CLOSESIZE); } -yy182: +yy191: yyaccept = 6; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy179; - if (yych <= '9') goto yy185; - if (yych != '}') goto yy179; + if (yych <= '/') goto yy188; + if (yych <= '9') goto yy194; + if (yych != '}') goto yy188; ++YYCURSOR; { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = -1; RETURN(CLOSESIZE); } -yy185: +yy194: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych <= '/') goto yy132; - if (yych <= '9') goto yy185; - if (yych != '}') goto yy132; + if (yych <= '/') goto yy141; + if (yych <= '9') goto yy194; + if (yych != '}') goto yy141; ++YYCURSOR; { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); RETURN(CLOSESIZE); } -yy189: +yy198: yyaccept = 6; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy179; - if (yych <= '9') goto yy185; - if (yych != '}') goto yy179; + if (yych <= '/') goto yy188; + if (yych <= '9') goto yy194; + if (yych != '}') goto yy188; ++YYCURSOR; { yylval.op = '*'; RETURN(CLOSE); } -yy192: +yy201: ++YYCURSOR; { if (!FFlag) { @@ -1224,20 +1261,20 @@ code: yych = *YYCURSOR; if (yych <= '&') { if (yych <= '\n') { - if (yych <= 0x00) goto yy202; - if (yych <= '\t') goto yy204; - goto yy200; + if (yych <= 0x00) goto yy211; + if (yych <= '\t') goto yy213; + goto yy209; } else { - if (yych == '"') goto yy206; - goto yy204; + if (yych == '"') goto yy215; + goto yy213; } } else { if (yych <= '{') { - if (yych <= '\'') goto yy207; - if (yych <= 'z') goto yy204; - goto yy198; + if (yych <= '\'') goto yy216; + if (yych <= 'z') goto yy213; + goto yy207; } else { - if (yych != '}') goto yy204; + if (yych != '}') goto yy213; } } ++YYCURSOR; @@ -1254,7 +1291,7 @@ code: } goto code; } -yy198: +yy207: ++YYCURSOR; { if (depth == 0) @@ -1267,17 +1304,17 @@ yy198: } goto code; } -yy200: +yy209: YYCTXMARKER = YYCURSOR + 1; ++YYCURSOR; if ((yych = *YYCURSOR) <= '\f') { - if (yych <= 0x08) goto yy201; - if (yych <= '\n') goto yy215; + if (yych <= 0x08) goto yy210; + if (yych <= '\n') goto yy224; } else { - if (yych <= '\r') goto yy215; - if (yych == ' ') goto yy215; + if (yych <= '\r') goto yy224; + if (yych == ' ') goto yy224; } -yy201: +yy210: { if (depth == 0) { @@ -1298,7 +1335,7 @@ yy201: cline++; goto code; } -yy202: +yy211: ++YYCURSOR; { if (cursor == eof) @@ -1311,56 +1348,56 @@ yy202: } goto code; } -yy204: +yy213: ++YYCURSOR; -yy205: +yy214: { goto code; } -yy206: +yy215: yych = *(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy205; - goto yy213; -yy207: + if (yych == '\n') goto yy214; + goto yy222; +yy216: yych = *(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy205; - goto yy209; -yy208: + if (yych == '\n') goto yy214; + goto yy218; +yy217: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy209: +yy218: if (yybm[0+yych] & 64) { - goto yy208; + goto yy217; } - if (yych <= '&') goto yy210; - if (yych <= '\'') goto yy204; - goto yy211; -yy210: + if (yych <= '&') goto yy219; + if (yych <= '\'') goto yy213; + goto yy220; +yy219: YYCURSOR = YYMARKER; - goto yy205; -yy211: + goto yy214; +yy220: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy210; - goto yy208; -yy212: + if (yych == '\n') goto yy219; + goto yy217; +yy221: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy213: +yy222: if (yybm[0+yych] & 128) { - goto yy212; + goto yy221; } - if (yych <= '!') goto yy210; - if (yych <= '"') goto yy204; + if (yych <= '!') goto yy219; + if (yych <= '"') goto yy213; ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy210; - goto yy212; -yy215: + if (yych == '\n') goto yy219; + goto yy221; +yy224: ++YYCURSOR; YYCURSOR = YYCTXMARKER; { @@ -1386,17 +1423,17 @@ comment: if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= ')') { - if (yych == '\n') goto yy222; - goto yy224; + if (yych == '\n') goto yy231; + goto yy233; } else { - if (yych <= '*') goto yy219; - if (yych == '/') goto yy221; - goto yy224; + if (yych <= '*') goto yy228; + if (yych == '/') goto yy230; + goto yy233; } -yy219: +yy228: ++YYCURSOR; - if ((yych = *YYCURSOR) == '/') goto yy227; -yy220: + if ((yych = *YYCURSOR) == '/') goto yy236; +yy229: { if(cursor == eof) { @@ -1404,11 +1441,11 @@ yy220: } goto comment; } -yy221: +yy230: yych = *++YYCURSOR; - if (yych == '*') goto yy225; - goto yy220; -yy222: + if (yych == '*') goto yy234; + goto yy229; +yy231: ++YYCURSOR; { if(cursor == eof) @@ -1419,17 +1456,17 @@ yy222: cline++; goto comment; } -yy224: +yy233: yych = *++YYCURSOR; - goto yy220; -yy225: + goto yy229; +yy234: ++YYCURSOR; { ++depth; fatal("ambiguous /* found"); goto comment; } -yy227: +yy236: ++YYCURSOR; { if(--depth == 0) @@ -1485,52 +1522,52 @@ config: if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= 0x1F) { - if (yych != '\t') goto yy235; + if (yych != '\t') goto yy244; } else { - if (yych <= ' ') goto yy231; - if (yych == '=') goto yy233; - goto yy235; + if (yych <= ' ') goto yy240; + if (yych == '=') goto yy242; + goto yy244; } -yy231: +yy240: ++YYCURSOR; yych = *YYCURSOR; - goto yy240; -yy232: + goto yy249; +yy241: { goto config; } -yy233: +yy242: ++YYCURSOR; yych = *YYCURSOR; - goto yy238; -yy234: + goto yy247; +yy243: { iscfg = 2; cur = cursor; RETURN('='); } -yy235: +yy244: ++YYCURSOR; { fatal("missing '='"); } -yy237: +yy246: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy238: +yy247: if (yybm[0+yych] & 128) { - goto yy237; + goto yy246; } - goto yy234; -yy239: + goto yy243; +yy248: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy240: - if (yych == '\t') goto yy239; - if (yych == ' ') goto yy239; - goto yy232; +yy249: + if (yych == '\t') goto yy248; + if (yych == ' ') goto yy248; + goto yy241; } @@ -1576,191 +1613,191 @@ value: yych = *YYCURSOR; if (yych <= '&') { if (yych <= '\r') { - if (yych <= 0x08) goto yy249; - if (yych <= '\n') goto yy243; - if (yych <= '\f') goto yy249; + if (yych <= 0x08) goto yy258; + if (yych <= '\n') goto yy252; + if (yych <= '\f') goto yy258; } else { if (yych <= ' ') { - if (yych <= 0x1F) goto yy249; + if (yych <= 0x1F) goto yy258; } else { - if (yych == '"') goto yy251; - goto yy249; + if (yych == '"') goto yy260; + goto yy258; } } } else { if (yych <= '/') { - if (yych <= '\'') goto yy253; - if (yych == '-') goto yy246; - goto yy249; + if (yych <= '\'') goto yy262; + if (yych == '-') goto yy255; + goto yy258; } else { if (yych <= '9') { - if (yych <= '0') goto yy244; - goto yy247; + if (yych <= '0') goto yy253; + goto yy256; } else { - if (yych != ';') goto yy249; + if (yych != ';') goto yy258; } } } -yy243: +yy252: { cur = cursor; yylval.str = new Str(token()); iscfg = 0; return VALUE; } -yy244: +yy253: ++YYCURSOR; if (yybm[0+(yych = *YYCURSOR)] & 8) { - goto yy249; + goto yy258; } -yy245: +yy254: { cur = cursor; yylval.number = atoi(token().to_string().c_str()); iscfg = 0; return NUMBER; } -yy246: +yy255: yych = *++YYCURSOR; - if (yych <= '0') goto yy250; - if (yych >= ':') goto yy250; -yy247: + if (yych <= '0') goto yy259; + if (yych >= ':') goto yy259; +yy256: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 4) { - goto yy247; + goto yy256; } if (yych <= '\r') { - if (yych <= 0x08) goto yy249; - if (yych <= '\n') goto yy245; - if (yych >= '\r') goto yy245; + if (yych <= 0x08) goto yy258; + if (yych <= '\n') goto yy254; + if (yych >= '\r') goto yy254; } else { if (yych <= ' ') { - if (yych >= ' ') goto yy245; + if (yych >= ' ') goto yy254; } else { - if (yych == ';') goto yy245; + if (yych == ';') goto yy254; } } -yy249: +yy258: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy250: +yy259: if (yybm[0+yych] & 8) { - goto yy249; + goto yy258; } - goto yy243; -yy251: + goto yy252; +yy260: YYMARKER = ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 16) { - goto yy251; + goto yy260; } if (yych <= '!') { - if (yych == '\n') goto yy243; - goto yy261; + if (yych == '\n') goto yy252; + goto yy270; } else { - if (yych <= '"') goto yy249; - if (yych <= '[') goto yy261; - goto yy263; + if (yych <= '"') goto yy258; + if (yych <= '[') goto yy270; + goto yy272; } -yy253: +yy262: YYMARKER = ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 32) { - goto yy253; + goto yy262; } if (yych <= '&') { - if (yych == '\n') goto yy243; + if (yych == '\n') goto yy252; } else { - if (yych <= '\'') goto yy249; - if (yych >= '\\') goto yy258; + if (yych <= '\'') goto yy258; + if (yych >= '\\') goto yy267; } -yy255: +yy264: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 64) { - goto yy255; + goto yy264; } - if (yych <= '&') goto yy257; - if (yych <= '\'') goto yy259; - goto yy260; -yy257: + if (yych <= '&') goto yy266; + if (yych <= '\'') goto yy268; + goto yy269; +yy266: YYCURSOR = YYMARKER; - goto yy243; -yy258: + goto yy252; +yy267: YYMARKER = ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '\r') { if (yych <= '\t') { - if (yych <= 0x08) goto yy253; - goto yy255; + if (yych <= 0x08) goto yy262; + goto yy264; } else { - if (yych <= '\n') goto yy243; - if (yych <= '\f') goto yy253; - goto yy255; + if (yych <= '\n') goto yy252; + if (yych <= '\f') goto yy262; + goto yy264; } } else { if (yych <= ' ') { - if (yych <= 0x1F) goto yy253; - goto yy255; + if (yych <= 0x1F) goto yy262; + goto yy264; } else { - if (yych == ';') goto yy255; - goto yy253; + if (yych == ';') goto yy264; + goto yy262; } } -yy259: +yy268: yych = *++YYCURSOR; - goto yy243; -yy260: + goto yy252; +yy269: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy257; - goto yy255; -yy261: + if (yych == '\n') goto yy266; + goto yy264; +yy270: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 128) { - goto yy261; + goto yy270; } - if (yych <= '!') goto yy257; - if (yych <= '"') goto yy259; - goto yy264; -yy263: + if (yych <= '!') goto yy266; + if (yych <= '"') goto yy268; + goto yy273; +yy272: YYMARKER = ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '\r') { if (yych <= '\t') { - if (yych <= 0x08) goto yy251; - goto yy261; + if (yych <= 0x08) goto yy260; + goto yy270; } else { - if (yych <= '\n') goto yy243; - if (yych <= '\f') goto yy251; - goto yy261; + if (yych <= '\n') goto yy252; + if (yych <= '\f') goto yy260; + goto yy270; } } else { if (yych <= ' ') { - if (yych <= 0x1F) goto yy251; - goto yy261; + if (yych <= 0x1F) goto yy260; + goto yy270; } else { - if (yych == ';') goto yy261; - goto yy251; + if (yych == ';') goto yy270; + goto yy260; } } -yy264: +yy273: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if (yych == '\n') goto yy257; - goto yy261; + if (yych == '\n') goto yy266; + goto yy270; } } diff --git a/re2c/code.cc b/re2c/code.cc index ba8893a9..9882b244 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -1555,7 +1555,7 @@ void DFA::findBaseState() delete [] span; } -void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std::string& condName, bool isLastCond, bool& bPrologBrace) +void DFA::prepare() { State *s; uint i; @@ -1566,7 +1566,6 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std:: head->link = head; uint nRules = 0; - bool bProlog = (!cFlag || !bWroteCondCheck); for (s = head; s; s = s->next) { @@ -1582,11 +1581,11 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std:: } uint nSaves = 0; - uint *saves = new uint[nRules]; + saves = new uint[nRules]; memset(saves, ~0, (nRules)*sizeof(*saves)); // mark backtracking points - bool bSaveOnHead = false; + bSaveOnHead = false; for (s = head; s; s = s->next) { @@ -1612,7 +1611,7 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std:: } // insert actions - State **rules = new State * [nRules]; + rules = new State * [nRules]; memset(rules, 0, (nRules)*sizeof(*rules)); @@ -1692,6 +1691,12 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std:: delete head->action; head->action = NULL; +} + + +void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std::string& condName, bool isLastCond, bool& bPrologBrace) +{ + bool bProlog = (!cFlag || !bWroteCondCheck); if (!cFlag) { @@ -1710,6 +1715,8 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std:: } } + State *s; + for (s = head; s; s = s->next) { s->label = next_label++; @@ -1849,9 +1856,6 @@ void DFA::emit(std::ostream &o, uint& ind, const RegExpMap* specMap, const std:: BitMap::first = NULL; } - delete [] saves; - delete [] rules; - bUseStartLabel = false; } @@ -2163,12 +2167,25 @@ void Scanner::config(const Str& cfg, int num) { bUseYYSetStateNaked = num != 0; } + else if (cfg.to_string() == "flags:u") + { + if (!rFlag) + { + fatalf("cannot use configuration name '%s' without -r flag", cfg.to_string().c_str()); + } + uFlag = num != 0; + } + else if (cfg.to_string() == "flags:w") + { + if (!rFlag) + { + fatalf("cannot use configuration name '%s' without -r flag", cfg.to_string().c_str()); + } + wFlag = num != 0; + } else { - std::string msg = "unrecognized configuration name '"; - msg += cfg.to_string(); - msg += "' or illegal integer value"; - fatal(msg.c_str()); + fatalf("unrecognized configuration name '%s' or illegal integer value", cfg.to_string().c_str()); } } diff --git a/re2c/dfa.cc b/re2c/dfa.cc index 3c9813ea..7a8a2303 100644 --- a/re2c/dfa.cc +++ b/re2c/dfa.cc @@ -355,6 +355,8 @@ DFA::~DFA() } delete [] free_ins; delete [] free_rep; + delete [] saves; + delete [] rules; } void DFA::addState(State **a, State *s) diff --git a/re2c/dfa.h b/re2c/dfa.h index 500a297f..f2932cef 100644 --- a/re2c/dfa.h +++ b/re2c/dfa.h @@ -259,6 +259,11 @@ public: const Ins *free_ins; const Char *free_rep; +protected: + bool bSaveOnHead; + uint *saves; + State **rules; + public: DFA(Ins*, uint, uint, uint, const Char*); ~DFA(); @@ -268,6 +273,7 @@ public: void findSCCs(); void findBaseState(); + void prepare(); void emit(std::ostream&, uint&, const RegExpMap*, const std::string&, bool, bool&); friend std::ostream& operator<<(std::ostream&, const DFA&); diff --git a/re2c/htdocs/index.html b/re2c/htdocs/index.html index 8d913f3e..bdaa4ae2 100755 --- a/re2c/htdocs/index.html +++ b/re2c/htdocs/index.html @@ -83,6 +83,8 @@ fixes which were incorporated. 2008-??-??: 0.13.4
  • Added re2c:yyfill:check inplace configuration.
  • Added re2c:define:YYSETSTATE:naked inplace configuration.
  • +
  • Added re2c:flags:w and re2c:flags:u inplace configurations.
  • +
  • Changed -r flag to accept only 'rules:re2c' and 'use:re2c' blocks.

    2008-03-14: 0.13.3

    diff --git a/re2c/htdocs/manual.html b/re2c/htdocs/manual.html index bc273b39..69268d5c 100755 --- a/re2c/htdocs/manual.html +++ b/re2c/htdocs/manual.html @@ -128,9 +128,9 @@ to have re2c themselves when building from your source. -o output Specify the output file.

    -r
    Allows reuse of scanner definitions with '/*!repeat:re2c' after -'/*!re2c'. In this mode only one '/*!re2c' block, the last, -can contain rules. Its rules are being saved and reused by every -'/*!repeat:re2c' block that follows. These blocks can contain +'/*!rules:re2c'. In this mode no '/*!re2c' block and exactly one +'/*!use:re2c' must be present. The rules are being saved and used by +every '/*!repeat:re2c' block that follows. These blocks can contain inplace configurations. That way it is possible to create the same scanner multiple times for different character types, different input mechanisms or different output mechanisms. diff --git a/re2c/parser.y b/re2c/parser.y index f1606579..1b11bc4b 100644 --- a/re2c/parser.y +++ b/re2c/parser.y @@ -164,7 +164,7 @@ spec: { if (parseMode == Scanner::Reuse) { - in->fatal("Rules not allowed in 'repeat:re2c' block"); + in->fatal("rules not allowed in 'use:re2c' block"); } } | spec decl @@ -489,21 +489,22 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) o << " */\n"; o << sourceFileInfo; + bool uFlagOld = uFlag; + bool wFlagOld = wFlag; + uint nRealCharsOld = nRealChars; + while ((parseMode = i.echo()) != Scanner::Stop) { bool bPrologBrace = false; - if (rFlag && parseMode == Scanner::Parse && (dfa || dfa_map.size())) + if (rFlag && parseMode == Scanner::Rules && (dfa || dfa_map.size())) { - in->fatal("Cannot have another 're2c' block after a block containing rules"); + in->fatal("cannot have a second 'rules:re2c' block"); } - in->set_in_parse(true); - yyparse(); - in->set_in_parse(false); if (parseMode == Scanner::Reuse) { if (!dfa && dfa_map.empty()) { - in->fatal("Got 'repeat:re2c' without 're2c'"); + in->fatal("got 'use:re2c' without 'rules:re2c'"); } } else @@ -513,6 +514,30 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) delete dfa; dfa = NULL; } + dfa_map.clear(); + } + in->set_in_parse(true); + yyparse(); + in->set_in_parse(false); + if (rFlag) + { + uint nRealCharsLast = nRealChars; + if (uFlag) + { + nRealChars = 0x110000; /* 17 times w-Flag */ + } + else if (wFlag) + { + nRealChars = (1<<16); /* 0x10000 */ + } + else + { + nRealChars = (1<<8); /* 0x100 */ + } + if (nRealCharsLast != nRealChars) + { + /* Char width changed, so we need to regenerate the dfa. */ + } } if (cFlag) { @@ -580,7 +605,12 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) yySetupRule = ""; } } - dfa_map[it->first] = genCode(o, topIndent, it->second.second, &specMap, it->first, !--nCount, bPrologBrace); + dfa_map[it->first] = genCode(it->second.second); + dfa_map[it->first]->prepare(); + if (!rFlag) + { + dfa_map[it->first]->emit(o, topIndent, &specMap, it->first, !--nCount, bPrologBrace); + } } } if (!h && !bTypesDone) @@ -588,7 +618,7 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) genTypes(typesInline, 0, specMap); } } - else if (spec) + else if (spec || dfa) { if (parseMode == Scanner::Reuse) { @@ -596,15 +626,21 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) } else { - dfa = genCode(o, topIndent, spec, NULL, "", 0, bPrologBrace); + dfa = genCode(spec); + dfa->prepare(); if (!rFlag) { + dfa->emit(o, topIndent, NULL, "", 0, bPrologBrace); delete dfa; dfa = NULL; } } } o << sourceFileInfo; + /* restore original char handling mode*/ + uFlag = uFlagOld; + wFlag = wFlagOld; + nRealChars = nRealCharsOld; } if (cFlag) @@ -614,7 +650,7 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) { if (itRuleSetup->first != "*" && specMap.find(itRuleSetup->first) == specMap.end()) { - in->fatalf_at(itRuleSetup->second.first, "Setup for non existing rule '%s' found", itRuleSetup->first.c_str()); + in->fatalf_at(itRuleSetup->second.first, "setup for non existing rule '%s' found", itRuleSetup->first.c_str()); } } if (specMap.size() < ruleSetupMap.size()) @@ -625,7 +661,7 @@ void parse(Scanner& i, std::ostream& o, std::ostream* h) { line = itRuleSetup->second.first; } - in->fatalf_at(line, "Setup for all rules with '*' not possible when all rules are setup explicitly"); + in->fatalf_at(line, "setup for all rules with '*' not possible when all rules are setup explicitly"); } } diff --git a/re2c/re.h b/re2c/re.h index 81b7c99b..1d7e2051 100644 --- a/re2c/re.h +++ b/re2c/re.h @@ -501,7 +501,7 @@ typedef std::map SetupMap; class DFA; -extern DFA* genCode(std::ostream&, uint&, RegExp*, const RegExpMap*, const std::string&, bool, bool&); +extern DFA* genCode(RegExp*); extern void genGetStateGoto(std::ostream&, uint&, uint); extern void genCondTable(std::ostream&, uint, const RegExpMap&); extern void genCondGoto(std::ostream&, uint, const RegExpMap&); diff --git a/re2c/re2c.1.in b/re2c/re2c.1.in index c97c3bdc..4442138d 100644 --- a/re2c/re2c.1.in +++ b/re2c/re2c.1.in @@ -144,9 +144,9 @@ Specify the output file. .TP \fB-r\fP Allows reuse of scanner definitions with '\fB/*!repeat:re2c\fP' after -'\fB/*!re2c\fP'. In this mode only one '\fB/*!re2c\fP' block, the last, -can contain rules. Its rules are being saved and reused by every -'\fB/*!repeat:re2c\fP' block that follows. These blocks can contain +'\fB/*!rules:re2c\fP'. In this mode no '\fB/*!re2c\fP' block and exactly one +'\fB/*!rules:re2c\fP' must be present. The rules are being saved and used by +every '\fB/*!use:re2c\fP' block that follows. These blocks can contain inplace configurations. That way it is possible to create the same scanner multiple times for different character types, different input mechanisms or different output mechanisms. diff --git a/re2c/scanner.h b/re2c/scanner.h index 9a646e22..208416b3 100644 --- a/re2c/scanner.h +++ b/re2c/scanner.h @@ -33,7 +33,8 @@ public: enum ParseMode { Stop, Parse, - Reuse + Reuse, + Rules }; ParseMode echo(); diff --git a/re2c/scanner.re b/re2c/scanner.re index 29fc9b03..97419535 100644 --- a/re2c/scanner.re +++ b/re2c/scanner.re @@ -120,7 +120,7 @@ echo: "/*!re2c" { if (rFlag) { - mapCodeName.clear(); + fatal("found standard 're2c' block while using -r flag"); } if (bUsedYYMaxFill && bSinglePass) { @@ -133,10 +133,26 @@ echo: tok = cursor; RETURN(Parse); } - "/*!repeat:re2c" { + "/*!rules:re2c" { + if (rFlag) + { + mapCodeName.clear(); + } + else + { + fatal("found 'reules:re2c' block without -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + tok = cursor; + RETURN(Rules); + } + "/*!use:re2c" { if (!rFlag) { - fatal("Cannot reuse scanner definition without -r flag"); + fatal("found 'use:re2c' block without -r flag"); } next_label = 0; next_fill_index = 0; @@ -149,7 +165,7 @@ echo: } if (!DFlag) { - out.write((const char*)(tok), (const char*)(&cursor[-14]) - (const char*)(tok)); + out.write((const char*)(tok), (const char*)(&cursor[-11]) - (const char*)(tok)); } tok = cursor; RETURN(Reuse); diff --git a/re2c/test/cond_error_10.c.c b/re2c/test/cond_error_10.c.c index 9ffacd65..991803c6 100755 --- a/re2c/test/cond_error_10.c.c +++ b/re2c/test/cond_error_10.c.c @@ -1 +1 @@ -re2c: error: line 6, column 1: Setup for non existing rule 'c' found +re2c: error: line 6, column 1: setup for non existing rule 'c' found diff --git a/re2c/test/cond_error_11.c.c b/re2c/test/cond_error_11.c.c index 5909407d..cc33de71 100755 --- a/re2c/test/cond_error_11.c.c +++ b/re2c/test/cond_error_11.c.c @@ -1 +1 @@ -re2c: error: line 7, column 1: Setup for all rules with '*' not possible when all rules are setup explicitly +re2c: error: line 7, column 1: setup for all rules with '*' not possible when all rules are setup explicitly diff --git a/re2c/test/repeat-00.cgi.c b/re2c/test/repeat-00.cgi.c index 63a649cb..d042e907 100755 --- a/re2c/test/repeat-00.cgi.c +++ b/re2c/test/repeat-00.cgi.c @@ -1 +1 @@ -re2c: error: line 22, column 1: Cannot reuse scanner definition without -r flag +re2c: error: line 5, column 1: found 'reules:re2c' block without -r flag diff --git a/re2c/test/repeat-00.cgi.re b/re2c/test/repeat-00.cgi.re index ef171900..b84243d8 100755 --- a/re2c/test/repeat-00.cgi.re +++ b/re2c/test/repeat-00.cgi.re @@ -2,24 +2,29 @@ void scan(unsigned char* in) { -/*!re2c +/*!rules:re2c + +<*> "1" { return "1"; } +<*> "2" { return "2"; } + "a" { return "a"; } + "b" { return "b"; } +*/ + +/*!use:re2c re2c:define:YYCTYPE = 'unsigned char'; -<*> "1" { return "1"; } -<*> "2" { return "2"; } - "a" { return "a"; } - "b" { return "b"; } + */ } void scan(unsigned short* in) { -/*!repeat:re2c +/*!use:re2c @@ -31,7 +36,7 @@ void scan(unsigned short* in) void scan(unsigned int* in) { -/*!repeat:re2c +/*!use:re2c diff --git a/re2c/test/repeat-01.cgir.c b/re2c/test/repeat-01.cgir.c index a4059ac9..578f575f 100755 --- a/re2c/test/repeat-01.cgir.c +++ b/re2c/test/repeat-01.cgir.c @@ -38,19 +38,15 @@ yy3: { return "2"; } yy5: ++YYCURSOR; -yy6: { return "1"; } yy7: ++YYCURSOR; -yy8: { return "a"; } yy9: ++YYCURSOR; -yy10: { return "b"; } /* *********************************** */ yyc_r2: -yy12: if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '2') { @@ -63,11 +59,9 @@ yy12: yy13: yy14: ++YYCURSOR; -yy15: { return "2"; } yy16: ++YYCURSOR; -yy17: { return "1"; } yy18: ++YYCURSOR; @@ -89,77 +83,50 @@ void scan(unsigned short* in) /* *********************************** */ yyc_r1: - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '2') { if (yych <= '0') goto yy2; - if (yych <= '1') goto yy6; + if (yych <= '1') goto yy5; goto yy3; } else { if (yych <= '`') goto yy2; - if (yych <= 'a') goto yy9; - if (yych <= 'b') goto yy12; + if (yych <= 'a') goto yy7; + if (yych <= 'b') goto yy9; } yy2: yy3: - yych = *++YYCURSOR; - goto yy5; + ++YYCURSOR; { return "2"; } yy5: - { return "2"; } -yy6: - yych = *++YYCURSOR; - goto yy8; -yy7: - { return "1"; } -yy8: + ++YYCURSOR; { return "1"; } -yy9: - yych = *++YYCURSOR; - goto yy11; -yy10: - { return "a"; } -yy11: +yy7: + ++YYCURSOR; { return "a"; } -yy12: - yych = *++YYCURSOR; - goto yy14; -yy13: - { return "b"; } -yy14: +yy9: + ++YYCURSOR; { return "b"; } /* *********************************** */ yyc_r2: -yy16: - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '2') { - if (yych <= '0') goto yy17; - if (yych <= '1') goto yy21; - goto yy18; + if (yych <= '0') goto yy13; + if (yych <= '1') goto yy16; + goto yy14; } else { - if (yych == 'b') goto yy24; + if (yych == 'b') goto yy18; } -yy17: -yy18: - yych = *++YYCURSOR; - goto yy20; - { return "2"; } -yy20: +yy13: +yy14: + ++YYCURSOR; { return "2"; } -yy21: - yych = *++YYCURSOR; - goto yy23; -yy22: - { return "1"; } -yy23: +yy16: + ++YYCURSOR; { return "1"; } -yy24: - yych = *++YYCURSOR; - goto yy26; -yy25: - { return "b"; } -yy26: +yy18: + ++YYCURSOR; { return "b"; } } @@ -178,88 +145,50 @@ void scan(unsigned int* in) /* *********************************** */ yyc_r1: - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '2') { if (yych <= '0') goto yy2; - if (yych <= '1') goto yy7; + if (yych <= '1') goto yy5; goto yy3; } else { if (yych <= '`') goto yy2; - if (yych <= 'a') goto yy11; - if (yych <= 'b') goto yy15; + if (yych <= 'a') goto yy7; + if (yych <= 'b') goto yy9; } yy2: yy3: - yych = *++YYCURSOR; - goto yy6; + ++YYCURSOR; { return "2"; } yy5: - { return "2"; } -yy6: - { return "2"; } -yy7: - yych = *++YYCURSOR; - goto yy10; -yy8: - { return "1"; } -yy9: - { return "1"; } -yy10: + ++YYCURSOR; { return "1"; } -yy11: - yych = *++YYCURSOR; - goto yy14; -yy12: - { return "a"; } -yy13: - { return "a"; } -yy14: +yy7: + ++YYCURSOR; { return "a"; } -yy15: - yych = *++YYCURSOR; - goto yy18; -yy16: - { return "b"; } -yy17: - { return "b"; } -yy18: +yy9: + ++YYCURSOR; { return "b"; } /* *********************************** */ yyc_r2: -yy20: - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '2') { - if (yych <= '0') goto yy21; - if (yych <= '1') goto yy26; - goto yy22; + if (yych <= '0') goto yy13; + if (yych <= '1') goto yy16; + goto yy14; } else { - if (yych == 'b') goto yy30; + if (yych == 'b') goto yy18; } -yy21: -yy22: - yych = *++YYCURSOR; - goto yy25; -yy23: - { return "2"; } -yy24: - { return "2"; } -yy25: +yy13: +yy14: + ++YYCURSOR; { return "2"; } -yy26: - yych = *++YYCURSOR; - goto yy29; - { return "1"; } - { return "1"; } -yy29: +yy16: + ++YYCURSOR; { return "1"; } -yy30: - yych = *++YYCURSOR; - goto yy33; - { return "b"; } - { return "b"; } -yy33: +yy18: + ++YYCURSOR; { return "b"; } } diff --git a/re2c/test/repeat-01.cgir.re b/re2c/test/repeat-01.cgir.re index a858609e..92ead9aa 100755 --- a/re2c/test/repeat-01.cgir.re +++ b/re2c/test/repeat-01.cgir.re @@ -4,24 +4,27 @@ void scan(unsigned char* in) { -/*!re2c +/*!rules:re2c + +<*> "1" { return "1"; } +<*> "2" { return "2"; } + "a" { return "a"; } + "b" { return "b"; } +*//*!use:re2c re2c:define:YYCTYPE = 'unsigned char'; -<*> "1" { return "1"; } -<*> "2" { return "2"; } - "a" { return "a"; } - "b" { return "b"; } + */ } void scan(unsigned short* in) { -/*!repeat:re2c +/*!use:re2c @@ -33,7 +36,7 @@ void scan(unsigned short* in) void scan(unsigned int* in) { -/*!repeat:re2c +/*!use:re2c diff --git a/re2c/test/repeat-02.cgir.c b/re2c/test/repeat-02.cgir.c index e5050eb8..2523688a 100755 --- a/re2c/test/repeat-02.cgir.c +++ b/re2c/test/repeat-02.cgir.c @@ -38,19 +38,15 @@ yy3: { return "2"; } yy5: ++cursor1; -yy6: { return "1"; } yy7: ++cursor1; -yy8: { return "a"; } yy9: ++cursor1; -yy10: { return "b"; } /* *********************************** */ yyc_r2: -yy12: if (limit1 <= cursor1) fill1(1); yych = *cursor1; if (yych <= '2') { @@ -63,11 +59,9 @@ yy12: yy13: yy14: ++cursor1; -yy15: { return "2"; } yy16: ++cursor1; -yy17: { return "1"; } yy18: ++cursor1; @@ -89,77 +83,50 @@ void scan(unsigned short* in) /* *********************************** */ yyc_r1: - if ((limit2 - cursor2) < 2) fill2(2); + if (limit2 <= cursor2) fill2(1); yych = *cursor2; if (yych <= '2') { if (yych <= '0') goto yy2; - if (yych <= '1') goto yy6; + if (yych <= '1') goto yy5; goto yy3; } else { if (yych <= '`') goto yy2; - if (yych <= 'a') goto yy9; - if (yych <= 'b') goto yy12; + if (yych <= 'a') goto yy7; + if (yych <= 'b') goto yy9; } yy2: yy3: - yych = *++cursor2; - goto yy5; + ++cursor2; { return "2"; } yy5: - { return "2"; } -yy6: - yych = *++cursor2; - goto yy8; -yy7: - { return "1"; } -yy8: + ++cursor2; { return "1"; } -yy9: - yych = *++cursor2; - goto yy11; -yy10: - { return "a"; } -yy11: +yy7: + ++cursor2; { return "a"; } -yy12: - yych = *++cursor2; - goto yy14; -yy13: - { return "b"; } -yy14: +yy9: + ++cursor2; { return "b"; } /* *********************************** */ yyc_r2: -yy16: - if ((limit2 - cursor2) < 2) fill2(2); + if (limit2 <= cursor2) fill2(1); yych = *cursor2; if (yych <= '2') { - if (yych <= '0') goto yy17; - if (yych <= '1') goto yy21; - goto yy18; + if (yych <= '0') goto yy13; + if (yych <= '1') goto yy16; + goto yy14; } else { - if (yych == 'b') goto yy24; + if (yych == 'b') goto yy18; } -yy17: -yy18: - yych = *++cursor2; - goto yy20; - { return "2"; } -yy20: +yy13: +yy14: + ++cursor2; { return "2"; } -yy21: - yych = *++cursor2; - goto yy23; -yy22: - { return "1"; } -yy23: +yy16: + ++cursor2; { return "1"; } -yy24: - yych = *++cursor2; - goto yy26; -yy25: - { return "b"; } -yy26: +yy18: + ++cursor2; { return "b"; } } @@ -178,88 +145,50 @@ void scan(unsigned int* in) /* *********************************** */ yyc_r1: - if ((limit3 - cursor3) < 2) fill3(2); + if (limit3 <= cursor3) fill3(1); yych = *cursor3; if (yych <= '2') { if (yych <= '0') goto yy2; - if (yych <= '1') goto yy7; + if (yych <= '1') goto yy5; goto yy3; } else { if (yych <= '`') goto yy2; - if (yych <= 'a') goto yy11; - if (yych <= 'b') goto yy15; + if (yych <= 'a') goto yy7; + if (yych <= 'b') goto yy9; } yy2: yy3: - yych = *++cursor3; - goto yy6; + ++cursor3; { return "2"; } yy5: - { return "2"; } -yy6: - { return "2"; } -yy7: - yych = *++cursor3; - goto yy10; -yy8: - { return "1"; } -yy9: + ++cursor3; { return "1"; } -yy10: - { return "1"; } -yy11: - yych = *++cursor3; - goto yy14; -yy12: - { return "a"; } -yy13: - { return "a"; } -yy14: +yy7: + ++cursor3; { return "a"; } -yy15: - yych = *++cursor3; - goto yy18; -yy16: - { return "b"; } -yy17: - { return "b"; } -yy18: +yy9: + ++cursor3; { return "b"; } /* *********************************** */ yyc_r2: -yy20: - if ((limit3 - cursor3) < 2) fill3(2); + if (limit3 <= cursor3) fill3(1); yych = *cursor3; if (yych <= '2') { - if (yych <= '0') goto yy21; - if (yych <= '1') goto yy26; - goto yy22; + if (yych <= '0') goto yy13; + if (yych <= '1') goto yy16; + goto yy14; } else { - if (yych == 'b') goto yy30; + if (yych == 'b') goto yy18; } -yy21: -yy22: - yych = *++cursor3; - goto yy25; -yy23: - { return "2"; } -yy24: - { return "2"; } -yy25: +yy13: +yy14: + ++cursor3; { return "2"; } -yy26: - yych = *++cursor3; - goto yy29; - { return "1"; } - { return "1"; } -yy29: +yy16: + ++cursor3; { return "1"; } -yy30: - yych = *++cursor3; - goto yy33; - { return "b"; } - { return "b"; } -yy33: +yy18: + ++cursor3; { return "b"; } } diff --git a/re2c/test/repeat-02.cgir.re b/re2c/test/repeat-02.cgir.re index 23d159eb..5c0fe0c7 100755 --- a/re2c/test/repeat-02.cgir.re +++ b/re2c/test/repeat-02.cgir.re @@ -4,24 +4,25 @@ void scan(unsigned char* in) { -/*!re2c - -re2c:define:YYCTYPE = 'unsigned char'; -re2c:define:YYFILL = 'fill1'; -re2c:define:YYCURSOR = 'cursor1'; -re2c:define:YYLIMIT = 'limit1'; +/*!rules:re2c <*> "1" { return "1"; } <*> "2" { return "2"; } "a" { return "a"; } "b" { return "b"; } +*//*!use:re2c + +re2c:define:YYCTYPE = 'unsigned char'; +re2c:define:YYFILL = 'fill1'; +re2c:define:YYCURSOR = 'cursor1'; +re2c:define:YYLIMIT = 'limit1'; */ } void scan(unsigned short* in) { -/*!repeat:re2c +/*!use:re2c re2c:define:YYCTYPE = 'unsigned short'; re2c:define:YYFILL = 'fill2'; @@ -33,7 +34,7 @@ re2c:define:YYLIMIT = 'limit2'; void scan(unsigned int* in) { -/*!repeat:re2c +/*!use:re2c re2c:define:YYCTYPE = 'unsigned int'; re2c:define:YYFILL = 'fill3'; diff --git a/re2c/test/repeat-03.cgir.c b/re2c/test/repeat-03.cgir.c index 8fa88c2b..d0d66367 100755 --- a/re2c/test/repeat-03.cgir.c +++ b/re2c/test/repeat-03.cgir.c @@ -1 +1 @@ -re2c: error: line 21, column 10: Rules not allowed in 'repeat:re2c' block +re2c: error: line 21, column 10: rules not allowed in 'use:re2c' block diff --git a/re2c/test/repeat-03.cgir.re b/re2c/test/repeat-03.cgir.re index 80416eb4..d0595cd9 100755 --- a/re2c/test/repeat-03.cgir.re +++ b/re2c/test/repeat-03.cgir.re @@ -4,7 +4,7 @@ void scan(unsigned char* in) { -/*!re2c +/*!rules:re2c <*> "1" { return "1"; } <*> "2" { return "2"; } @@ -16,7 +16,7 @@ void scan(unsigned char* in) void scan(unsigned short* in) { -/*!repeat:re2c +/*!use:re2c "c" { return "c"; } diff --git a/re2c/test/repeat-04.cgir.c b/re2c/test/repeat-04.cgir.c index 56460c07..7812fb47 100755 --- a/re2c/test/repeat-04.cgir.c +++ b/re2c/test/repeat-04.cgir.c @@ -1 +1 @@ -re2c: error: line 20, column 1: Cannot have another 're2c' block after a block containing rules +re2c: error: line 20, column 1: cannot have a second 'rules:re2c' block diff --git a/re2c/test/repeat-04.cgir.re b/re2c/test/repeat-04.cgir.re index 3d53c4d4..6227a938 100755 --- a/re2c/test/repeat-04.cgir.re +++ b/re2c/test/repeat-04.cgir.re @@ -4,20 +4,20 @@ void scan(unsigned char* in) { -/*!re2c -re2c:define:YYCTYPE = 'unsigned char'; -*/ - -/*!re2c +/*!rules:re2c <*> "1" { return "1"; } <*> "2" { return "2"; } "a" { return "a"; } "b" { return "b"; } +*//*!use:re2c + +re2c:define:YYCTYPE = 'unsigned char'; + */ /* Next block is not possible */ -/*!re2c +/*!rules:re2c */ } \ No newline at end of file diff --git a/re2c/test/repeat-05.cgir.c b/re2c/test/repeat-05.cgir.c new file mode 100755 index 00000000..67f02944 --- /dev/null +++ b/re2c/test/repeat-05.cgir.c @@ -0,0 +1 @@ +re2c: error: line 7, column 1: found standard 're2c' block while using -r flag diff --git a/re2c/test/repeat-05.cgir.re b/re2c/test/repeat-05.cgir.re new file mode 100755 index 00000000..3f2d9f65 --- /dev/null +++ b/re2c/test/repeat-05.cgir.re @@ -0,0 +1,10 @@ +// multiple scanners, error + +/*!types:re2c */ + +void scan(unsigned char* in) +{ +/*!re2c re2c not allowed +*/ +} + \ No newline at end of file -- 2.40.0