From e67f99dbfec47c09a0037769f4b8acb136acc5fe Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sat, 2 Apr 2016 22:06:25 +0100 Subject: [PATCH] Lexer: minor code cleanup (check errors before doing anything else). --- re2c/bootstrap/src/parse/lex.cc | 499 ++++++++++++++++---------------- re2c/src/parse/lex.re | 21 +- 2 files changed, 259 insertions(+), 261 deletions(-) diff --git a/re2c/bootstrap/src/parse/lex.cc b/re2c/bootstrap/src/parse/lex.cc index 9354b434..2f2006e1 100644 --- a/re2c/bootstrap/src/parse/lex.cc +++ b/re2c/bootstrap/src/parse/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Sat Apr 2 18:46:12 2016 */ +/* Generated by re2c 0.16 on Sat Apr 2 22:03:43 2016 */ #line 1 "../src/parse/lex.re" #include "src/util/c99_stdint.h" #include @@ -114,7 +114,7 @@ echo: } } ++YYCURSOR; -#line 154 "../src/parse/lex.re" +#line 153 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start); @@ -127,7 +127,7 @@ echo: yy4: ++YYCURSOR; yy5: -#line 174 "../src/parse/lex.re" +#line 173 "../src/parse/lex.re" { goto echo; } #line 133 "src/parse/lex.cc" yy6: @@ -138,7 +138,7 @@ yy6: } if (yych == '#') goto yy14; yy7: -#line 168 "../src/parse/lex.re" +#line 167 "../src/parse/lex.re" { cline++; pos = cur; @@ -189,12 +189,12 @@ yy16: ++YYCURSOR; #line 76 "../src/parse/lex.re" { - if (opts->target == opt_t::CODE) { - out.wraw(tok, start); - } if (opts->rFlag) { fatal("found standard 're2c' block while using -r flag"); } + if (opts->target == opt_t::CODE) { + out.wraw(tok, start); + } return Parse; } #line 201 "src/parse/lex.cc" @@ -427,7 +427,7 @@ yy65: yy67: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 163 "../src/parse/lex.re" +#line 162 "../src/parse/lex.re" { set_sourceline(); goto echo; @@ -528,7 +528,7 @@ yy90: goto yy13; yy91: ++YYCURSOR; -#line 117 "../src/parse/lex.re" +#line 116 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start) @@ -548,14 +548,14 @@ yy94: goto yy13; yy95: ++YYCURSOR; -#line 98 "../src/parse/lex.re" +#line 97 "../src/parse/lex.re" { - if (opts->target == opt_t::CODE) { - out.wraw(tok, start); - } if (!opts->rFlag) { fatal("found 'use:re2c' block without -r flag"); } + if (opts->target == opt_t::CODE) { + out.wraw(tok, start); + } reuse(); return Reuse; } @@ -596,20 +596,19 @@ yy105: ++YYCURSOR; #line 86 "../src/parse/lex.re" { + if (!opts->rFlag) { + fatal("found 'rules:re2c' block without -r flag"); + } if (opts->target == opt_t::CODE) { out.wraw(tok, start); } - if (opts->rFlag) { - opts.reset_mapCodeName (); - } else { - fatal("found 'rules:re2c' block without -r flag"); - } + opts.reset_mapCodeName (); return Rules; } -#line 610 "src/parse/lex.cc" +#line 609 "src/parse/lex.cc" yy107: ++YYCURSOR; -#line 135 "../src/parse/lex.re" +#line 134 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start) @@ -620,7 +619,7 @@ yy107: lex_end_of_comment(); goto echo; } -#line 624 "src/parse/lex.cc" +#line 623 "src/parse/lex.cc" yy109: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy113; @@ -631,7 +630,7 @@ yy110: goto yy13; yy111: ++YYCURSOR; -#line 109 "../src/parse/lex.re" +#line 108 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start); @@ -639,7 +638,7 @@ yy111: lex_end_of_comment(); goto echo; } -#line 643 "src/parse/lex.cc" +#line 642 "src/parse/lex.cc" yy113: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy115; @@ -650,7 +649,7 @@ yy114: goto yy13; yy115: ++YYCURSOR; -#line 146 "../src/parse/lex.re" +#line 145 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start); @@ -658,10 +657,10 @@ yy115: lex_contexts(); goto echo; } -#line 662 "src/parse/lex.cc" +#line 661 "src/parse/lex.cc" yy117: ++YYCURSOR; -#line 126 "../src/parse/lex.re" +#line 125 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start) @@ -670,9 +669,9 @@ yy117: lex_end_of_comment(); goto echo; } -#line 674 "src/parse/lex.cc" +#line 673 "src/parse/lex.cc" } -#line 175 "../src/parse/lex.re" +#line 174 "../src/parse/lex.re" } @@ -680,7 +679,7 @@ void Scanner::lex_end_of_comment() { uint32_t ignored = 0; for (;;) { -#line 684 "src/parse/lex.cc" +#line 683 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -696,20 +695,20 @@ void Scanner::lex_end_of_comment() } yy121: ++YYCURSOR; -#line 182 "../src/parse/lex.re" +#line 181 "../src/parse/lex.re" { fatal("expected end of block"); } -#line 702 "src/parse/lex.cc" +#line 701 "src/parse/lex.cc" yy123: ++YYCURSOR; yy124: -#line 184 "../src/parse/lex.re" +#line 183 "../src/parse/lex.re" { continue; } -#line 708 "src/parse/lex.cc" +#line 707 "src/parse/lex.cc" yy125: ++YYCURSOR; -#line 185 "../src/parse/lex.re" +#line 184 "../src/parse/lex.re" { ++ignored; continue; } -#line 713 "src/parse/lex.cc" +#line 712 "src/parse/lex.cc" yy127: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy125; @@ -718,7 +717,7 @@ yy128: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy124; ++YYCURSOR; -#line 186 "../src/parse/lex.re" +#line 185 "../src/parse/lex.re" { if (ignored > 0) { cline += ignored; @@ -727,9 +726,9 @@ yy128: tok = pos = cur; return; } -#line 731 "src/parse/lex.cc" +#line 730 "src/parse/lex.cc" } -#line 194 "../src/parse/lex.re" +#line 193 "../src/parse/lex.re" } } @@ -737,7 +736,7 @@ void Scanner::lex_contexts() { ConfContexts conf; for (;;) { -#line 741 "src/parse/lex.cc" +#line 740 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -795,9 +794,9 @@ void Scanner::lex_contexts() } ++YYCURSOR; yy134: -#line 201 "../src/parse/lex.re" +#line 200 "../src/parse/lex.re" { fatal("unrecognized configuration"); } -#line 801 "src/parse/lex.cc" +#line 800 "src/parse/lex.cc" yy135: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -805,14 +804,14 @@ yy135: if (yybm[0+yych] & 128) { goto yy135; } -#line 206 "../src/parse/lex.re" +#line 205 "../src/parse/lex.re" { continue; } -#line 811 "src/parse/lex.cc" +#line 810 "src/parse/lex.cc" yy138: ++YYCURSOR; -#line 207 "../src/parse/lex.re" +#line 206 "../src/parse/lex.re" { ++cline; continue; } -#line 816 "src/parse/lex.cc" +#line 815 "src/parse/lex.cc" yy140: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy138; @@ -831,7 +830,7 @@ yy143: goto yy134; yy144: ++YYCURSOR; -#line 208 "../src/parse/lex.re" +#line 207 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wdelay_contexts(opts->topIndent, @@ -840,7 +839,7 @@ yy144: tok = pos = cur; return; } -#line 844 "src/parse/lex.cc" +#line 843 "src/parse/lex.cc" yy146: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy149; @@ -857,16 +856,16 @@ yy149: goto yy147; yy150: ++YYCURSOR; -#line 204 "../src/parse/lex.re" +#line 203 "../src/parse/lex.re" { conf.sep = lex_conf_string(); continue; } -#line 863 "src/parse/lex.cc" +#line 862 "src/parse/lex.cc" yy152: ++YYCURSOR; -#line 203 "../src/parse/lex.re" +#line 202 "../src/parse/lex.re" { conf.line = lex_conf_string(); continue; } -#line 868 "src/parse/lex.cc" +#line 867 "src/parse/lex.cc" } -#line 216 "../src/parse/lex.re" +#line 215 "../src/parse/lex.re" } } @@ -886,7 +885,7 @@ scan: start: -#line 890 "src/parse/lex.cc" +#line 889 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -992,12 +991,12 @@ start: yy156: ++YYCURSOR; yy157: -#line 394 "../src/parse/lex.re" +#line 393 "../src/parse/lex.re" { fatalf("unexpected character: '%c'", *tok); goto scan; } -#line 1001 "src/parse/lex.cc" +#line 1000 "src/parse/lex.cc" yy158: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1005,11 +1004,11 @@ yy158: if (yybm[0+yych] & 16) { goto yy158; } -#line 378 "../src/parse/lex.re" +#line 377 "../src/parse/lex.re" { goto scan; } -#line 1013 "src/parse/lex.cc" +#line 1012 "src/parse/lex.cc" yy161: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1020,65 +1019,65 @@ yy161: if (yych == '#') goto yy190; } yy162: -#line 387 "../src/parse/lex.re" +#line 386 "../src/parse/lex.re" { if (cur == eof) return 0; pos = cur; cline++; goto scan; } -#line 1031 "src/parse/lex.cc" +#line 1030 "src/parse/lex.cc" yy163: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy161; goto yy157; yy164: ++YYCURSOR; -#line 265 "../src/parse/lex.re" +#line 264 "../src/parse/lex.re" { yylval.regexp = lex_str('"', opts->bCaseInsensitive || opts->bCaseInverted); return TOKEN_REGEXP; } -#line 1040 "src/parse/lex.cc" +#line 1039 "src/parse/lex.cc" yy166: yych = (YYCTYPE)*++YYCURSOR; if (yych == '}') goto yy192; goto yy157; yy167: ++YYCURSOR; -#line 264 "../src/parse/lex.re" +#line 263 "../src/parse/lex.re" { yylval.regexp = lex_str('\'', opts->bCaseInsensitive || !opts->bCaseInverted); return TOKEN_REGEXP; } -#line 1049 "src/parse/lex.cc" +#line 1048 "src/parse/lex.cc" yy169: ++YYCURSOR; yy170: -#line 281 "../src/parse/lex.re" +#line 280 "../src/parse/lex.re" { return *tok; } -#line 1057 "src/parse/lex.cc" +#line 1056 "src/parse/lex.cc" yy171: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '/') goto yy192; -#line 285 "../src/parse/lex.re" +#line 284 "../src/parse/lex.re" { yylval.op = *tok; return TOKEN_STAR; } -#line 1066 "src/parse/lex.cc" +#line 1065 "src/parse/lex.cc" yy173: ++YYCURSOR; -#line 289 "../src/parse/lex.re" +#line 288 "../src/parse/lex.re" { yylval.op = *tok; return TOKEN_CLOSE; } -#line 1074 "src/parse/lex.cc" +#line 1073 "src/parse/lex.cc" yy175: ++YYCURSOR; -#line 373 "../src/parse/lex.re" +#line 372 "../src/parse/lex.re" { yylval.regexp = mkDot(); return TOKEN_REGEXP; } -#line 1082 "src/parse/lex.cc" +#line 1081 "src/parse/lex.cc" yy177: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy194; @@ -1118,9 +1117,9 @@ yy181: yy182: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '^') goto yy213; -#line 266 "../src/parse/lex.re" +#line 265 "../src/parse/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1124 "src/parse/lex.cc" +#line 1123 "src/parse/lex.cc" yy184: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -1144,12 +1143,12 @@ yy185: } } yy186: -#line 235 "../src/parse/lex.re" +#line 234 "../src/parse/lex.re" { depth = 1; goto code; } -#line 1153 "src/parse/lex.cc" +#line 1152 "src/parse/lex.cc" yy187: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1189,31 +1188,31 @@ yy190: } yy192: ++YYCURSOR; -#line 259 "../src/parse/lex.re" +#line 258 "../src/parse/lex.re" { tok = cur; return 0; } -#line 1198 "src/parse/lex.cc" +#line 1197 "src/parse/lex.cc" yy194: ++YYCURSOR; -#line 253 "../src/parse/lex.re" +#line 252 "../src/parse/lex.re" { depth = 1; goto comment; } -#line 1206 "src/parse/lex.cc" +#line 1205 "src/parse/lex.cc" yy196: ++YYCURSOR; -#line 250 "../src/parse/lex.re" +#line 249 "../src/parse/lex.re" { goto nextLine; } -#line 1213 "src/parse/lex.cc" +#line 1212 "src/parse/lex.cc" yy198: ++YYCURSOR; YYCURSOR -= 1; -#line 357 "../src/parse/lex.re" +#line 356 "../src/parse/lex.re" { if (!opts->FFlag) { yylval.str = new std::string (tok, tok_len()); @@ -1229,19 +1228,19 @@ yy198: return TOKEN_REGEXP; } } -#line 1233 "src/parse/lex.cc" +#line 1232 "src/parse/lex.cc" yy200: yych = (YYCTYPE)*++YYCURSOR; goto yy226; yy201: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 352 "../src/parse/lex.re" +#line 351 "../src/parse/lex.re" { yylval.str = new std::string (tok, tok_len ()); return TOKEN_ID; } -#line 1245 "src/parse/lex.cc" +#line 1244 "src/parse/lex.cc" yy203: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1268,20 +1267,20 @@ yy204: yy205: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '>') goto yy227; -#line 244 "../src/parse/lex.re" +#line 243 "../src/parse/lex.re" { tok += 2; /* skip ":=" */ depth = 0; goto code; } -#line 1278 "src/parse/lex.cc" +#line 1277 "src/parse/lex.cc" yy207: ++YYCURSOR; -#line 272 "../src/parse/lex.re" +#line 271 "../src/parse/lex.re" { return TOKEN_SETUP; } -#line 1285 "src/parse/lex.cc" +#line 1284 "src/parse/lex.cc" yy209: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -1303,17 +1302,17 @@ yy210: } } yy212: -#line 276 "../src/parse/lex.re" +#line 275 "../src/parse/lex.re" { yylval.str = new std::string(tok + 1, tok_len() - 1); return TOKEN_CTX; } -#line 1312 "src/parse/lex.cc" +#line 1311 "src/parse/lex.cc" yy213: ++YYCURSOR; -#line 267 "../src/parse/lex.re" +#line 266 "../src/parse/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1317 "src/parse/lex.cc" +#line 1316 "src/parse/lex.cc" yy215: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -1322,11 +1321,11 @@ yy215: yy216: ++YYCURSOR; yy217: -#line 325 "../src/parse/lex.re" +#line 324 "../src/parse/lex.re" { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 1330 "src/parse/lex.cc" +#line 1329 "src/parse/lex.cc" yy218: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1379,7 +1378,7 @@ yy222: yy223: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 339 "../src/parse/lex.re" +#line 338 "../src/parse/lex.re" { yylval.str = new std::string (tok, tok_len ()); if (opts->FFlag) @@ -1392,7 +1391,7 @@ yy223: return TOKEN_ID; } } -#line 1396 "src/parse/lex.cc" +#line 1395 "src/parse/lex.cc" yy225: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1415,11 +1414,11 @@ yy226: yy227: ++YYCURSOR; YYCURSOR -= 2; -#line 240 "../src/parse/lex.re" +#line 239 "../src/parse/lex.re" { return *tok; } -#line 1423 "src/parse/lex.cc" +#line 1422 "src/parse/lex.cc" yy229: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1453,11 +1452,11 @@ yy232: yy233: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 269 "../src/parse/lex.re" +#line 268 "../src/parse/lex.re" { return TOKEN_NOCOND; } -#line 1461 "src/parse/lex.cc" +#line 1460 "src/parse/lex.cc" yy235: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -1472,7 +1471,7 @@ yy236: goto yy217; yy237: ++YYCURSOR; -#line 294 "../src/parse/lex.re" +#line 293 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.extop.min)) { @@ -1481,10 +1480,10 @@ yy237: yylval.extop.max = yylval.extop.min; return TOKEN_CLOSESIZE; } -#line 1485 "src/parse/lex.cc" +#line 1484 "src/parse/lex.cc" yy239: ++YYCURSOR; -#line 329 "../src/parse/lex.re" +#line 328 "../src/parse/lex.re" { if (!opts->FFlag) { fatal("curly braces for names only allowed with -F switch"); @@ -1492,7 +1491,7 @@ yy239: yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return TOKEN_ID; } -#line 1496 "src/parse/lex.cc" +#line 1495 "src/parse/lex.cc" yy241: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy247; @@ -1512,7 +1511,7 @@ yy243: goto yy189; yy245: ++YYCURSOR; -#line 316 "../src/parse/lex.re" +#line 315 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.extop.min)) { @@ -1521,19 +1520,19 @@ yy245: yylval.extop.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1525 "src/parse/lex.cc" +#line 1524 "src/parse/lex.cc" yy247: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy252; goto yy189; yy248: ++YYCURSOR; -#line 337 "../src/parse/lex.re" +#line 336 "../src/parse/lex.re" { lex_conf (); return TOKEN_CONF; } -#line 1534 "src/parse/lex.cc" +#line 1533 "src/parse/lex.cc" yy250: ++YYCURSOR; -#line 303 "../src/parse/lex.re" +#line 302 "../src/parse/lex.re" { const char * p = strchr (tok, ','); if (!s_to_u32_unsafe (tok + 1, p, yylval.extop.min)) @@ -1546,7 +1545,7 @@ yy250: } return TOKEN_CLOSESIZE; } -#line 1550 "src/parse/lex.cc" +#line 1549 "src/parse/lex.cc" yy252: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy254; @@ -1602,12 +1601,12 @@ yy257: yy259: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 382 "../src/parse/lex.re" +#line 381 "../src/parse/lex.re" { set_sourceline (); goto scan; } -#line 1611 "src/parse/lex.cc" +#line 1610 "src/parse/lex.cc" yy261: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy259; @@ -1632,12 +1631,12 @@ yy265: if (yych == '\n') goto yy189; goto yy262; } -#line 398 "../src/parse/lex.re" +#line 397 "../src/parse/lex.re" flex_name: -#line 1641 "src/parse/lex.cc" +#line 1640 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1646,32 +1645,32 @@ flex_name: if (yych == '\r') goto yy272; ++YYCURSOR; yy269: -#line 409 "../src/parse/lex.re" +#line 408 "../src/parse/lex.re" { YYCURSOR = tok; goto start; } -#line 1655 "src/parse/lex.cc" +#line 1654 "src/parse/lex.cc" yy270: ++YYCURSOR; -#line 403 "../src/parse/lex.re" +#line 402 "../src/parse/lex.re" { YYCURSOR = tok; lexer_state = LEX_NORMAL; return TOKEN_FID_END; } -#line 1664 "src/parse/lex.cc" +#line 1663 "src/parse/lex.cc" yy272: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '\n') goto yy270; goto yy269; } -#line 413 "../src/parse/lex.re" +#line 412 "../src/parse/lex.re" code: -#line 1675 "src/parse/lex.cc" +#line 1674 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1732,7 +1731,7 @@ code: } yy275: ++YYCURSOR; -#line 476 "../src/parse/lex.re" +#line 475 "../src/parse/lex.re" { if (cur == eof) { @@ -1744,15 +1743,15 @@ yy275: } goto code; } -#line 1748 "src/parse/lex.cc" +#line 1747 "src/parse/lex.cc" yy277: ++YYCURSOR; yy278: -#line 490 "../src/parse/lex.re" +#line 489 "../src/parse/lex.re" { goto code; } -#line 1756 "src/parse/lex.cc" +#line 1755 "src/parse/lex.cc" yy279: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1771,7 +1770,7 @@ yy279: } } yy280: -#line 457 "../src/parse/lex.re" +#line 456 "../src/parse/lex.re" { if (depth == 0) { @@ -1791,7 +1790,7 @@ yy280: cline++; goto code; } -#line 1795 "src/parse/lex.cc" +#line 1794 "src/parse/lex.cc" yy281: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1804,7 +1803,7 @@ yy282: goto yy299; yy283: ++YYCURSOR; -#line 429 "../src/parse/lex.re" +#line 428 "../src/parse/lex.re" { if (depth == 0) { @@ -1816,10 +1815,10 @@ yy283: } goto code; } -#line 1820 "src/parse/lex.cc" +#line 1819 "src/parse/lex.cc" yy285: ++YYCURSOR; -#line 417 "../src/parse/lex.re" +#line 416 "../src/parse/lex.re" { if (depth == 0) { @@ -1832,7 +1831,7 @@ yy285: } goto code; } -#line 1836 "src/parse/lex.cc" +#line 1835 "src/parse/lex.cc" yy287: yyaccept = 2; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1844,7 +1843,7 @@ yy287: } yy288: YYCURSOR -= 1; -#line 444 "../src/parse/lex.re" +#line 443 "../src/parse/lex.re" { if (depth == 0) { @@ -1858,7 +1857,7 @@ yy288: cline++; goto code; } -#line 1862 "src/parse/lex.cc" +#line 1861 "src/parse/lex.cc" yy289: yych = (YYCTYPE)*++YYCURSOR; goto yy288; @@ -1893,11 +1892,11 @@ yy294: if (yych >= '#') goto yy297; yy295: ++YYCURSOR; -#line 487 "../src/parse/lex.re" +#line 486 "../src/parse/lex.re" { goto code; } -#line 1901 "src/parse/lex.cc" +#line 1900 "src/parse/lex.cc" yy297: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1987,12 +1986,12 @@ yy311: yy313: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 440 "../src/parse/lex.re" +#line 439 "../src/parse/lex.re" { set_sourceline (); goto code; } -#line 1996 "src/parse/lex.cc" +#line 1995 "src/parse/lex.cc" yy315: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy313; @@ -2021,12 +2020,12 @@ yy319: if (yych == '\n') goto yy292; goto yy316; } -#line 493 "../src/parse/lex.re" +#line 492 "../src/parse/lex.re" comment: -#line 2030 "src/parse/lex.cc" +#line 2029 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2073,7 +2072,7 @@ comment: } ++YYCURSOR; yy323: -#line 525 "../src/parse/lex.re" +#line 524 "../src/parse/lex.re" { if (cur == eof) { @@ -2081,7 +2080,7 @@ yy323: } goto comment; } -#line 2085 "src/parse/lex.cc" +#line 2084 "src/parse/lex.cc" yy324: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -2089,7 +2088,7 @@ yy324: } if (yych == '#') goto yy331; yy325: -#line 516 "../src/parse/lex.re" +#line 515 "../src/parse/lex.re" { if (cur == eof) { @@ -2099,7 +2098,7 @@ yy325: cline++; goto comment; } -#line 2103 "src/parse/lex.cc" +#line 2102 "src/parse/lex.cc" yy326: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy333; @@ -2133,7 +2132,7 @@ yy331: } yy333: ++YYCURSOR; -#line 497 "../src/parse/lex.re" +#line 496 "../src/parse/lex.re" { if (--depth == 0) { @@ -2144,16 +2143,16 @@ yy333: goto comment; } } -#line 2148 "src/parse/lex.cc" +#line 2147 "src/parse/lex.cc" yy335: ++YYCURSOR; -#line 507 "../src/parse/lex.re" +#line 506 "../src/parse/lex.re" { ++depth; fatal("ambiguous /* found"); goto comment; } -#line 2157 "src/parse/lex.cc" +#line 2156 "src/parse/lex.cc" yy337: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'i') goto yy330; @@ -2210,12 +2209,12 @@ yy345: yy347: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 512 "../src/parse/lex.re" +#line 511 "../src/parse/lex.re" { set_sourceline (); goto comment; } -#line 2219 "src/parse/lex.cc" +#line 2218 "src/parse/lex.cc" yy349: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy347; @@ -2240,28 +2239,28 @@ yy353: if (yych == '\n') goto yy330; goto yy350; } -#line 532 "../src/parse/lex.re" +#line 531 "../src/parse/lex.re" nextLine: -#line 2249 "src/parse/lex.cc" +#line 2248 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\n') goto yy358; ++YYCURSOR; -#line 543 "../src/parse/lex.re" +#line 542 "../src/parse/lex.re" { if(cur == eof) { return 0; } goto nextLine; } -#line 2262 "src/parse/lex.cc" +#line 2261 "src/parse/lex.cc" yy358: ++YYCURSOR; -#line 536 "../src/parse/lex.re" +#line 535 "../src/parse/lex.re" { if(cur == eof) { return 0; } @@ -2269,9 +2268,9 @@ yy358: cline++; goto scan; } -#line 2273 "src/parse/lex.cc" +#line 2272 "src/parse/lex.cc" } -#line 548 "../src/parse/lex.re" +#line 547 "../src/parse/lex.re" } @@ -2295,35 +2294,35 @@ const RegExp *Scanner::lex_cls(bool neg) uint32_t u, l; fst: -#line 2299 "src/parse/lex.cc" +#line 2298 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy363; -#line 572 "../src/parse/lex.re" +#line 571 "../src/parse/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2307 "src/parse/lex.cc" +#line 2306 "src/parse/lex.cc" yy363: ++YYCURSOR; -#line 571 "../src/parse/lex.re" +#line 570 "../src/parse/lex.re" { goto end; } -#line 2312 "src/parse/lex.cc" +#line 2311 "src/parse/lex.cc" } -#line 573 "../src/parse/lex.re" +#line 572 "../src/parse/lex.re" snd: -#line 2318 "src/parse/lex.cc" +#line 2317 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy368; yy367: -#line 576 "../src/parse/lex.re" +#line 575 "../src/parse/lex.re" { u = l; goto add; } -#line 2327 "src/parse/lex.cc" +#line 2326 "src/parse/lex.cc" yy368: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy370; @@ -2332,7 +2331,7 @@ yy368: yy370: ++YYCURSOR; YYCURSOR -= 1; -#line 577 "../src/parse/lex.re" +#line 576 "../src/parse/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2341,9 +2340,9 @@ yy370: } goto add; } -#line 2345 "src/parse/lex.cc" +#line 2344 "src/parse/lex.cc" } -#line 585 "../src/parse/lex.re" +#line 584 "../src/parse/lex.re" add: if (!(s = opts->encoding.encodeRange(l, u))) { @@ -2362,7 +2361,7 @@ uint32_t Scanner::lex_cls_chr() { tok = cur; -#line 2366 "src/parse/lex.cc" +#line 2365 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2371,14 +2370,14 @@ uint32_t Scanner::lex_cls_chr() if (yych == '\n') goto yy376; if (yych == '\\') goto yy378; ++YYCURSOR; -#line 608 "../src/parse/lex.re" +#line 607 "../src/parse/lex.re" { return static_cast(tok[0]); } -#line 2377 "src/parse/lex.cc" +#line 2376 "src/parse/lex.cc" yy376: ++YYCURSOR; -#line 603 "../src/parse/lex.re" +#line 602 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 2382 "src/parse/lex.cc" +#line 2381 "src/parse/lex.cc" yy378: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) <= '`') { @@ -2427,31 +2426,31 @@ yy378: } } } -#line 606 "../src/parse/lex.re" +#line 605 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 2433 "src/parse/lex.cc" +#line 2432 "src/parse/lex.cc" yy380: ++YYCURSOR; -#line 621 "../src/parse/lex.re" +#line 620 "../src/parse/lex.re" { warn.useless_escape(tline, tok - pos, tok[1]); return static_cast(tok[1]); } -#line 2441 "src/parse/lex.cc" +#line 2440 "src/parse/lex.cc" yy382: ++YYCURSOR; -#line 619 "../src/parse/lex.re" +#line 618 "../src/parse/lex.re" { return static_cast('-'); } -#line 2446 "src/parse/lex.cc" +#line 2445 "src/parse/lex.cc" yy384: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy385; if (yych <= '7') goto yy409; yy385: -#line 605 "../src/parse/lex.re" +#line 604 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 2455 "src/parse/lex.cc" +#line 2454 "src/parse/lex.cc" yy386: yych = (YYCTYPE)*++YYCURSOR; goto yy385; @@ -2467,9 +2466,9 @@ yy387: if (yych <= 'f') goto yy411; } yy388: -#line 604 "../src/parse/lex.re" +#line 603 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 2473 "src/parse/lex.cc" +#line 2472 "src/parse/lex.cc" yy389: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2485,49 +2484,49 @@ yy389: } yy390: ++YYCURSOR; -#line 618 "../src/parse/lex.re" +#line 617 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2491 "src/parse/lex.cc" +#line 2490 "src/parse/lex.cc" yy392: ++YYCURSOR; -#line 620 "../src/parse/lex.re" +#line 619 "../src/parse/lex.re" { return static_cast(']'); } -#line 2496 "src/parse/lex.cc" +#line 2495 "src/parse/lex.cc" yy394: ++YYCURSOR; -#line 611 "../src/parse/lex.re" +#line 610 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2501 "src/parse/lex.cc" +#line 2500 "src/parse/lex.cc" yy396: ++YYCURSOR; -#line 612 "../src/parse/lex.re" +#line 611 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2506 "src/parse/lex.cc" +#line 2505 "src/parse/lex.cc" yy398: ++YYCURSOR; -#line 613 "../src/parse/lex.re" +#line 612 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2511 "src/parse/lex.cc" +#line 2510 "src/parse/lex.cc" yy400: ++YYCURSOR; -#line 614 "../src/parse/lex.re" +#line 613 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2516 "src/parse/lex.cc" +#line 2515 "src/parse/lex.cc" yy402: ++YYCURSOR; -#line 615 "../src/parse/lex.re" +#line 614 "../src/parse/lex.re" { return static_cast('\r'); } -#line 2521 "src/parse/lex.cc" +#line 2520 "src/parse/lex.cc" yy404: ++YYCURSOR; -#line 616 "../src/parse/lex.re" +#line 615 "../src/parse/lex.re" { return static_cast('\t'); } -#line 2526 "src/parse/lex.cc" +#line 2525 "src/parse/lex.cc" yy406: ++YYCURSOR; -#line 617 "../src/parse/lex.re" +#line 616 "../src/parse/lex.re" { return static_cast('\v'); } -#line 2531 "src/parse/lex.cc" +#line 2530 "src/parse/lex.cc" yy408: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2590,9 +2589,9 @@ yy413: } yy414: ++YYCURSOR; -#line 610 "../src/parse/lex.re" +#line 609 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 2596 "src/parse/lex.cc" +#line 2595 "src/parse/lex.cc" yy416: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2619,9 +2618,9 @@ yy417: } yy418: ++YYCURSOR; -#line 609 "../src/parse/lex.re" +#line 608 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 2625 "src/parse/lex.cc" +#line 2624 "src/parse/lex.cc" yy420: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2645,7 +2644,7 @@ yy421: goto yy410; } } -#line 625 "../src/parse/lex.re" +#line 624 "../src/parse/lex.re" } @@ -2654,7 +2653,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) end = false; tok = cur; -#line 2658 "src/parse/lex.cc" +#line 2657 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2663,17 +2662,17 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) if (yych == '\n') goto yy426; if (yych == '\\') goto yy428; ++YYCURSOR; -#line 638 "../src/parse/lex.re" +#line 637 "../src/parse/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2672 "src/parse/lex.cc" +#line 2671 "src/parse/lex.cc" yy426: ++YYCURSOR; -#line 633 "../src/parse/lex.re" +#line 632 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 2677 "src/parse/lex.cc" +#line 2676 "src/parse/lex.cc" yy428: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) <= 'a') { @@ -2719,28 +2718,28 @@ yy428: } } } -#line 636 "../src/parse/lex.re" +#line 635 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 2725 "src/parse/lex.cc" +#line 2724 "src/parse/lex.cc" yy430: ++YYCURSOR; -#line 652 "../src/parse/lex.re" +#line 651 "../src/parse/lex.re" { if (tok[1] != quote) { warn.useless_escape(tline, tok - pos, tok[1]); } return static_cast(tok[1]); } -#line 2735 "src/parse/lex.cc" +#line 2734 "src/parse/lex.cc" yy432: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy433; if (yych <= '7') goto yy455; yy433: -#line 635 "../src/parse/lex.re" +#line 634 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 2744 "src/parse/lex.cc" +#line 2743 "src/parse/lex.cc" yy434: yych = (YYCTYPE)*++YYCURSOR; goto yy433; @@ -2756,9 +2755,9 @@ yy435: if (yych <= 'f') goto yy457; } yy436: -#line 634 "../src/parse/lex.re" +#line 633 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 2762 "src/parse/lex.cc" +#line 2761 "src/parse/lex.cc" yy437: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2774,44 +2773,44 @@ yy437: } yy438: ++YYCURSOR; -#line 651 "../src/parse/lex.re" +#line 650 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2780 "src/parse/lex.cc" +#line 2779 "src/parse/lex.cc" yy440: ++YYCURSOR; -#line 644 "../src/parse/lex.re" +#line 643 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2785 "src/parse/lex.cc" +#line 2784 "src/parse/lex.cc" yy442: ++YYCURSOR; -#line 645 "../src/parse/lex.re" +#line 644 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2790 "src/parse/lex.cc" +#line 2789 "src/parse/lex.cc" yy444: ++YYCURSOR; -#line 646 "../src/parse/lex.re" +#line 645 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2795 "src/parse/lex.cc" +#line 2794 "src/parse/lex.cc" yy446: ++YYCURSOR; -#line 647 "../src/parse/lex.re" +#line 646 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2800 "src/parse/lex.cc" +#line 2799 "src/parse/lex.cc" yy448: ++YYCURSOR; -#line 648 "../src/parse/lex.re" +#line 647 "../src/parse/lex.re" { return static_cast('\r'); } -#line 2805 "src/parse/lex.cc" +#line 2804 "src/parse/lex.cc" yy450: ++YYCURSOR; -#line 649 "../src/parse/lex.re" +#line 648 "../src/parse/lex.re" { return static_cast('\t'); } -#line 2810 "src/parse/lex.cc" +#line 2809 "src/parse/lex.cc" yy452: ++YYCURSOR; -#line 650 "../src/parse/lex.re" +#line 649 "../src/parse/lex.re" { return static_cast('\v'); } -#line 2815 "src/parse/lex.cc" +#line 2814 "src/parse/lex.cc" yy454: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2874,9 +2873,9 @@ yy459: } yy460: ++YYCURSOR; -#line 643 "../src/parse/lex.re" +#line 642 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 2880 "src/parse/lex.cc" +#line 2879 "src/parse/lex.cc" yy462: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2903,9 +2902,9 @@ yy463: } yy464: ++YYCURSOR; -#line 642 "../src/parse/lex.re" +#line 641 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 2909 "src/parse/lex.cc" +#line 2908 "src/parse/lex.cc" yy466: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2929,7 +2928,7 @@ yy467: goto yy456; } } -#line 658 "../src/parse/lex.re" +#line 657 "../src/parse/lex.re" } @@ -2950,7 +2949,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2954 "src/parse/lex.cc" +#line 2953 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2999,14 +2998,14 @@ sourceline: yy470: ++YYCURSOR; yy471: -#line 701 "../src/parse/lex.re" +#line 700 "../src/parse/lex.re" { goto sourceline; } -#line 3007 "src/parse/lex.cc" +#line 3006 "src/parse/lex.cc" yy472: ++YYCURSOR; -#line 689 "../src/parse/lex.re" +#line 688 "../src/parse/lex.re" { if (cur == eof) { @@ -3019,7 +3018,7 @@ yy472: tok = cur; return; } -#line 3023 "src/parse/lex.cc" +#line 3022 "src/parse/lex.cc" yy474: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych == '\n') goto yy471; @@ -3031,7 +3030,7 @@ yy475: if (yybm[0+yych] & 64) { goto yy475; } -#line 678 "../src/parse/lex.re" +#line 677 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { @@ -3039,7 +3038,7 @@ yy475: } goto sourceline; } -#line 3043 "src/parse/lex.cc" +#line 3042 "src/parse/lex.cc" yy478: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3056,12 +3055,12 @@ yy480: goto yy471; yy481: ++YYCURSOR; -#line 685 "../src/parse/lex.re" +#line 684 "../src/parse/lex.re" { escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes goto sourceline; } -#line 3065 "src/parse/lex.cc" +#line 3064 "src/parse/lex.cc" yy483: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3069,7 +3068,7 @@ yy483: if (yych == '\n') goto yy480; goto yy478; } -#line 704 "../src/parse/lex.re" +#line 703 "../src/parse/lex.re" } diff --git a/re2c/src/parse/lex.re b/re2c/src/parse/lex.re index 23768f00..2ce931a0 100644 --- a/re2c/src/parse/lex.re +++ b/re2c/src/parse/lex.re @@ -74,34 +74,33 @@ echo: /*!re2c "%{" | "/*!re2c" { - if (opts->target == opt_t::CODE) { - out.wraw(tok, start); - } if (opts->rFlag) { fatal("found standard 're2c' block while using -r flag"); } + if (opts->target == opt_t::CODE) { + out.wraw(tok, start); + } return Parse; } "/*!rules:re2c" { + if (!opts->rFlag) { + fatal("found 'rules:re2c' block without -r flag"); + } if (opts->target == opt_t::CODE) { out.wraw(tok, start); } - if (opts->rFlag) { - opts.reset_mapCodeName (); - } else { - fatal("found 'rules:re2c' block without -r flag"); - } + opts.reset_mapCodeName (); return Rules; } "/*!use:re2c" { - if (opts->target == opt_t::CODE) { - out.wraw(tok, start); - } if (!opts->rFlag) { fatal("found 'use:re2c' block without -r flag"); } + if (opts->target == opt_t::CODE) { + out.wraw(tok, start); + } reuse(); return Reuse; } -- 2.40.0