From 54e910feb60d9c203f2955e5dd9f6107ea0de520 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 22 Dec 2016 13:58:05 +0000 Subject: [PATCH] Simplified handling of user-defined code in parser. --- re2c/Makefile.am | 3 - re2c/bootstrap/src/parse/lex.cc | 499 ++++++++++++++--------------- re2c/bootstrap/src/parse/parser.cc | 221 +++++++------ re2c/bootstrap/src/parse/y.tab.h | 2 +- re2c/src/codegen/emit_action.cc | 11 +- re2c/src/codegen/emit_dfa.cc | 8 +- re2c/src/conf/warn.cc | 2 +- re2c/src/ir/dfa/closure.cc | 2 +- re2c/src/ir/dfa/dead_rules.cc | 2 +- re2c/src/ir/dfa/determinization.cc | 2 +- re2c/src/ir/nfa/init_rules.cc | 4 +- re2c/src/ir/regexp/nullable.cc | 2 +- re2c/src/ir/regexp/regexp.h | 6 +- re2c/src/ir/rule.h | 38 ++- re2c/src/parse/code.cc | 8 - re2c/src/parse/code.h | 31 -- re2c/src/parse/lex.re | 5 +- re2c/src/parse/loc.h | 24 -- re2c/src/parse/parser.ypp | 71 ++-- 19 files changed, 444 insertions(+), 497 deletions(-) delete mode 100644 re2c/src/parse/code.cc delete mode 100644 re2c/src/parse/code.h delete mode 100644 re2c/src/parse/loc.h diff --git a/re2c/Makefile.am b/re2c/Makefile.am index a4e55215..2a8e61da 100644 --- a/re2c/Makefile.am +++ b/re2c/Makefile.am @@ -46,10 +46,8 @@ SRC_HDR = \ src/ir/tcmd.h \ src/ir/skeleton/path.h \ src/ir/skeleton/skeleton.h \ - src/parse/code.h \ src/parse/extop.h \ src/parse/input.h \ - src/parse/loc.h \ src/parse/parser.h \ src/parse/rules.h \ src/parse/scanner.h \ @@ -132,7 +130,6 @@ SRC = \ src/ir/tag.cc \ src/ir/tcmd.cc \ src/main.cc \ - src/parse/code.cc \ src/parse/input.cc \ src/parse/scanner.cc \ src/parse/unescape.cc \ diff --git a/re2c/bootstrap/src/parse/lex.cc b/re2c/bootstrap/src/parse/lex.cc index 82ddfe22..4f158e0a 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 Thu Dec 22 12:04:32 2016 */ +/* Generated by re2c 0.16 on Thu Dec 22 13:54:31 2016 */ #line 1 "../src/parse/lex.re" #include "src/util/c99_stdint.h" #include @@ -10,7 +10,6 @@ #include "src/codegen/output.h" #include "src/ir/regexp/encoding/enc.h" #include "src/ir/regexp/regexp.h" -#include "src/parse/code.h" #include "src/parse/extop.h" #include "src/parse/input.h" #include "src/parse/scanner.h" @@ -35,10 +34,10 @@ namespace re2c // source code is in ASCII: pointers have type 'char *' // but re2c makes an implicit assumption that YYCTYPE is unsigned // when it generates comparisons -#line 38 "../src/parse/lex.re" +#line 37 "../src/parse/lex.re" -#line 59 "../src/parse/lex.re" +#line 58 "../src/parse/lex.re" Scanner::ParseMode Scanner::echo() @@ -53,7 +52,7 @@ echo: const char *start = cur; -#line 57 "src/parse/lex.cc" +#line 56 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -111,7 +110,7 @@ echo: } } ++YYCURSOR; -#line 150 "../src/parse/lex.re" +#line 149 "../src/parse/lex.re" { if (cur == eof) { if (opts->target == opt_t::CODE) { @@ -121,13 +120,13 @@ echo: } goto echo; } -#line 125 "src/parse/lex.cc" +#line 124 "src/parse/lex.cc" yy4: ++YYCURSOR; yy5: -#line 171 "../src/parse/lex.re" +#line 170 "../src/parse/lex.re" { goto echo; } -#line 131 "src/parse/lex.cc" +#line 130 "src/parse/lex.cc" yy6: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -136,13 +135,13 @@ yy6: } if (yych == '#') goto yy14; yy7: -#line 165 "../src/parse/lex.re" +#line 164 "../src/parse/lex.re" { cline++; pos = cur; goto echo; } -#line 146 "src/parse/lex.cc" +#line 145 "src/parse/lex.cc" yy8: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy6; @@ -185,7 +184,7 @@ yy14: } yy16: ++YYCURSOR; -#line 73 "../src/parse/lex.re" +#line 72 "../src/parse/lex.re" { if (opts->rFlag) { fatal("found standard 're2c' block while using -r flag"); @@ -195,7 +194,7 @@ yy16: } return Parse; } -#line 199 "src/parse/lex.cc" +#line 198 "src/parse/lex.cc" yy18: yych = (YYCTYPE)*++YYCURSOR; if (yych == '!') goto yy20; @@ -423,12 +422,12 @@ yy64: yy66: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 160 "../src/parse/lex.re" +#line 159 "../src/parse/lex.re" { set_sourceline(); goto echo; } -#line 432 "src/parse/lex.cc" +#line 431 "src/parse/lex.cc" yy68: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy66; @@ -520,7 +519,7 @@ yy88: goto yy13; yy89: ++YYCURSOR; -#line 113 "../src/parse/lex.re" +#line 112 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start) @@ -529,7 +528,7 @@ yy89: lex_end_of_comment(); goto echo; } -#line 533 "src/parse/lex.cc" +#line 532 "src/parse/lex.cc" yy91: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy98; @@ -544,7 +543,7 @@ yy93: goto yy13; yy94: ++YYCURSOR; -#line 94 "../src/parse/lex.re" +#line 93 "../src/parse/lex.re" { if (!opts->rFlag) { fatal("found 'use:re2c' block without -r flag"); @@ -555,7 +554,7 @@ yy94: reuse(); return Reuse; } -#line 559 "src/parse/lex.cc" +#line 558 "src/parse/lex.cc" yy96: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy102; @@ -570,7 +569,7 @@ yy98: goto yy13; yy99: ++YYCURSOR; -#line 142 "../src/parse/lex.re" +#line 141 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start); @@ -578,7 +577,7 @@ yy99: lex_tags(); goto echo; } -#line 582 "src/parse/lex.cc" +#line 581 "src/parse/lex.cc" yy101: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy106; @@ -593,7 +592,7 @@ yy103: goto yy13; yy104: ++YYCURSOR; -#line 83 "../src/parse/lex.re" +#line 82 "../src/parse/lex.re" { if (!opts->rFlag) { fatal("found 'rules:re2c' block without -r flag"); @@ -604,10 +603,10 @@ yy104: opts.reset_mapCodeName (); return Rules; } -#line 608 "src/parse/lex.cc" +#line 607 "src/parse/lex.cc" yy106: ++YYCURSOR; -#line 131 "../src/parse/lex.re" +#line 130 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start) @@ -618,14 +617,14 @@ yy106: lex_end_of_comment(); goto echo; } -#line 622 "src/parse/lex.cc" +#line 621 "src/parse/lex.cc" yy108: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy111; goto yy13; yy109: ++YYCURSOR; -#line 105 "../src/parse/lex.re" +#line 104 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start); @@ -633,12 +632,12 @@ yy109: lex_end_of_comment(); goto echo; } -#line 637 "src/parse/lex.cc" +#line 636 "src/parse/lex.cc" yy111: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy13; ++YYCURSOR; -#line 122 "../src/parse/lex.re" +#line 121 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wraw(tok, start) @@ -647,9 +646,9 @@ yy111: lex_end_of_comment(); goto echo; } -#line 651 "src/parse/lex.cc" +#line 650 "src/parse/lex.cc" } -#line 172 "../src/parse/lex.re" +#line 171 "../src/parse/lex.re" } @@ -657,7 +656,7 @@ void Scanner::lex_end_of_comment() { uint32_t ignored = 0; for (;;) { -#line 661 "src/parse/lex.cc" +#line 660 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -673,20 +672,20 @@ void Scanner::lex_end_of_comment() } yy116: ++YYCURSOR; -#line 179 "../src/parse/lex.re" +#line 178 "../src/parse/lex.re" { fatal("expected end of block"); } -#line 679 "src/parse/lex.cc" +#line 678 "src/parse/lex.cc" yy118: ++YYCURSOR; yy119: -#line 181 "../src/parse/lex.re" +#line 180 "../src/parse/lex.re" { continue; } -#line 685 "src/parse/lex.cc" +#line 684 "src/parse/lex.cc" yy120: ++YYCURSOR; -#line 182 "../src/parse/lex.re" +#line 181 "../src/parse/lex.re" { ++ignored; continue; } -#line 690 "src/parse/lex.cc" +#line 689 "src/parse/lex.cc" yy122: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy120; @@ -695,7 +694,7 @@ yy123: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy119; ++YYCURSOR; -#line 183 "../src/parse/lex.re" +#line 182 "../src/parse/lex.re" { if (ignored > 0) { cline += ignored; @@ -704,9 +703,9 @@ yy123: tok = pos = cur; return; } -#line 708 "src/parse/lex.cc" +#line 707 "src/parse/lex.cc" } -#line 191 "../src/parse/lex.re" +#line 190 "../src/parse/lex.re" } } @@ -714,7 +713,7 @@ void Scanner::lex_tags() { std::string fmt, sep; for (;;) { -#line 718 "src/parse/lex.cc" +#line 717 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -772,9 +771,9 @@ void Scanner::lex_tags() } ++YYCURSOR; yy129: -#line 198 "../src/parse/lex.re" +#line 197 "../src/parse/lex.re" { fatal("unrecognized configuration"); } -#line 778 "src/parse/lex.cc" +#line 777 "src/parse/lex.cc" yy130: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -782,14 +781,14 @@ yy130: if (yybm[0+yych] & 128) { goto yy130; } -#line 203 "../src/parse/lex.re" +#line 202 "../src/parse/lex.re" { continue; } -#line 788 "src/parse/lex.cc" +#line 787 "src/parse/lex.cc" yy133: ++YYCURSOR; -#line 204 "../src/parse/lex.re" +#line 203 "../src/parse/lex.re" { ++cline; continue; } -#line 793 "src/parse/lex.cc" +#line 792 "src/parse/lex.cc" yy135: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy133; @@ -808,7 +807,7 @@ yy138: goto yy129; yy139: ++YYCURSOR; -#line 205 "../src/parse/lex.re" +#line 204 "../src/parse/lex.re" { if (opts->target == opt_t::CODE) { out.wdelay_tags(opts->topIndent, @@ -817,7 +816,7 @@ yy139: tok = pos = cur; return; } -#line 821 "src/parse/lex.cc" +#line 820 "src/parse/lex.cc" yy141: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy144; @@ -854,9 +853,9 @@ yy149: goto yy142; yy150: ++YYCURSOR; -#line 200 "../src/parse/lex.re" +#line 199 "../src/parse/lex.re" { fmt = lex_conf_string(); continue; } -#line 860 "src/parse/lex.cc" +#line 859 "src/parse/lex.cc" yy152: yych = (YYCTYPE)*++YYCURSOR; if (yych != 't') goto yy142; @@ -865,11 +864,11 @@ yy152: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'r') goto yy142; ++YYCURSOR; -#line 201 "../src/parse/lex.re" +#line 200 "../src/parse/lex.re" { sep = lex_conf_string(); continue; } -#line 871 "src/parse/lex.cc" +#line 870 "src/parse/lex.cc" } -#line 213 "../src/parse/lex.re" +#line 212 "../src/parse/lex.re" } } @@ -887,7 +886,7 @@ scan: start: -#line 891 "src/parse/lex.cc" +#line 890 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -992,12 +991,12 @@ start: yy159: ++YYCURSOR; yy160: -#line 388 "../src/parse/lex.re" +#line 387 "../src/parse/lex.re" { fatalf("unexpected character: '%c'", *tok); goto scan; } -#line 1001 "src/parse/lex.cc" +#line 1000 "src/parse/lex.cc" yy161: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1005,11 +1004,11 @@ yy161: if (yybm[0+yych] & 16) { goto yy161; } -#line 372 "../src/parse/lex.re" +#line 371 "../src/parse/lex.re" { goto scan; } -#line 1013 "src/parse/lex.cc" +#line 1012 "src/parse/lex.cc" yy164: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1020,14 +1019,14 @@ yy164: if (yych == '#') goto yy193; } yy165: -#line 381 "../src/parse/lex.re" +#line 380 "../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" yy166: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy164; @@ -1035,50 +1034,50 @@ yy166: yy167: ++YYCURSOR; yy168: -#line 275 "../src/parse/lex.re" +#line 274 "../src/parse/lex.re" { return *tok; } -#line 1043 "src/parse/lex.cc" +#line 1042 "src/parse/lex.cc" yy169: ++YYCURSOR; -#line 262 "../src/parse/lex.re" +#line 261 "../src/parse/lex.re" { yylval.regexp = lex_str('"', opts->bCaseInsensitive || opts->bCaseInverted); return TOKEN_REGEXP; } -#line 1048 "src/parse/lex.cc" +#line 1047 "src/parse/lex.cc" yy171: yych = (YYCTYPE)*++YYCURSOR; if (yych == '}') goto yy195; goto yy160; yy172: ++YYCURSOR; -#line 261 "../src/parse/lex.re" +#line 260 "../src/parse/lex.re" { yylval.regexp = lex_str('\'', opts->bCaseInsensitive || !opts->bCaseInverted); return TOKEN_REGEXP; } -#line 1057 "src/parse/lex.cc" +#line 1056 "src/parse/lex.cc" yy174: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy195; -#line 279 "../src/parse/lex.re" +#line 278 "../src/parse/lex.re" { yylval.op = *tok; return TOKEN_STAR; } -#line 1066 "src/parse/lex.cc" +#line 1065 "src/parse/lex.cc" yy176: ++YYCURSOR; -#line 283 "../src/parse/lex.re" +#line 282 "../src/parse/lex.re" { yylval.op = *tok; return TOKEN_CLOSE; } -#line 1074 "src/parse/lex.cc" +#line 1073 "src/parse/lex.cc" yy178: ++YYCURSOR; -#line 367 "../src/parse/lex.re" +#line 366 "../src/parse/lex.re" { yylval.regexp = mkDot(); return TOKEN_REGEXP; } -#line 1082 "src/parse/lex.cc" +#line 1081 "src/parse/lex.cc" yy180: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy197; @@ -1138,9 +1137,9 @@ yy184: yy185: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy212; -#line 263 "../src/parse/lex.re" +#line 262 "../src/parse/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1144 "src/parse/lex.cc" +#line 1143 "src/parse/lex.cc" yy187: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy214; @@ -1163,13 +1162,13 @@ yy188: } } yy189: -#line 230 "../src/parse/lex.re" +#line 229 "../src/parse/lex.re" { depth = 1; code_line = cline; goto code; } -#line 1173 "src/parse/lex.cc" +#line 1172 "src/parse/lex.cc" yy190: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1205,31 +1204,31 @@ yy193: } yy195: ++YYCURSOR; -#line 256 "../src/parse/lex.re" +#line 255 "../src/parse/lex.re" { tok = cur; return 0; } -#line 1214 "src/parse/lex.cc" +#line 1213 "src/parse/lex.cc" yy197: ++YYCURSOR; -#line 250 "../src/parse/lex.re" +#line 249 "../src/parse/lex.re" { depth = 1; goto comment; } -#line 1222 "src/parse/lex.cc" +#line 1221 "src/parse/lex.cc" yy199: ++YYCURSOR; -#line 247 "../src/parse/lex.re" +#line 246 "../src/parse/lex.re" { goto nextLine; } -#line 1229 "src/parse/lex.cc" +#line 1228 "src/parse/lex.cc" yy201: ++YYCURSOR; YYCURSOR -= 1; -#line 351 "../src/parse/lex.re" +#line 350 "../src/parse/lex.re" { if (!opts->FFlag) { yylval.str = new std::string (tok, tok_len()); @@ -1245,7 +1244,7 @@ yy201: return TOKEN_REGEXP; } } -#line 1249 "src/parse/lex.cc" +#line 1248 "src/parse/lex.cc" yy203: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1265,23 +1264,23 @@ yy203: yy205: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 346 "../src/parse/lex.re" +#line 345 "../src/parse/lex.re" { yylval.str = new std::string (tok, tok_len ()); return TOKEN_ID; } -#line 1274 "src/parse/lex.cc" +#line 1273 "src/parse/lex.cc" yy207: yych = (YYCTYPE)*++YYCURSOR; if (yych == '>') goto yy224; -#line 240 "../src/parse/lex.re" +#line 239 "../src/parse/lex.re" { tok += 2; /* skip ":=" */ depth = 0; code_line = cline; goto code; } -#line 1285 "src/parse/lex.cc" +#line 1284 "src/parse/lex.cc" yy209: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1299,7 +1298,7 @@ yy209: } } yy211: -#line 266 "../src/parse/lex.re" +#line 265 "../src/parse/lex.re" { if (!opts->tags) { fatal("tags are only allowed with '-T, --tags' option"); @@ -1308,12 +1307,12 @@ yy211: yylval.regexp = RegExp::make_tag(name); return TOKEN_REGEXP; } -#line 1312 "src/parse/lex.cc" +#line 1311 "src/parse/lex.cc" yy212: ++YYCURSOR; -#line 264 "../src/parse/lex.re" +#line 263 "../src/parse/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1317 "src/parse/lex.cc" +#line 1316 "src/parse/lex.cc" yy214: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy226; @@ -1321,11 +1320,11 @@ yy214: yy215: ++YYCURSOR; yy216: -#line 319 "../src/parse/lex.re" +#line 318 "../src/parse/lex.re" { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 1329 "src/parse/lex.cc" +#line 1328 "src/parse/lex.cc" yy217: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1378,7 +1377,7 @@ yy221: yy222: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 333 "../src/parse/lex.re" +#line 332 "../src/parse/lex.re" { yylval.str = new std::string (tok, tok_len ()); if (opts->FFlag) @@ -1391,15 +1390,15 @@ yy222: return TOKEN_ID; } } -#line 1395 "src/parse/lex.cc" +#line 1394 "src/parse/lex.cc" yy224: ++YYCURSOR; YYCURSOR -= 2; -#line 236 "../src/parse/lex.re" +#line 235 "../src/parse/lex.re" { return *tok; } -#line 1403 "src/parse/lex.cc" +#line 1402 "src/parse/lex.cc" yy226: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy233; @@ -1413,7 +1412,7 @@ yy227: goto yy216; yy228: ++YYCURSOR; -#line 288 "../src/parse/lex.re" +#line 287 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.extop.min)) { @@ -1422,10 +1421,10 @@ yy228: yylval.extop.max = yylval.extop.min; return TOKEN_CLOSESIZE; } -#line 1426 "src/parse/lex.cc" +#line 1425 "src/parse/lex.cc" yy230: ++YYCURSOR; -#line 323 "../src/parse/lex.re" +#line 322 "../src/parse/lex.re" { if (!opts->FFlag) { fatal("curly braces for names only allowed with -F switch"); @@ -1433,7 +1432,7 @@ yy230: yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return TOKEN_ID; } -#line 1437 "src/parse/lex.cc" +#line 1436 "src/parse/lex.cc" yy232: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy238; @@ -1452,7 +1451,7 @@ yy234: goto yy192; yy236: ++YYCURSOR; -#line 310 "../src/parse/lex.re" +#line 309 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.extop.min)) { @@ -1461,19 +1460,19 @@ yy236: yylval.extop.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1465 "src/parse/lex.cc" +#line 1464 "src/parse/lex.cc" yy238: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy243; goto yy192; yy239: ++YYCURSOR; -#line 331 "../src/parse/lex.re" +#line 330 "../src/parse/lex.re" { lex_conf (); return TOKEN_CONF; } -#line 1474 "src/parse/lex.cc" +#line 1473 "src/parse/lex.cc" yy241: ++YYCURSOR; -#line 297 "../src/parse/lex.re" +#line 296 "../src/parse/lex.re" { const char * p = strchr (tok, ','); if (!s_to_u32_unsafe (tok + 1, p, yylval.extop.min)) @@ -1486,7 +1485,7 @@ yy241: } return TOKEN_CLOSESIZE; } -#line 1490 "src/parse/lex.cc" +#line 1489 "src/parse/lex.cc" yy243: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy245; @@ -1542,12 +1541,12 @@ yy248: yy250: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 376 "../src/parse/lex.re" +#line 375 "../src/parse/lex.re" { set_sourceline (); goto scan; } -#line 1551 "src/parse/lex.cc" +#line 1550 "src/parse/lex.cc" yy252: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy250; @@ -1572,12 +1571,12 @@ yy256: if (yych == '\n') goto yy192; goto yy253; } -#line 392 "../src/parse/lex.re" +#line 391 "../src/parse/lex.re" flex_name: -#line 1581 "src/parse/lex.cc" +#line 1580 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1586,32 +1585,32 @@ flex_name: if (yych == '\r') goto yy263; ++YYCURSOR; yy260: -#line 403 "../src/parse/lex.re" +#line 402 "../src/parse/lex.re" { YYCURSOR = tok; goto start; } -#line 1595 "src/parse/lex.cc" +#line 1594 "src/parse/lex.cc" yy261: ++YYCURSOR; -#line 397 "../src/parse/lex.re" +#line 396 "../src/parse/lex.re" { YYCURSOR = tok; lexer_state = LEX_NORMAL; return TOKEN_FID_END; } -#line 1604 "src/parse/lex.cc" +#line 1603 "src/parse/lex.cc" yy263: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy261; goto yy260; } -#line 407 "../src/parse/lex.re" +#line 406 "../src/parse/lex.re" code: -#line 1615 "src/parse/lex.cc" +#line 1614 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1672,7 +1671,7 @@ code: } yy266: ++YYCURSOR; -#line 470 "../src/parse/lex.re" +#line 469 "../src/parse/lex.re" { if (cur == eof) { @@ -1684,15 +1683,15 @@ yy266: } goto code; } -#line 1688 "src/parse/lex.cc" +#line 1687 "src/parse/lex.cc" yy268: ++YYCURSOR; yy269: -#line 484 "../src/parse/lex.re" +#line 483 "../src/parse/lex.re" { goto code; } -#line 1696 "src/parse/lex.cc" +#line 1695 "src/parse/lex.cc" yy270: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1711,7 +1710,7 @@ yy270: } } yy271: -#line 451 "../src/parse/lex.re" +#line 450 "../src/parse/lex.re" { if (depth == 0) { @@ -1720,7 +1719,7 @@ yy271: { --cur; } - yylval.code = new Code (tok, tok_len (), get_fname (), code_line); + yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); return TOKEN_CODE; } else if (cur == eof) @@ -1731,7 +1730,7 @@ yy271: cline++; goto code; } -#line 1735 "src/parse/lex.cc" +#line 1734 "src/parse/lex.cc" yy272: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1744,7 +1743,7 @@ yy273: goto yy290; yy274: ++YYCURSOR; -#line 423 "../src/parse/lex.re" +#line 422 "../src/parse/lex.re" { if (depth == 0) { @@ -1756,10 +1755,10 @@ yy274: } goto code; } -#line 1760 "src/parse/lex.cc" +#line 1759 "src/parse/lex.cc" yy276: ++YYCURSOR; -#line 411 "../src/parse/lex.re" +#line 410 "../src/parse/lex.re" { if (depth == 0) { @@ -1767,12 +1766,12 @@ yy276: } else if (--depth == 0) { - yylval.code = new Code (tok, tok_len (), get_fname (), code_line); + yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); return TOKEN_CODE; } goto code; } -#line 1776 "src/parse/lex.cc" +#line 1775 "src/parse/lex.cc" yy278: yyaccept = 2; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1784,7 +1783,7 @@ yy278: } yy279: YYCURSOR -= 1; -#line 438 "../src/parse/lex.re" +#line 437 "../src/parse/lex.re" { if (depth == 0) { @@ -1798,7 +1797,7 @@ yy279: cline++; goto code; } -#line 1802 "src/parse/lex.cc" +#line 1801 "src/parse/lex.cc" yy280: ++YYCURSOR; goto yy279; @@ -1833,11 +1832,11 @@ yy285: if (yych >= '#') goto yy288; yy286: ++YYCURSOR; -#line 481 "../src/parse/lex.re" +#line 480 "../src/parse/lex.re" { goto code; } -#line 1841 "src/parse/lex.cc" +#line 1840 "src/parse/lex.cc" yy288: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1927,12 +1926,12 @@ yy302: yy304: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 434 "../src/parse/lex.re" +#line 433 "../src/parse/lex.re" { set_sourceline (); goto code; } -#line 1936 "src/parse/lex.cc" +#line 1935 "src/parse/lex.cc" yy306: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy304; @@ -1961,12 +1960,12 @@ yy310: if (yych == '\n') goto yy283; goto yy307; } -#line 487 "../src/parse/lex.re" +#line 486 "../src/parse/lex.re" comment: -#line 1970 "src/parse/lex.cc" +#line 1969 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2013,7 +2012,7 @@ comment: } ++YYCURSOR; yy314: -#line 519 "../src/parse/lex.re" +#line 518 "../src/parse/lex.re" { if (cur == eof) { @@ -2021,7 +2020,7 @@ yy314: } goto comment; } -#line 2025 "src/parse/lex.cc" +#line 2024 "src/parse/lex.cc" yy315: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -2029,7 +2028,7 @@ yy315: } if (yych == '#') goto yy322; yy316: -#line 510 "../src/parse/lex.re" +#line 509 "../src/parse/lex.re" { if (cur == eof) { @@ -2039,7 +2038,7 @@ yy316: cline++; goto comment; } -#line 2043 "src/parse/lex.cc" +#line 2042 "src/parse/lex.cc" yy317: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy324; @@ -2073,7 +2072,7 @@ yy322: } yy324: ++YYCURSOR; -#line 491 "../src/parse/lex.re" +#line 490 "../src/parse/lex.re" { if (--depth == 0) { @@ -2084,16 +2083,16 @@ yy324: goto comment; } } -#line 2088 "src/parse/lex.cc" +#line 2087 "src/parse/lex.cc" yy326: ++YYCURSOR; -#line 501 "../src/parse/lex.re" +#line 500 "../src/parse/lex.re" { ++depth; fatal("ambiguous /* found"); goto comment; } -#line 2097 "src/parse/lex.cc" +#line 2096 "src/parse/lex.cc" yy328: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'i') goto yy321; @@ -2150,12 +2149,12 @@ yy336: yy338: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 506 "../src/parse/lex.re" +#line 505 "../src/parse/lex.re" { set_sourceline (); goto comment; } -#line 2159 "src/parse/lex.cc" +#line 2158 "src/parse/lex.cc" yy340: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy338; @@ -2180,28 +2179,28 @@ yy344: if (yych == '\n') goto yy321; goto yy341; } -#line 526 "../src/parse/lex.re" +#line 525 "../src/parse/lex.re" nextLine: -#line 2189 "src/parse/lex.cc" +#line 2188 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\n') goto yy349; ++YYCURSOR; -#line 537 "../src/parse/lex.re" +#line 536 "../src/parse/lex.re" { if(cur == eof) { return 0; } goto nextLine; } -#line 2202 "src/parse/lex.cc" +#line 2201 "src/parse/lex.cc" yy349: ++YYCURSOR; -#line 530 "../src/parse/lex.re" +#line 529 "../src/parse/lex.re" { if(cur == eof) { return 0; } @@ -2209,9 +2208,9 @@ yy349: cline++; goto scan; } -#line 2213 "src/parse/lex.cc" +#line 2212 "src/parse/lex.cc" } -#line 542 "../src/parse/lex.re" +#line 541 "../src/parse/lex.re" } @@ -2235,35 +2234,35 @@ const RegExp *Scanner::lex_cls(bool neg) uint32_t u, l; fst: -#line 2239 "src/parse/lex.cc" +#line 2238 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy354; -#line 566 "../src/parse/lex.re" +#line 565 "../src/parse/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2247 "src/parse/lex.cc" +#line 2246 "src/parse/lex.cc" yy354: ++YYCURSOR; -#line 565 "../src/parse/lex.re" +#line 564 "../src/parse/lex.re" { goto end; } -#line 2252 "src/parse/lex.cc" +#line 2251 "src/parse/lex.cc" } -#line 567 "../src/parse/lex.re" +#line 566 "../src/parse/lex.re" snd: -#line 2258 "src/parse/lex.cc" +#line 2257 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy359; yy358: -#line 570 "../src/parse/lex.re" +#line 569 "../src/parse/lex.re" { u = l; goto add; } -#line 2267 "src/parse/lex.cc" +#line 2266 "src/parse/lex.cc" yy359: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy361; @@ -2272,7 +2271,7 @@ yy359: yy361: ++YYCURSOR; YYCURSOR -= 1; -#line 571 "../src/parse/lex.re" +#line 570 "../src/parse/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2281,9 +2280,9 @@ yy361: } goto add; } -#line 2285 "src/parse/lex.cc" +#line 2284 "src/parse/lex.cc" } -#line 579 "../src/parse/lex.re" +#line 578 "../src/parse/lex.re" add: if (!(s = opts->encoding.encodeRange(l, u))) { @@ -2302,7 +2301,7 @@ uint32_t Scanner::lex_cls_chr() { tok = cur; -#line 2306 "src/parse/lex.cc" +#line 2305 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2311,14 +2310,14 @@ uint32_t Scanner::lex_cls_chr() if (yych == '\n') goto yy367; if (yych == '\\') goto yy369; ++YYCURSOR; -#line 602 "../src/parse/lex.re" +#line 601 "../src/parse/lex.re" { return static_cast(tok[0]); } -#line 2317 "src/parse/lex.cc" +#line 2316 "src/parse/lex.cc" yy367: ++YYCURSOR; -#line 597 "../src/parse/lex.re" +#line 596 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 2322 "src/parse/lex.cc" +#line 2321 "src/parse/lex.cc" yy369: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '`') { @@ -2367,31 +2366,31 @@ yy369: } } } -#line 600 "../src/parse/lex.re" +#line 599 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 2373 "src/parse/lex.cc" +#line 2372 "src/parse/lex.cc" yy371: ++YYCURSOR; -#line 615 "../src/parse/lex.re" +#line 614 "../src/parse/lex.re" { warn.useless_escape(cline, tok - pos, tok[1]); return static_cast(tok[1]); } -#line 2381 "src/parse/lex.cc" +#line 2380 "src/parse/lex.cc" yy373: ++YYCURSOR; -#line 613 "../src/parse/lex.re" +#line 612 "../src/parse/lex.re" { return static_cast('-'); } -#line 2386 "src/parse/lex.cc" +#line 2385 "src/parse/lex.cc" yy375: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy376; if (yych <= '7') goto yy400; yy376: -#line 599 "../src/parse/lex.re" +#line 598 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 2395 "src/parse/lex.cc" +#line 2394 "src/parse/lex.cc" yy377: ++YYCURSOR; goto yy376; @@ -2407,9 +2406,9 @@ yy378: if (yych <= 'f') goto yy402; } yy379: -#line 598 "../src/parse/lex.re" +#line 597 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 2413 "src/parse/lex.cc" +#line 2412 "src/parse/lex.cc" yy380: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2425,49 +2424,49 @@ yy380: } yy381: ++YYCURSOR; -#line 612 "../src/parse/lex.re" +#line 611 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2431 "src/parse/lex.cc" +#line 2430 "src/parse/lex.cc" yy383: ++YYCURSOR; -#line 614 "../src/parse/lex.re" +#line 613 "../src/parse/lex.re" { return static_cast(']'); } -#line 2436 "src/parse/lex.cc" +#line 2435 "src/parse/lex.cc" yy385: ++YYCURSOR; -#line 605 "../src/parse/lex.re" +#line 604 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2441 "src/parse/lex.cc" +#line 2440 "src/parse/lex.cc" yy387: ++YYCURSOR; -#line 606 "../src/parse/lex.re" +#line 605 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2446 "src/parse/lex.cc" +#line 2445 "src/parse/lex.cc" yy389: ++YYCURSOR; -#line 607 "../src/parse/lex.re" +#line 606 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2451 "src/parse/lex.cc" +#line 2450 "src/parse/lex.cc" yy391: ++YYCURSOR; -#line 608 "../src/parse/lex.re" +#line 607 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2456 "src/parse/lex.cc" +#line 2455 "src/parse/lex.cc" yy393: ++YYCURSOR; -#line 609 "../src/parse/lex.re" +#line 608 "../src/parse/lex.re" { return static_cast('\r'); } -#line 2461 "src/parse/lex.cc" +#line 2460 "src/parse/lex.cc" yy395: ++YYCURSOR; -#line 610 "../src/parse/lex.re" +#line 609 "../src/parse/lex.re" { return static_cast('\t'); } -#line 2466 "src/parse/lex.cc" +#line 2465 "src/parse/lex.cc" yy397: ++YYCURSOR; -#line 611 "../src/parse/lex.re" +#line 610 "../src/parse/lex.re" { return static_cast('\v'); } -#line 2471 "src/parse/lex.cc" +#line 2470 "src/parse/lex.cc" yy399: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2530,9 +2529,9 @@ yy404: } yy405: ++YYCURSOR; -#line 604 "../src/parse/lex.re" +#line 603 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 2536 "src/parse/lex.cc" +#line 2535 "src/parse/lex.cc" yy407: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2559,9 +2558,9 @@ yy408: } yy409: ++YYCURSOR; -#line 603 "../src/parse/lex.re" +#line 602 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 2565 "src/parse/lex.cc" +#line 2564 "src/parse/lex.cc" yy411: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2585,7 +2584,7 @@ yy412: goto yy401; } } -#line 619 "../src/parse/lex.re" +#line 618 "../src/parse/lex.re" } @@ -2594,7 +2593,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) end = false; tok = cur; -#line 2598 "src/parse/lex.cc" +#line 2597 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2603,17 +2602,17 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) if (yych == '\n') goto yy417; if (yych == '\\') goto yy419; ++YYCURSOR; -#line 632 "../src/parse/lex.re" +#line 631 "../src/parse/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2612 "src/parse/lex.cc" +#line 2611 "src/parse/lex.cc" yy417: ++YYCURSOR; -#line 627 "../src/parse/lex.re" +#line 626 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 2617 "src/parse/lex.cc" +#line 2616 "src/parse/lex.cc" yy419: yych = (YYCTYPE)*++YYCURSOR; if (yych <= 'a') { @@ -2659,28 +2658,28 @@ yy419: } } } -#line 630 "../src/parse/lex.re" +#line 629 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 2665 "src/parse/lex.cc" +#line 2664 "src/parse/lex.cc" yy421: ++YYCURSOR; -#line 646 "../src/parse/lex.re" +#line 645 "../src/parse/lex.re" { if (tok[1] != quote) { warn.useless_escape(cline, tok - pos, tok[1]); } return static_cast(tok[1]); } -#line 2675 "src/parse/lex.cc" +#line 2674 "src/parse/lex.cc" yy423: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy424; if (yych <= '7') goto yy446; yy424: -#line 629 "../src/parse/lex.re" +#line 628 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 2684 "src/parse/lex.cc" +#line 2683 "src/parse/lex.cc" yy425: ++YYCURSOR; goto yy424; @@ -2696,9 +2695,9 @@ yy426: if (yych <= 'f') goto yy448; } yy427: -#line 628 "../src/parse/lex.re" +#line 627 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 2702 "src/parse/lex.cc" +#line 2701 "src/parse/lex.cc" yy428: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2714,44 +2713,44 @@ yy428: } yy429: ++YYCURSOR; -#line 645 "../src/parse/lex.re" +#line 644 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2720 "src/parse/lex.cc" +#line 2719 "src/parse/lex.cc" yy431: ++YYCURSOR; -#line 638 "../src/parse/lex.re" +#line 637 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2725 "src/parse/lex.cc" +#line 2724 "src/parse/lex.cc" yy433: ++YYCURSOR; -#line 639 "../src/parse/lex.re" +#line 638 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2730 "src/parse/lex.cc" +#line 2729 "src/parse/lex.cc" yy435: ++YYCURSOR; -#line 640 "../src/parse/lex.re" +#line 639 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2735 "src/parse/lex.cc" +#line 2734 "src/parse/lex.cc" yy437: ++YYCURSOR; -#line 641 "../src/parse/lex.re" +#line 640 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2740 "src/parse/lex.cc" +#line 2739 "src/parse/lex.cc" yy439: ++YYCURSOR; -#line 642 "../src/parse/lex.re" +#line 641 "../src/parse/lex.re" { return static_cast('\r'); } -#line 2745 "src/parse/lex.cc" +#line 2744 "src/parse/lex.cc" yy441: ++YYCURSOR; -#line 643 "../src/parse/lex.re" +#line 642 "../src/parse/lex.re" { return static_cast('\t'); } -#line 2750 "src/parse/lex.cc" +#line 2749 "src/parse/lex.cc" yy443: ++YYCURSOR; -#line 644 "../src/parse/lex.re" +#line 643 "../src/parse/lex.re" { return static_cast('\v'); } -#line 2755 "src/parse/lex.cc" +#line 2754 "src/parse/lex.cc" yy445: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2814,9 +2813,9 @@ yy450: } yy451: ++YYCURSOR; -#line 637 "../src/parse/lex.re" +#line 636 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 2820 "src/parse/lex.cc" +#line 2819 "src/parse/lex.cc" yy453: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2843,9 +2842,9 @@ yy454: } yy455: ++YYCURSOR; -#line 636 "../src/parse/lex.re" +#line 635 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 2849 "src/parse/lex.cc" +#line 2848 "src/parse/lex.cc" yy457: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2869,7 +2868,7 @@ yy458: goto yy447; } } -#line 652 "../src/parse/lex.re" +#line 651 "../src/parse/lex.re" } @@ -2890,7 +2889,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2894 "src/parse/lex.cc" +#line 2893 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2939,14 +2938,14 @@ sourceline: yy461: ++YYCURSOR; yy462: -#line 695 "../src/parse/lex.re" +#line 694 "../src/parse/lex.re" { goto sourceline; } -#line 2947 "src/parse/lex.cc" +#line 2946 "src/parse/lex.cc" yy463: ++YYCURSOR; -#line 683 "../src/parse/lex.re" +#line 682 "../src/parse/lex.re" { if (cur == eof) { @@ -2959,7 +2958,7 @@ yy463: tok = cur; return; } -#line 2963 "src/parse/lex.cc" +#line 2962 "src/parse/lex.cc" yy465: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych == '\n') goto yy462; @@ -2971,7 +2970,7 @@ yy466: if (yybm[0+yych] & 64) { goto yy466; } -#line 672 "../src/parse/lex.re" +#line 671 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { @@ -2979,7 +2978,7 @@ yy466: } goto sourceline; } -#line 2983 "src/parse/lex.cc" +#line 2982 "src/parse/lex.cc" yy469: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2996,12 +2995,12 @@ yy471: goto yy462; yy472: ++YYCURSOR; -#line 679 "../src/parse/lex.re" +#line 678 "../src/parse/lex.re" { escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes goto sourceline; } -#line 3005 "src/parse/lex.cc" +#line 3004 "src/parse/lex.cc" yy474: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3009,7 +3008,7 @@ yy474: if (yych == '\n') goto yy471; goto yy469; } -#line 698 "../src/parse/lex.re" +#line 697 "../src/parse/lex.re" } diff --git a/re2c/bootstrap/src/parse/parser.cc b/re2c/bootstrap/src/parse/parser.cc index 5b425854..2bc9bd19 100644 --- a/re2c/bootstrap/src/parse/parser.cc +++ b/re2c/bootstrap/src/parse/parser.cc @@ -88,9 +88,7 @@ #include "src/ir/regexp/encoding/range_suffix.h" #include "src/ir/regexp/regexp.h" #include "src/ir/skeleton/skeleton.h" -#include "src/parse/code.h" #include "src/parse/extop.h" -#include "src/parse/loc.h" #include "src/parse/parser.h" #include "src/parse/scanner.h" #include "src/util/free_list.h" @@ -129,8 +127,8 @@ static void check(const Spec &spec, const std::string &cond) j = std::find_if(i + 1, e, RegExpRule::is_def); if (j != e) { const uint32_t - l1 = (*i)->info->loc.line, - l2 = (*j)->info->loc.line; + l1 = (*i)->code->fline, + l2 = (*j)->code->fline; error("line %u: code to default rule %sis already defined at line %u", l2, incond(cond).c_str(), l1); exit(1); @@ -140,7 +138,7 @@ static void check(const Spec &spec, const std::string &cond) if (cond == "0" && e - b > 1) { fprintf(stderr, "re2c: error: multiple definitions of startup code (lines "); for (i = b;;) { - fprintf(stderr, "%u", (*i)->info->loc.line); + fprintf(stderr, "%u", (*i)->code->fline); if (++i == e) break; fprintf(stderr, ", "); } @@ -167,11 +165,10 @@ void context_check(Scanner &in, CondList *clist) } } -void context_rule(Scanner &in, CondList *clist, const Loc &loc, - RegExpRule *rule, const Code *code, const std::string *newcond) +void context_rule(Scanner &in, CondList *clist, RegExpRule *rule, const std::string *newcond) { context_check(in, clist); - rule->info = new RuleInfo(loc, code, newcond); + if (newcond) rule->code->cond = *newcond; for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) { const std::string &cond = *i; if (cond != "" && cond != "*" && specMap.find(cond) == specMap.end()) { @@ -192,9 +189,9 @@ void setup_rule(Scanner &in, CondList *clist, const Code * code) { if (ruleSetupMap.find(*it) != ruleSetupMap.end()) { - in.fatalf_at(code->loc.line, "code to setup rule '%s' is already defined", it->c_str()); + in.fatalf_at(code->fline, "code to setup rule '%s' is already defined", it->c_str()); } - ruleSetupMap[*it] = std::make_pair(code->loc.line, code->text); + ruleSetupMap[*it] = std::make_pair(code->fline, code->text); } delete clist; } @@ -260,7 +257,7 @@ typedef union YYSTYPE const re2c::RegExp * regexp; - const re2c::Code * code; + re2c::Code * code; char op; re2c::ExtOp extop; std::string * str; @@ -498,11 +495,11 @@ union yyalloc /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 24 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 16 +#define YYNNTS 15 /* YYNRULES -- Number of rules. */ #define YYNRULES 42 /* YYNRULES -- Number of states. */ -#define YYNSTATES 66 +#define YYNSTATES 73 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -549,38 +546,40 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint8 yyprhs[] = { 0, 0, 3, 4, 7, 10, 13, 17, 21, 24, - 26, 28, 30, 33, 40, 47, 52, 57, 63, 65, - 69, 71, 73, 74, 78, 80, 84, 86, 88, 92, - 94, 98, 100, 103, 105, 108, 111, 113, 115, 118, - 121, 123, 125 + 26, 28, 30, 33, 39, 48, 57, 61, 68, 75, + 81, 83, 87, 89, 91, 93, 97, 99, 101, 105, + 107, 111, 113, 116, 118, 121, 124, 126, 128, 131, + 134, 136, 138 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 25, 0, -1, -1, 25, 6, -1, 25, 26, -1, - 25, 29, -1, 27, 34, 28, -1, 27, 34, 12, + 25, 29, -1, 27, 33, 28, -1, 27, 33, 12, -1, 7, 13, -1, 8, -1, 14, -1, 9, -1, - 33, 5, -1, 15, 30, 16, 33, 32, 5, -1, - 15, 30, 16, 33, 17, 32, -1, 15, 16, 32, - 5, -1, 15, 16, 17, 32, -1, 15, 18, 30, - 16, 5, -1, 31, -1, 30, 19, 31, -1, 7, - -1, 11, -1, -1, 13, 16, 7, -1, 34, -1, - 34, 12, 34, -1, 11, -1, 35, -1, 34, 20, - 35, -1, 36, -1, 35, 21, 36, -1, 37, -1, - 36, 37, -1, 39, -1, 39, 38, -1, 39, 4, - -1, 3, -1, 11, -1, 38, 3, -1, 38, 11, - -1, 7, -1, 10, -1, 22, 34, 23, -1 + 32, 5, -1, 15, 30, 16, 32, 5, -1, 15, + 30, 16, 32, 13, 16, 7, 5, -1, 15, 30, + 16, 32, 17, 13, 16, 7, -1, 15, 16, 5, + -1, 15, 16, 13, 16, 7, 5, -1, 15, 16, + 17, 13, 16, 7, -1, 15, 18, 30, 16, 5, + -1, 31, -1, 30, 19, 31, -1, 7, -1, 11, + -1, 33, -1, 33, 12, 33, -1, 11, -1, 34, + -1, 33, 20, 34, -1, 35, -1, 34, 21, 35, + -1, 36, -1, 35, 36, -1, 38, -1, 38, 37, + -1, 38, 4, -1, 3, -1, 11, -1, 37, 3, + -1, 37, 11, -1, 7, -1, 10, -1, 22, 33, + 23, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 184, 184, 186, 187, 188, 192, 199, 204, 207, - 211, 211, 214, 220, 224, 229, 236, 244, 249, 255, - 262, 263, 268, 271, 278, 282, 287, 292, 296, 303, - 307, 314, 318, 325, 329, 346, 365, 369, 373, 377, - 384, 394, 398 + 0, 181, 181, 183, 184, 185, 189, 196, 201, 204, + 208, 208, 211, 218, 223, 228, 233, 241, 249, 257, + 262, 268, 275, 276, 280, 284, 289, 294, 298, 305, + 309, 316, 320, 327, 331, 348, 367, 371, 375, 379, + 386, 396, 400 }; #endif @@ -593,8 +592,8 @@ static const char *const yytname[] = "TOKEN_CODE", "TOKEN_CONF", "TOKEN_ID", "TOKEN_FID", "TOKEN_FID_END", "TOKEN_REGEXP", "TOKEN_STAR", "'/'", "'='", "';'", "'<'", "'>'", "':'", "'!'", "','", "'|'", "'\\\\'", "'('", "')'", "$accept", "spec", "def", - "name", "enddef", "rule", "clist", "cname", "newcond", "trailexpr", - "expr", "diff", "term", "factor", "close", "primary", 0 + "name", "enddef", "rule", "clist", "cname", "trailexpr", "expr", "diff", + "term", "factor", "close", "primary", 0 }; #endif @@ -613,18 +612,18 @@ static const yytype_uint16 yytoknum[] = static const yytype_uint8 yyr1[] = { 0, 24, 25, 25, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 29, 29, 29, 29, 30, 30, - 31, 31, 32, 32, 33, 33, 33, 34, 34, 35, - 35, 36, 36, 37, 37, 37, 38, 38, 38, 38, - 39, 39, 39 + 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, + 30, 30, 31, 31, 32, 32, 32, 33, 33, 34, + 34, 35, 35, 36, 36, 36, 37, 37, 37, 37, + 38, 38, 38 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 2, 2, 3, 3, 2, 1, - 1, 1, 2, 6, 6, 4, 4, 5, 1, 3, - 1, 1, 0, 3, 1, 3, 1, 1, 3, 1, + 1, 1, 2, 5, 8, 8, 3, 6, 6, 5, + 1, 3, 1, 1, 1, 3, 1, 1, 3, 1, 3, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 1, 3 }; @@ -636,39 +635,41 @@ static const yytype_uint8 yydefact[] = { 2, 0, 1, 3, 40, 9, 41, 26, 0, 0, 4, 0, 5, 0, 24, 27, 29, 31, 33, 8, - 20, 21, 22, 0, 0, 18, 40, 0, 0, 12, - 0, 0, 0, 32, 36, 35, 37, 34, 0, 22, + 22, 23, 0, 0, 0, 20, 40, 0, 0, 12, + 0, 0, 0, 32, 36, 35, 37, 34, 16, 0, 0, 0, 0, 0, 42, 11, 7, 10, 6, 25, - 28, 30, 38, 39, 0, 16, 15, 0, 22, 19, - 23, 17, 22, 0, 14, 13 + 28, 30, 38, 39, 0, 0, 0, 0, 21, 0, + 0, 19, 13, 0, 0, 17, 18, 0, 0, 0, + 0, 14, 15 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 1, 10, 11, 48, 12, 24, 25, 40, 13, - 14, 15, 16, 17, 37, 18 + -1, 1, 10, 11, 48, 12, 24, 25, 13, 14, + 15, 16, 17, 37, 18 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -39 +#define YYPACT_NINF -17 static const yytype_int8 yypact[] = { - -39, 3, -39, -39, -6, -39, -39, -39, 10, 12, - -39, 12, -39, 1, 19, 27, 12, -39, 26, -39, - -39, -39, 28, 35, -11, -39, -39, 31, 24, -39, - 12, 12, 12, -39, -39, -39, -39, 29, 34, 40, - 50, 33, 5, 35, -39, -39, -39, -39, -39, 36, - 27, 12, -39, -39, 51, -39, -39, 52, 30, -39, - -39, -39, 40, 54, -39, -39 + -17, 1, -17, -17, -9, -17, -17, -17, 22, 8, + -17, 8, -17, 12, 24, 0, 8, -17, 38, -17, + -17, -17, 14, -5, 31, -17, -17, 32, 25, -17, + 8, 8, 8, -17, -17, -17, -17, 40, -17, 6, + 13, 37, 3, -5, -17, -17, -17, -17, -17, 26, + 0, 8, -17, -17, 41, 42, 49, 15, -17, 52, + 53, -17, -17, 43, 48, -17, -17, 55, 47, 59, + 58, -17, -17 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -39, -39, -39, -39, -39, -39, 37, 18, -38, 20, - -7, 32, 38, -16, -39, -39 + -17, -17, -17, -17, -17, -17, 44, 23, 27, -6, + 39, 36, -16, -17, -17 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -678,26 +679,26 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 33, 55, 27, 2, 28, 42, 29, 19, 43, 3, - 4, 5, 26, 6, 7, 6, 7, 20, 8, 26, - 63, 21, 6, 49, 64, 9, 22, 9, 23, 34, - 35, 30, 52, 45, 9, 33, 46, 36, 47, 31, - 53, 38, 20, 38, 31, 39, 21, 62, 32, 57, - 54, 31, 43, 38, 44, 56, 31, 61, 60, 65, - 41, 59, 58, 50, 0, 0, 0, 0, 0, 0, - 51 + 33, 2, 20, 27, 19, 28, 21, 3, 4, 5, + 26, 6, 7, 6, 7, 26, 8, 29, 6, 38, + 62, 32, 54, 9, 49, 9, 55, 39, 63, 20, + 9, 40, 64, 21, 45, 33, 30, 46, 22, 47, + 23, 34, 35, 52, 31, 31, 31, 42, 59, 36, + 43, 53, 31, 56, 61, 44, 43, 65, 60, 67, + 66, 68, 69, 70, 71, 72, 58, 41, 51, 57, + 50 }; -static const yytype_int8 yycheck[] = +static const yytype_uint8 yycheck[] = { - 16, 39, 9, 0, 11, 16, 5, 13, 19, 6, - 7, 8, 7, 10, 11, 10, 11, 7, 15, 7, - 58, 11, 10, 30, 62, 22, 16, 22, 18, 3, - 4, 12, 3, 9, 22, 51, 12, 11, 14, 20, - 11, 13, 7, 13, 20, 17, 11, 17, 21, 16, - 16, 20, 19, 13, 23, 5, 20, 5, 7, 5, - 23, 43, 42, 31, -1, -1, -1, -1, -1, -1, - 32 + 16, 0, 7, 9, 13, 11, 11, 6, 7, 8, + 7, 10, 11, 10, 11, 7, 15, 5, 10, 5, + 5, 21, 16, 22, 30, 22, 13, 13, 13, 7, + 22, 17, 17, 11, 9, 51, 12, 12, 16, 14, + 18, 3, 4, 3, 20, 20, 20, 16, 7, 11, + 19, 11, 20, 16, 5, 23, 19, 5, 16, 16, + 7, 13, 7, 16, 5, 7, 43, 23, 32, 42, + 31 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -705,12 +706,13 @@ static const yytype_int8 yycheck[] = static const yytype_uint8 yystos[] = { 0, 25, 0, 6, 7, 8, 10, 11, 15, 22, - 26, 27, 29, 33, 34, 35, 36, 37, 39, 13, - 7, 11, 16, 18, 30, 31, 7, 34, 34, 5, - 12, 20, 21, 37, 3, 4, 11, 38, 13, 17, - 32, 30, 16, 19, 23, 9, 12, 14, 28, 34, - 35, 36, 3, 11, 16, 32, 5, 16, 33, 31, - 7, 5, 17, 32, 32, 5 + 26, 27, 29, 32, 33, 34, 35, 36, 38, 13, + 7, 11, 16, 18, 30, 31, 7, 33, 33, 5, + 12, 20, 21, 36, 3, 4, 11, 37, 5, 13, + 17, 30, 16, 19, 23, 9, 12, 14, 28, 33, + 34, 35, 3, 11, 16, 13, 16, 32, 31, 7, + 16, 5, 5, 13, 17, 5, 7, 16, 13, 7, + 16, 5, 7 }; #define yyerrok (yyerrstatus = 0) @@ -1572,32 +1574,32 @@ yyreduce: { CondList *cl = new CondList; cl->insert(""); - context_rule(in, cl, (yyvsp[(2) - (2)].code)->loc, (yyvsp[(1) - (2)].rule), (yyvsp[(2) - (2)].code), NULL); + (yyvsp[(1) - (2)].rule)->code = (yyvsp[(2) - (2)].code); + context_rule(in, cl, (yyvsp[(1) - (2)].rule), NULL); ;} break; case 13: { - context_rule(in, (yyvsp[(2) - (6)].clist), (yyvsp[(6) - (6)].code)->loc, (yyvsp[(4) - (6)].rule), (yyvsp[(6) - (6)].code), (yyvsp[(5) - (6)].str)); + (yyvsp[(4) - (5)].rule)->code = (yyvsp[(5) - (5)].code); + context_rule(in, (yyvsp[(2) - (5)].clist), (yyvsp[(4) - (5)].rule), NULL); ;} break; case 14: { - Loc loc(in.get_fname(), in.get_cline()); - context_rule(in, (yyvsp[(2) - (6)].clist), loc, (yyvsp[(4) - (6)].rule), NULL, (yyvsp[(6) - (6)].str)); + (yyvsp[(4) - (8)].rule)->code = (yyvsp[(8) - (8)].code); + context_rule(in, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), (yyvsp[(7) - (8)].str)); ;} break; case 15: { - CondList *cl = new CondList; - cl->insert("0"); - RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); - context_rule(in, cl, (yyvsp[(4) - (4)].code)->loc, r, (yyvsp[(4) - (4)].code), (yyvsp[(3) - (4)].str)); + (yyvsp[(4) - (8)].rule)->code = new Code(in.get_fname(), in.get_cline()); + context_rule(in, (yyvsp[(2) - (8)].clist), (yyvsp[(4) - (8)].rule), (yyvsp[(8) - (8)].str)); ;} break; @@ -1607,53 +1609,61 @@ yyreduce: CondList *cl = new CondList; cl->insert("0"); RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); - Loc loc(in.get_fname(), in.get_cline()); - context_rule(in, cl, loc, r, NULL, (yyvsp[(4) - (4)].str)); + r->code = (yyvsp[(3) - (3)].code); + context_rule(in, cl, r, NULL); ;} break; case 17: { - setup_rule(in, (yyvsp[(3) - (5)].clist), (yyvsp[(5) - (5)].code)); + CondList *cl = new CondList; + cl->insert("0"); + RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); + r->code = (yyvsp[(6) - (6)].code); + context_rule(in, cl, r, (yyvsp[(5) - (6)].str)); ;} break; case 18: { - (yyval.clist) = new CondList; - (yyval.clist)->insert(*(yyvsp[(1) - (1)].str)); - delete (yyvsp[(1) - (1)].str); + CondList *cl = new CondList; + cl->insert("0"); + RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); + r->code = new Code(in.get_fname(), in.get_cline()); + context_rule(in, cl, r, (yyvsp[(6) - (6)].str)); ;} break; case 19: { - (yyvsp[(1) - (3)].clist)->insert(*(yyvsp[(3) - (3)].str)); - delete (yyvsp[(3) - (3)].str); - (yyval.clist) = (yyvsp[(1) - (3)].clist); + setup_rule(in, (yyvsp[(3) - (5)].clist), (yyvsp[(5) - (5)].code)); ;} break; - case 21: + case 20: - { (yyval.str) = new std::string("*"); ;} + { + (yyval.clist) = new CondList; + (yyval.clist)->insert(*(yyvsp[(1) - (1)].str)); + delete (yyvsp[(1) - (1)].str); + ;} break; - case 22: + case 21: { - (yyval.str) = NULL; - ;} + (yyvsp[(1) - (3)].clist)->insert(*(yyvsp[(3) - (3)].str)); + delete (yyvsp[(3) - (3)].str); + (yyval.clist) = (yyvsp[(1) - (3)].clist); + ;} break; case 23: - { - (yyval.str) = (yyvsp[(3) - (3)].str); - ;} + { (yyval.str) = new std::string("*"); ;} break; case 24: @@ -2183,7 +2193,6 @@ void parse_cleanup() RegExp::flist.clear(); Range::vFreeList.clear(); RangeSuffix::freeList.clear(); - Code::freelist.clear(); symbol_table.clear (); condnames.clear (); specMap.clear(); diff --git a/re2c/bootstrap/src/parse/y.tab.h b/re2c/bootstrap/src/parse/y.tab.h index 58acf933..6a5ec4d2 100644 --- a/re2c/bootstrap/src/parse/y.tab.h +++ b/re2c/bootstrap/src/parse/y.tab.h @@ -58,7 +58,7 @@ typedef union YYSTYPE const re2c::RegExp * regexp; - const re2c::Code * code; + re2c::Code * code; char op; re2c::ExtOp extop; std::string * str; diff --git a/re2c/src/codegen/emit_action.cc b/re2c/src/codegen/emit_action.cc index 38982f9f..a6b59b9b 100644 --- a/re2c/src/codegen/emit_action.cc +++ b/re2c/src/codegen/emit_action.cc @@ -10,8 +10,6 @@ #include "src/ir/adfa/adfa.h" #include "src/ir/regexp/regexp.h" #include "src/ir/skeleton/skeleton.h" -#include "src/parse/code.h" -#include "src/parse/loc.h" #include "src/util/string_utils.h" namespace re2c @@ -208,8 +206,8 @@ void emit_rule(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rule_idx) { Opt &opts = o.opts; const Rule &rule = dfa.rules[rule_idx]; - const std::string &cond = rule.info->newcond; - const Code *code = rule.info->code; + const Code *code = rule.code; + const std::string &cond = code->cond; std::string s; gen_fintags(o, ind, dfa, rule); @@ -227,12 +225,13 @@ void emit_rule(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rule_idx) } o.ws("\n"); } - if (code) { + + if (!code->autogen) { const std::string setup = o.block().setup_rule; if (!setup.empty()) { o.wind(ind).wstring(setup).ws("\n"); } - o.wline_info(code->loc.line, code->loc.filename.c_str()) + o.wline_info(code->fline, code->fname.c_str()) .wind(ind).wstring(code->text).ws("\n") .wdelay_line_info(); } else if (!cond.empty()) { diff --git a/re2c/src/codegen/emit_dfa.cc b/re2c/src/codegen/emit_dfa.cc index c49dc06a..5f308c37 100644 --- a/re2c/src/codegen/emit_dfa.cc +++ b/re2c/src/codegen/emit_dfa.cc @@ -122,11 +122,11 @@ void DFA::emit_dot( .wu32(i).ws("\"]").ws("\n"); } } else if (s->action.type == Action::RULE) { - const Code *code = rules[s->action.info.rule].info->code; - if (code) { + const Code *code = rules[s->action.info.rule].code; + if (!code->autogen) { o.wlabel(s->label).ws(" [label=\"") - .wstring(code->loc.filename) - .ws(":").wu32(code->loc.line) + .wstring(code->fname) + .ws(":").wu32(code->fline) .ws("\"]").ws("\n"); } } diff --git a/re2c/src/conf/warn.cc b/re2c/src/conf/warn.cc index f6e6d992..42972189 100644 --- a/re2c/src/conf/warn.cc +++ b/re2c/src/conf/warn.cc @@ -188,7 +188,7 @@ void Warn::unreachable_rule(const std::string &cond, const Rule &rule) const bool e = mask[UNREACHABLE_RULES] & ERROR; error_accuml |= e; - warning_start(rule.info->loc.line, e); + warning_start(rule.code->fline, e); fprintf(stderr, "unreachable rule %s", incond(cond).c_str()); const size_t shadows = rule.shadow.size(); if (shadows > 0) { diff --git a/re2c/src/ir/dfa/closure.cc b/re2c/src/ir/dfa/closure.cc index f04e5bdf..b4e4f919 100644 --- a/re2c/src/ir/dfa/closure.cc +++ b/re2c/src/ir/dfa/closure.cc @@ -185,7 +185,7 @@ void prune_final_items(closure_t &clos, std::valarray &rules) if (f != e) { std::partial_sort(f, f, e, compare_by_rule); // mark all rules except the first one as shadowed - const uint32_t line = rules[f->state->rule].info->loc.line; + const uint32_t line = rules[f->state->rule].code->fline; for (cclositer_t c = f + 1; c != e; ++c) { rules[c->state->rule].shadow.insert(line); } diff --git a/re2c/src/ir/dfa/dead_rules.cc b/re2c/src/ir/dfa/dead_rules.cc index 39b0ab87..b6eefc5c 100644 --- a/re2c/src/ir/dfa/dead_rules.cc +++ b/re2c/src/ir/dfa/dead_rules.cc @@ -142,7 +142,7 @@ static void warn_dead_rules(const dfa_t &dfa, size_t defrule, // skip last rule (it's the NONE-rule) for (size_t j = 0; j < nrules; ++j) { if (live[j * nstates + i]) { - dfa.rules[r].shadow.insert(dfa.rules[j].info->loc.line); + dfa.rules[r].shadow.insert(dfa.rules[j].code->fline); } } } diff --git a/re2c/src/ir/dfa/determinization.cc b/re2c/src/ir/dfa/determinization.cc index 49be63e7..65dd61cc 100644 --- a/re2c/src/ir/dfa/determinization.cc +++ b/re2c/src/ir/dfa/determinization.cc @@ -138,7 +138,7 @@ void warn_nondeterministic_tags(const kernels_t &kernels, const size_t m = maxv[t]; if (m > 1) { const VarTag &tag = tags[t]; - const uint32_t line = rules[tag.rule].info->loc.line; + const uint32_t line = rules[tag.rule].code->fline; warn.nondeterministic_tags(line, cond, tag.name, m); } } diff --git a/re2c/src/ir/nfa/init_rules.cc b/re2c/src/ir/nfa/init_rules.cc index 9afdf8d6..f1399b7d 100644 --- a/re2c/src/ir/nfa/init_rules.cc +++ b/re2c/src/ir/nfa/init_rules.cc @@ -25,7 +25,7 @@ static void assert_tags_used_once(const Rule &rule, error: error("line %u: tag '%s' is used multiple times in the same rule", - rule.info->loc.line, name->c_str()); + rule.code->fline, name->c_str()); exit(1); } @@ -40,7 +40,7 @@ void init_rules(const std::vector ®exps, for (size_t r = 0, v = 0, f = 0, t; r < nr; ++r) { Rule &rule = rules[r]; - rule.info = regexps[r]->info; + rule.code = regexps[r]->code; rule.lvar = v; for (; v < nv && vartags[v].rule == r; ++v); diff --git a/re2c/src/ir/regexp/nullable.cc b/re2c/src/ir/regexp/nullable.cc index 00a1ccc8..83b1e98b 100644 --- a/re2c/src/ir/regexp/nullable.cc +++ b/re2c/src/ir/regexp/nullable.cc @@ -39,7 +39,7 @@ void warn_nullable(const std::vector ®exps, const RegExpRule *r = regexps[i]; bool trail = false; if (nullable(r->re, trail)) { - warn.match_empty_string(r->info->loc.line, cond); + warn.match_empty_string(r->code->fline, cond); } } } diff --git a/re2c/src/ir/regexp/regexp.h b/re2c/src/ir/regexp/regexp.h index 975bcadb..d37439b8 100644 --- a/re2c/src/ir/regexp/regexp.h +++ b/re2c/src/ir/regexp/regexp.h @@ -108,19 +108,19 @@ struct RegExpRule static free_list flist; const RegExp *re; - RuleInfo *info; + Code *code; bool def; RegExpRule(const RegExp *r, bool d) : re(r) - , info(NULL) + , code(NULL) , def(d) { flist.insert(this); } ~RegExpRule() { - delete info; + delete code; flist.erase(this); } static bool is_def(const RegExpRule *r) { return r->def; } diff --git a/re2c/src/ir/rule.h b/re2c/src/ir/rule.h index e74683a0..fbe3c89b 100644 --- a/re2c/src/ir/rule.h +++ b/re2c/src/ir/rule.h @@ -1,39 +1,45 @@ #ifndef _RE2C_IR_RULE_ #define _RE2C_IR_RULE_ +#include "src/util/c99_stdint.h" #include #include -#include #include "src/ir/tag.h" -#include "src/parse/code.h" -#include "src/parse/loc.h" #include "src/util/forbid_copy.h" namespace re2c { -struct RuleInfo +struct Code { - const Loc loc; - const Code *code; - const std::string newcond; + std::string fname; + uint32_t fline; + bool autogen; + const std::string text; + std::string cond; - RuleInfo(const Loc &l, const Code *c, - const std::string *cond) - : loc(l) - , code(c) - , newcond(cond ? *cond : "") + Code(const std::string &file, uint32_t line) + : fname(file) + , fline(line) + , autogen(true) + , text("") + , cond("") + {} + Code(const std::string &file, uint32_t line, const char *s, size_t slen) + : fname(file) + , fline(line) + , autogen(false) + , text(s, slen) + , cond("") {} - - FORBID_COPY(RuleInfo); }; struct Rule { static const size_t NONE; - const RuleInfo *info; + const Code *code; std::set shadow; // variable tags @@ -46,7 +52,7 @@ struct Rule size_t hfix; // next to last size_t tfix; // trailing context - Rule(): info(NULL), shadow(), + Rule(): code(NULL), shadow(), lvar(0), hvar(0), tvar(0), lfix(0), hfix(0), tfix(0) {} diff --git a/re2c/src/parse/code.cc b/re2c/src/parse/code.cc deleted file mode 100644 index 97a865ce..00000000 --- a/re2c/src/parse/code.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "src/parse/code.h" - -namespace re2c -{ - -free_list Code::freelist; - -} // namespace re2c diff --git a/re2c/src/parse/code.h b/re2c/src/parse/code.h deleted file mode 100644 index d658e628..00000000 --- a/re2c/src/parse/code.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _RE2C_PARSE_CODE_ -#define _RE2C_PARSE_CODE_ - -#include "src/util/c99_stdint.h" -#include -#include - -#include "src/parse/loc.h" -#include "src/util/free_list.h" - -namespace re2c -{ - -struct Code -{ - static free_list freelist; - - const Loc loc; - const std::string text; - - inline Code (const char * t, size_t t_len, const std::string & f, uint32_t l) - : loc (f, l) - , text (t, t_len) - { - freelist.insert (this); - } -}; - -} // namespace re2c - -#endif // _RE2C_PARSE_CODE_ diff --git a/re2c/src/parse/lex.re b/re2c/src/parse/lex.re index d9a2cfa1..58de6e8c 100644 --- a/re2c/src/parse/lex.re +++ b/re2c/src/parse/lex.re @@ -8,7 +8,6 @@ #include "src/codegen/output.h" #include "src/ir/regexp/encoding/enc.h" #include "src/ir/regexp/regexp.h" -#include "src/parse/code.h" #include "src/parse/extop.h" #include "src/parse/input.h" #include "src/parse/scanner.h" @@ -415,7 +414,7 @@ code: } else if (--depth == 0) { - yylval.code = new Code (tok, tok_len (), get_fname (), code_line); + yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); return TOKEN_CODE; } goto code; @@ -456,7 +455,7 @@ code: { --cur; } - yylval.code = new Code (tok, tok_len (), get_fname (), code_line); + yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); return TOKEN_CODE; } else if (cur == eof) diff --git a/re2c/src/parse/loc.h b/re2c/src/parse/loc.h deleted file mode 100644 index b3d4277a..00000000 --- a/re2c/src/parse/loc.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _RE2C_PARSE_LOC_ -#define _RE2C_PARSE_LOC_ - -#include - -#include "src/util/c99_stdint.h" - -namespace re2c -{ - -struct Loc -{ - std::string filename; - uint32_t line; - - inline Loc (const std::string & f, uint32_t l) - : filename (f) - , line (l) - {} -}; - -} // namespace re2c - -#endif // _RE2C_PARSE_LOC_ diff --git a/re2c/src/parse/parser.ypp b/re2c/src/parse/parser.ypp index 52c95248..e1746c5e 100644 --- a/re2c/src/parse/parser.ypp +++ b/re2c/src/parse/parser.ypp @@ -20,9 +20,7 @@ #include "src/ir/regexp/encoding/range_suffix.h" #include "src/ir/regexp/regexp.h" #include "src/ir/skeleton/skeleton.h" -#include "src/parse/code.h" #include "src/parse/extop.h" -#include "src/parse/loc.h" #include "src/parse/parser.h" #include "src/parse/scanner.h" #include "src/util/free_list.h" @@ -61,8 +59,8 @@ static void check(const Spec &spec, const std::string &cond) j = std::find_if(i + 1, e, RegExpRule::is_def); if (j != e) { const uint32_t - l1 = (*i)->info->loc.line, - l2 = (*j)->info->loc.line; + l1 = (*i)->code->fline, + l2 = (*j)->code->fline; error("line %u: code to default rule %sis already defined at line %u", l2, incond(cond).c_str(), l1); exit(1); @@ -72,7 +70,7 @@ static void check(const Spec &spec, const std::string &cond) if (cond == "0" && e - b > 1) { fprintf(stderr, "re2c: error: multiple definitions of startup code (lines "); for (i = b;;) { - fprintf(stderr, "%u", (*i)->info->loc.line); + fprintf(stderr, "%u", (*i)->code->fline); if (++i == e) break; fprintf(stderr, ", "); } @@ -99,11 +97,10 @@ void context_check(Scanner &in, CondList *clist) } } -void context_rule(Scanner &in, CondList *clist, const Loc &loc, - RegExpRule *rule, const Code *code, const std::string *newcond) +void context_rule(Scanner &in, CondList *clist, RegExpRule *rule, const std::string *newcond) { context_check(in, clist); - rule->info = new RuleInfo(loc, code, newcond); + if (newcond) rule->code->cond = *newcond; for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) { const std::string &cond = *i; if (cond != "" && cond != "*" && specMap.find(cond) == specMap.end()) { @@ -124,9 +121,9 @@ void setup_rule(Scanner &in, CondList *clist, const Code * code) { if (ruleSetupMap.find(*it) != ruleSetupMap.end()) { - in.fatalf_at(code->loc.line, "code to setup rule '%s' is already defined", it->c_str()); + in.fatalf_at(code->fline, "code to setup rule '%s' is already defined", it->c_str()); } - ruleSetupMap[*it] = std::make_pair(code->loc.line, code->text); + ruleSetupMap[*it] = std::make_pair(code->fline, code->text); } delete clist; } @@ -153,7 +150,7 @@ static std::string find_setup_rule(const SetupMap &map, const std::string &key) %union { const re2c::RegExp * regexp; - const re2c::Code * code; + re2c::Code * code; char op; re2c::ExtOp extop; std::string * str; @@ -175,7 +172,7 @@ static std::string find_setup_rule(const SetupMap &map, const std::string &key) %type TOKEN_CLOSESIZE %type TOKEN_CODE %type TOKEN_REGEXP rule expr diff term factor primary -%type TOKEN_ID TOKEN_FID newcond name cname +%type TOKEN_ID TOKEN_FID name cname %type clist %type trailexpr @@ -214,31 +211,47 @@ rule : trailexpr TOKEN_CODE { CondList *cl = new CondList; cl->insert(""); - context_rule(in, cl, $2->loc, $1, $2, NULL); + $1->code = $2; + context_rule(in, cl, $1, NULL); } - | '<' clist '>' trailexpr newcond TOKEN_CODE { - context_rule(in, $2, $6->loc, $4, $6, $5); + | '<' clist '>' trailexpr TOKEN_CODE { + $4->code = $5; + context_rule(in, $2, $4, NULL); } - | '<' clist '>' trailexpr ':' newcond { - Loc loc(in.get_fname(), in.get_cline()); - context_rule(in, $2, loc, $4, NULL, $6); + | '<' clist '>' trailexpr '=' '>' TOKEN_ID TOKEN_CODE { + $4->code = $8; + context_rule(in, $2, $4, $7); } - | '<' '>' newcond TOKEN_CODE { + | '<' clist '>' trailexpr ':' '=' '>' TOKEN_ID { + $4->code = new Code(in.get_fname(), in.get_cline()); + context_rule(in, $2, $4, $8); + } + + | '<' '>' TOKEN_CODE { + CondList *cl = new CondList; + cl->insert("0"); + RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); + r->code = $3; + context_rule(in, cl, r, NULL); + } + + | '<' '>' '=' '>' TOKEN_ID TOKEN_CODE { CondList *cl = new CondList; cl->insert("0"); RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); - context_rule(in, cl, $4->loc, r, $4, $3); + r->code = $6; + context_rule(in, cl, r, $5); } - | '<' '>' ':' newcond { + | '<' '>' ':' '=' '>' TOKEN_ID { CondList *cl = new CondList; cl->insert("0"); RegExpRule *r = new RegExpRule(RegExp::make_nil(), false); - Loc loc(in.get_fname(), in.get_cline()); - context_rule(in, cl, loc, r, NULL, $4); + r->code = new Code(in.get_fname(), in.get_cline()); + context_rule(in, cl, r, $6); } | '<' '!' clist '>' TOKEN_CODE { @@ -263,17 +276,6 @@ cname | TOKEN_STAR { $$ = new std::string("*"); } ; -newcond: - /* empty */ - { - $$ = NULL; - } - | '=' '>' TOKEN_ID - { - $$ = $3; - } -; - trailexpr : expr { $$ = new RegExpRule($1, false); @@ -551,7 +553,6 @@ void parse_cleanup() RegExp::flist.clear(); Range::vFreeList.clear(); RangeSuffix::freeList.clear(); - Code::freelist.clear(); symbol_table.clear (); condnames.clear (); specMap.clear(); -- 2.40.0