From: Ulya Trofimovich Date: Thu, 27 Dec 2018 22:08:38 +0000 (+0000) Subject: Track current line of each input file separately. X-Git-Tag: 1.2~280 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8edf3ff2526476c97cc921b2f2c4f30d05387376;p=re2c Track current line of each input file separately. --- diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 69b6290b..8aa85bb2 100644 --- a/re2c/bootstrap/src/ast/lex.cc +++ b/re2c/bootstrap/src/ast/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Wed Dec 26 11:34:46 2018 */ +/* Generated by re2c 1.1.1 on Thu Dec 27 21:57:09 2018 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include @@ -33,7 +33,7 @@ namespace re2c { #line 55 "../src/ast/lex.re" -#line 113 "../src/ast/lex.re" +#line 111 "../src/ast/lex.re" Scanner::ParseMode Scanner::echo(Output &out) @@ -103,7 +103,7 @@ echo: } } ++YYCURSOR; -#line 209 "../src/ast/lex.re" +#line 207 "../src/ast/lex.re" { if (!is_eof()) goto echo; out.wraw(tok, ptr); @@ -113,7 +113,7 @@ echo: yy4: ++YYCURSOR; yy5: -#line 227 "../src/ast/lex.re" +#line 224 "../src/ast/lex.re" { goto echo; } #line 119 "src/ast/lex.cc" yy6: @@ -124,13 +124,12 @@ yy6: } if (yych == '#') goto yy14; yy7: -#line 221 "../src/ast/lex.re" +#line 219 "../src/ast/lex.re" { - cline++; - pos = cur; + next_line(); goto echo; } -#line 134 "src/ast/lex.cc" +#line 133 "src/ast/lex.cc" yy8: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy6; @@ -173,12 +172,12 @@ yy14: } yy16: ++YYCURSOR; -#line 124 "../src/ast/lex.re" +#line 122 "../src/ast/lex.re" { out.wraw(tok, ptr); return Parse; } -#line 182 "src/ast/lex.cc" +#line 181 "src/ast/lex.cc" yy18: yych = (YYCTYPE)*++YYCURSOR; if (yych == '!') goto yy20; @@ -474,13 +473,13 @@ yy80: yy82: ++YYCURSOR; YYCURSOR = yyt1; -#line 215 "../src/ast/lex.re" +#line 213 "../src/ast/lex.re" { out.wraw(tok, ptr + 1); set_sourceline(); goto echo; } -#line 484 "src/ast/lex.cc" +#line 483 "src/ast/lex.cc" yy84: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy82; @@ -613,14 +612,14 @@ yy114: goto yy13; yy115: ++YYCURSOR; -#line 145 "../src/ast/lex.re" +#line 143 "../src/ast/lex.re" { out.wraw(tok, ptr); out.wdelay_yymaxfill(); lex_end_of_comment(out); goto echo; } -#line 624 "src/ast/lex.cc" +#line 623 "src/ast/lex.cc" yy117: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'h') goto yy128; @@ -643,12 +642,12 @@ yy121: goto yy13; yy122: ++YYCURSOR; -#line 134 "../src/ast/lex.re" +#line 132 "../src/ast/lex.re" { out.wraw(tok, ptr); return Reuse; } -#line 652 "src/ast/lex.cc" +#line 651 "src/ast/lex.cc" yy124: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy133; @@ -707,42 +706,42 @@ yy137: goto yy13; yy138: ++YYCURSOR; -#line 181 "../src/ast/lex.re" +#line 179 "../src/ast/lex.re" { out.wraw(tok, ptr); lex_tags(out, true); goto echo; } -#line 717 "src/ast/lex.cc" +#line 716 "src/ast/lex.cc" yy140: ++YYCURSOR; -#line 129 "../src/ast/lex.re" +#line 127 "../src/ast/lex.re" { out.wraw(tok, ptr); return Rules; } -#line 725 "src/ast/lex.cc" +#line 724 "src/ast/lex.cc" yy142: ++YYCURSOR; -#line 175 "../src/ast/lex.re" +#line 173 "../src/ast/lex.re" { out.wraw(tok, ptr); lex_tags(out, false); goto echo; } -#line 734 "src/ast/lex.cc" +#line 733 "src/ast/lex.cc" yy144: ++YYCURSOR; -#line 166 "../src/ast/lex.re" +#line 164 "../src/ast/lex.re" { out.wraw(tok, ptr); out.wdelay_line_info_output(); out.wdelay_types(); - out.wdelay_line_info_input(cline, get_fname()); + out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); goto echo; } -#line 746 "src/ast/lex.cc" +#line 745 "src/ast/lex.cc" yy146: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy152; @@ -753,13 +752,13 @@ yy147: goto yy13; yy148: ++YYCURSOR; -#line 139 "../src/ast/lex.re" +#line 137 "../src/ast/lex.re" { out.wraw(tok, ptr); lex_end_of_comment(out); goto echo; } -#line 763 "src/ast/lex.cc" +#line 762 "src/ast/lex.cc" yy150: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy154; @@ -778,27 +777,27 @@ yy153: goto yy13; yy154: ++YYCURSOR; -#line 203 "../src/ast/lex.re" +#line 201 "../src/ast/lex.re" { out.wraw(tok, ptr); lex_include(); goto echo; } -#line 788 "src/ast/lex.cc" +#line 787 "src/ast/lex.cc" yy156: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy160; goto yy13; yy157: ++YYCURSOR; -#line 159 "../src/ast/lex.re" +#line 157 "../src/ast/lex.re" { out.wraw(tok, ptr); out.wdelay_state_goto(0); lex_end_of_comment(out); goto echo; } -#line 802 "src/ast/lex.cc" +#line 801 "src/ast/lex.cc" yy159: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'f') goto yy161; @@ -814,7 +813,7 @@ yy161: goto yy13; yy162: ++YYCURSOR; -#line 187 "../src/ast/lex.re" +#line 185 "../src/ast/lex.re" { out.wraw(tok, ptr); out.header_mode(true); @@ -822,37 +821,38 @@ yy162: lex_end_of_comment(out); goto echo; } -#line 826 "src/ast/lex.cc" +#line 825 "src/ast/lex.cc" yy164: ++YYCURSOR; -#line 152 "../src/ast/lex.re" +#line 150 "../src/ast/lex.re" { out.wraw(tok, ptr); out.wdelay_yymaxnmatch(); lex_end_of_comment(out); goto echo; } -#line 836 "src/ast/lex.cc" +#line 835 "src/ast/lex.cc" yy166: ++YYCURSOR; -#line 195 "../src/ast/lex.re" +#line 193 "../src/ast/lex.re" { out.wraw(tok, ptr); out.header_mode(false); - out.wdelay_line_info_input(cline, get_fname()); + out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); goto echo; } -#line 847 "src/ast/lex.cc" +#line 846 "src/ast/lex.cc" } -#line 228 "../src/ast/lex.re" +#line 225 "../src/ast/lex.re" } void Scanner::lex_end_of_comment(Output &out) { - uint32_t ignored = 0; + bool multiline = false; for (;;) { + #line 857 "src/ast/lex.cc" { YYCTYPE yych; @@ -869,19 +869,19 @@ void Scanner::lex_end_of_comment(Output &out) } yy170: ++YYCURSOR; -#line 235 "../src/ast/lex.re" - { fatal_lc(get_cline(), get_column(), "expected end of block"); } +#line 233 "../src/ast/lex.re" + { fatal_lc(get_line(), get_column(), "expected end of block"); } #line 875 "src/ast/lex.cc" yy172: ++YYCURSOR; yy173: -#line 237 "../src/ast/lex.re" +#line 234 "../src/ast/lex.re" { continue; } #line 881 "src/ast/lex.cc" yy174: ++YYCURSOR; -#line 238 "../src/ast/lex.re" - { ++ignored; continue; } +#line 235 "../src/ast/lex.re" + { next_line(); multiline = true; continue; } #line 886 "src/ast/lex.cc" yy176: yych = (YYCTYPE)*++YYCURSOR; @@ -891,18 +891,17 @@ yy177: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy173; ++YYCURSOR; -#line 239 "../src/ast/lex.re" +#line 236 "../src/ast/lex.re" { - if (ignored > 0) { - cline += ignored; - out.wdelay_line_info_input(cline, get_fname()); + if (multiline) { + out.wdelay_line_info_input(get_line(), get_fname()); } - tok = pos = cur; + tok = cur; return; } -#line 904 "src/ast/lex.cc" +#line 903 "src/ast/lex.cc" } -#line 247 "../src/ast/lex.re" +#line 243 "../src/ast/lex.re" } } @@ -910,7 +909,7 @@ void Scanner::lex_include() { const char *x, *y; -#line 914 "src/ast/lex.cc" +#line 913 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -953,12 +952,12 @@ void Scanner::lex_include() if (yych == ' ') goto yy184; ++YYCURSOR; yy183: -#line 254 "../src/ast/lex.re" +#line 250 "../src/ast/lex.re" { - fatal_lc(get_cline(), get_column() + fatal_lc(get_line(), get_column() , "syntax error in include directive"); } -#line 962 "src/ast/lex.cc" +#line 961 "src/ast/lex.cc" yy184: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 64) { @@ -1034,14 +1033,14 @@ yy194: ++YYCURSOR; x = yyt1; y = yyt2; -#line 259 "../src/ast/lex.re" +#line 255 "../src/ast/lex.re" { include(std::string(x + 1, static_cast(y - x) - 2)); return; } -#line 1043 "src/ast/lex.cc" +#line 1042 "src/ast/lex.cc" } -#line 263 "../src/ast/lex.re" +#line 259 "../src/ast/lex.re" } @@ -1049,6 +1048,7 @@ void Scanner::lex_tags(Output &out, bool mtags) { std::string fmt, sep; for (;;) { + #line 1053 "src/ast/lex.cc" { YYCTYPE yych; @@ -1107,8 +1107,8 @@ void Scanner::lex_tags(Output &out, bool mtags) } ++YYCURSOR; yy200: -#line 270 "../src/ast/lex.re" - { fatal_lc(get_cline(), get_column(), "unrecognized configuration"); } +#line 267 "../src/ast/lex.re" + { fatal_lc(get_line(), get_column(), "unrecognized configuration"); } #line 1113 "src/ast/lex.cc" yy201: ++YYCURSOR; @@ -1117,13 +1117,13 @@ yy201: if (yybm[0+yych] & 128) { goto yy201; } -#line 275 "../src/ast/lex.re" +#line 272 "../src/ast/lex.re" { continue; } #line 1123 "src/ast/lex.cc" yy204: ++YYCURSOR; -#line 276 "../src/ast/lex.re" - { ++cline; continue; } +#line 273 "../src/ast/lex.re" + { next_line(); continue; } #line 1128 "src/ast/lex.cc" yy206: yych = (YYCTYPE)*++YYCURSOR; @@ -1143,10 +1143,10 @@ yy209: goto yy200; yy210: ++YYCURSOR; -#line 277 "../src/ast/lex.re" +#line 274 "../src/ast/lex.re" { out.wdelay_tags(new ConfTags(fmt, sep), mtags); - tok = pos = cur; + tok = cur; return; } #line 1153 "src/ast/lex.cc" @@ -1186,7 +1186,7 @@ yy220: goto yy213; yy221: ++YYCURSOR; -#line 272 "../src/ast/lex.re" +#line 269 "../src/ast/lex.re" { fmt = lex_conf_string(); continue; } #line 1192 "src/ast/lex.cc" yy223: @@ -1197,11 +1197,11 @@ yy223: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'r') goto yy213; ++YYCURSOR; -#line 273 "../src/ast/lex.re" +#line 270 "../src/ast/lex.re" { sep = lex_conf_string(); continue; } #line 1203 "src/ast/lex.cc" } -#line 282 "../src/ast/lex.re" +#line 279 "../src/ast/lex.re" } } @@ -1322,9 +1322,9 @@ scan: yy230: ++YYCURSOR; yy231: -#line 409 "../src/ast/lex.re" +#line 405 "../src/ast/lex.re" { - fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); + fatal_lc(get_line(), get_column(), "unexpected character: '%c'", *tok); goto scan; } #line 1331 "src/ast/lex.cc" @@ -1335,7 +1335,7 @@ yy232: if (yybm[0+yych] & 16) { goto yy232; } -#line 390 "../src/ast/lex.re" +#line 387 "../src/ast/lex.re" { goto scan; } #line 1341 "src/ast/lex.cc" yy235: @@ -1348,10 +1348,9 @@ yy235: if (yych == '#') goto yy265; } yy236: -#line 397 "../src/ast/lex.re" +#line 394 "../src/ast/lex.re" { - pos = cur; - cline++; + next_line(); if (lexer_state == LEX_FLEX_NAME) { lexer_state = LEX_NORMAL; return TOKEN_FID_END; @@ -1360,16 +1359,16 @@ yy236: goto scan; } } -#line 1364 "src/ast/lex.cc" +#line 1363 "src/ast/lex.cc" yy237: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy235; goto yy231; yy238: ++YYCURSOR; -#line 308 "../src/ast/lex.re" +#line 305 "../src/ast/lex.re" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; } -#line 1373 "src/ast/lex.cc" +#line 1372 "src/ast/lex.cc" yy240: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '^') { @@ -1384,30 +1383,30 @@ yy240: yy241: ++YYCURSOR; yy242: -#line 318 "../src/ast/lex.re" +#line 315 "../src/ast/lex.re" { return *tok; } -#line 1390 "src/ast/lex.cc" +#line 1389 "src/ast/lex.cc" yy243: yych = (YYCTYPE)*++YYCURSOR; if (yych == '}') goto yy270; goto yy231; yy244: ++YYCURSOR; -#line 307 "../src/ast/lex.re" +#line 304 "../src/ast/lex.re" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; } -#line 1399 "src/ast/lex.cc" +#line 1398 "src/ast/lex.cc" yy246: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy270; goto yy242; yy247: ++YYCURSOR; -#line 385 "../src/ast/lex.re" +#line 382 "../src/ast/lex.re" { - yylval.regexp = ast_dot(cline, get_column()); + yylval.regexp = ast_dot(get_line(), get_column()); return TOKEN_REGEXP; } -#line 1411 "src/ast/lex.cc" +#line 1410 "src/ast/lex.cc" yy249: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy272; @@ -1419,9 +1418,9 @@ yy250: goto yy231; yy251: ++YYCURSOR; -#line 300 "../src/ast/lex.re" +#line 297 "../src/ast/lex.re" { return lex_clist(); } -#line 1425 "src/ast/lex.cc" +#line 1424 "src/ast/lex.cc" yy253: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1435,7 +1434,7 @@ yy255: if (yybm[0+yych] & 32) { goto yy254; } -#line 362 "../src/ast/lex.re" +#line 359 "../src/ast/lex.re" { if (!globopts->FFlag || lex_namedef_context_re2c()) { yylval.str = new std::string (tok, tok_len()); @@ -1454,17 +1453,17 @@ yy255: col = static_cast(s - tok); str->push_back(ASTChar(chr, col)); } - yylval.regexp = ast_str(cline, get_column(), str, false); + yylval.regexp = ast_str(get_line(), get_column(), str, false); return TOKEN_REGEXP; } } -#line 1462 "src/ast/lex.cc" +#line 1461 "src/ast/lex.cc" yy257: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy280; -#line 309 "../src/ast/lex.re" +#line 306 "../src/ast/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1468 "src/ast/lex.cc" +#line 1467 "src/ast/lex.cc" yy259: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy282; @@ -1487,9 +1486,9 @@ yy260: } } yy261: -#line 292 "../src/ast/lex.re" +#line 289 "../src/ast/lex.re" { lex_code_in_braces(); return TOKEN_CODE; } -#line 1493 "src/ast/lex.cc" +#line 1492 "src/ast/lex.cc" yy262: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1548,36 +1547,36 @@ yy267: } } yy269: -#line 312 "../src/ast/lex.re" +#line 309 "../src/ast/lex.re" { const std::string *name = new std::string(tok + 1, tok_len() - 1); - yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#'); + yylval.regexp = ast_tag(get_line(), get_column(), name, tok[0] == '#'); return TOKEN_REGEXP; } -#line 1558 "src/ast/lex.cc" +#line 1557 "src/ast/lex.cc" yy270: ++YYCURSOR; -#line 305 "../src/ast/lex.re" +#line 302 "../src/ast/lex.re" { tok = cur; return 0; } -#line 1563 "src/ast/lex.cc" +#line 1562 "src/ast/lex.cc" yy272: ++YYCURSOR; -#line 303 "../src/ast/lex.re" +#line 300 "../src/ast/lex.re" { lex_c_comment(); goto scan; } -#line 1568 "src/ast/lex.cc" +#line 1567 "src/ast/lex.cc" yy274: ++YYCURSOR; -#line 302 "../src/ast/lex.re" +#line 299 "../src/ast/lex.re" { lex_cpp_comment(); goto scan; } -#line 1573 "src/ast/lex.cc" +#line 1572 "src/ast/lex.cc" yy276: yyaccept = 3; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych == '>') goto yy278; yy277: -#line 293 "../src/ast/lex.re" +#line 290 "../src/ast/lex.re" { lex_code_indented(); return TOKEN_CODE; } -#line 1581 "src/ast/lex.cc" +#line 1580 "src/ast/lex.cc" yy278: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1610,9 +1609,9 @@ yy278: } yy280: ++YYCURSOR; -#line 310 "../src/ast/lex.re" +#line 307 "../src/ast/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1616 "src/ast/lex.cc" +#line 1615 "src/ast/lex.cc" yy282: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy293; @@ -1620,12 +1619,12 @@ yy282: yy283: ++YYCURSOR; yy284: -#line 346 "../src/ast/lex.re" +#line 343 "../src/ast/lex.re" { - fatal_lc(get_cline(), get_column(), + fatal_lc(get_line(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 1629 "src/ast/lex.cc" +#line 1628 "src/ast/lex.cc" yy285: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1683,12 +1682,12 @@ yy290: } yy292: p = yyt1; -#line 295 "../src/ast/lex.re" +#line 292 "../src/ast/lex.re" { yylval.str = new std::string(p, static_cast(cur - p)); return tok[0] == ':' ? TOKEN_CJUMP : TOKEN_CNEXT; } -#line 1692 "src/ast/lex.cc" +#line 1691 "src/ast/lex.cc" yy293: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy300; @@ -1702,27 +1701,27 @@ yy294: goto yy284; yy295: ++YYCURSOR; -#line 320 "../src/ast/lex.re" +#line 317 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { - fatal_lc(get_cline(), get_column(), "repetition count overflow"); + fatal_lc(get_line(), get_column(), "repetition count overflow"); } yylval.bounds.max = yylval.bounds.min; return TOKEN_CLOSESIZE; } -#line 1714 "src/ast/lex.cc" +#line 1713 "src/ast/lex.cc" yy297: ++YYCURSOR; -#line 351 "../src/ast/lex.re" +#line 348 "../src/ast/lex.re" { if (!globopts->FFlag) { - fatal_lc(get_cline(), get_column(), + fatal_lc(get_line(), get_column(), "curly braces for names only allowed with -F switch"); } yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return TOKEN_ID; } -#line 1726 "src/ast/lex.cc" +#line 1725 "src/ast/lex.cc" yy299: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy305; @@ -1741,38 +1740,38 @@ yy301: goto yy264; yy303: ++YYCURSOR; -#line 338 "../src/ast/lex.re" +#line 335 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + fatal_lc(get_line(), get_column(), "repetition lower bound overflow"); } yylval.bounds.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1753 "src/ast/lex.cc" +#line 1752 "src/ast/lex.cc" yy305: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy310; goto yy264; yy306: ++YYCURSOR; -#line 360 "../src/ast/lex.re" +#line 357 "../src/ast/lex.re" { return TOKEN_CONF; } -#line 1762 "src/ast/lex.cc" +#line 1761 "src/ast/lex.cc" yy308: ++YYCURSOR; p = yyt1; -#line 328 "../src/ast/lex.re" +#line 325 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + fatal_lc(get_line(), get_column(), "repetition lower bound overflow"); } if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max)) { - fatal_lc(get_cline(), get_column(), "repetition upper bound overflow"); + fatal_lc(get_line(), get_column(), "repetition upper bound overflow"); } return TOKEN_CLOSESIZE; } -#line 1776 "src/ast/lex.cc" +#line 1775 "src/ast/lex.cc" yy310: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy312; @@ -1828,12 +1827,12 @@ yy315: yy317: ++YYCURSOR; YYCURSOR = yyt1; -#line 392 "../src/ast/lex.re" +#line 389 "../src/ast/lex.re" { set_sourceline (); return TOKEN_LINE_INFO; } -#line 1837 "src/ast/lex.cc" +#line 1836 "src/ast/lex.cc" yy319: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy317; @@ -1859,14 +1858,14 @@ yy323: if (yych == '\n') goto yy264; goto yy320; } -#line 413 "../src/ast/lex.re" +#line 409 "../src/ast/lex.re" } bool Scanner::lex_namedef_context_re2c() { -#line 1870 "src/ast/lex.cc" +#line 1869 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1921,9 +1920,9 @@ bool Scanner::lex_namedef_context_re2c() } } yy326: -#line 420 "../src/ast/lex.re" +#line 416 "../src/ast/lex.re" { return false; } -#line 1927 "src/ast/lex.cc" +#line 1926 "src/ast/lex.cc" yy327: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1940,18 +1939,18 @@ yy330: if (yych == '>') goto yy329; ++YYCURSOR; YYCURSOR = yyt1; -#line 419 "../src/ast/lex.re" +#line 415 "../src/ast/lex.re" { return true; } -#line 1946 "src/ast/lex.cc" +#line 1945 "src/ast/lex.cc" } -#line 421 "../src/ast/lex.re" +#line 417 "../src/ast/lex.re" } bool Scanner::lex_namedef_context_flex() { -#line 1955 "src/ast/lex.cc" +#line 1954 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1998,9 +1997,9 @@ bool Scanner::lex_namedef_context_flex() yyt1 = YYCURSOR; goto yy336; } -#line 429 "../src/ast/lex.re" +#line 425 "../src/ast/lex.re" { return false; } -#line 2004 "src/ast/lex.cc" +#line 2003 "src/ast/lex.cc" yy336: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2015,17 +2014,17 @@ yy336: if (yych == '{') goto yy339; } YYCURSOR = yyt1; -#line 428 "../src/ast/lex.re" +#line 424 "../src/ast/lex.re" { return true; } -#line 2021 "src/ast/lex.cc" +#line 2020 "src/ast/lex.cc" yy339: ++YYCURSOR; YYCURSOR = yyt1; -#line 427 "../src/ast/lex.re" +#line 423 "../src/ast/lex.re" { return false; } -#line 2027 "src/ast/lex.cc" +#line 2026 "src/ast/lex.cc" } -#line 430 "../src/ast/lex.re" +#line 426 "../src/ast/lex.re" } @@ -2034,7 +2033,7 @@ int Scanner::lex_clist() int kind = TOKEN_CLIST; CondList *cl = new CondList; -#line 2038 "src/ast/lex.cc" +#line 2037 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2084,30 +2083,30 @@ yy341: if (yych <= '!') goto yy345; if (yych == '>') goto yy348; yy344: -#line 440 "../src/ast/lex.re" +#line 436 "../src/ast/lex.re" { goto cond; } -#line 2090 "src/ast/lex.cc" +#line 2089 "src/ast/lex.cc" yy345: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\t') goto yy345; if (yych == ' ') goto yy345; -#line 438 "../src/ast/lex.re" +#line 434 "../src/ast/lex.re" { kind = TOKEN_CSETUP; goto cond; } -#line 2099 "src/ast/lex.cc" +#line 2098 "src/ast/lex.cc" yy348: ++YYCURSOR; -#line 439 "../src/ast/lex.re" +#line 435 "../src/ast/lex.re" { kind = TOKEN_CZERO; goto end; } -#line 2104 "src/ast/lex.cc" +#line 2103 "src/ast/lex.cc" } -#line 441 "../src/ast/lex.re" +#line 437 "../src/ast/lex.re" cond: tok = cur; -#line 2111 "src/ast/lex.cc" +#line 2110 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2159,14 +2158,14 @@ cond: } yy352: ++YYCURSOR; -#line 447 "../src/ast/lex.re" +#line 443 "../src/ast/lex.re" { goto error; } -#line 2165 "src/ast/lex.cc" +#line 2164 "src/ast/lex.cc" yy354: ++YYCURSOR; -#line 446 "../src/ast/lex.re" +#line 442 "../src/ast/lex.re" { if (!cl->empty()) goto error; cl->insert("*"); goto next; } -#line 2170 "src/ast/lex.cc" +#line 2169 "src/ast/lex.cc" yy356: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2174,15 +2173,15 @@ yy356: if (yybm[0+yych] & 128) { goto yy356; } -#line 445 "../src/ast/lex.re" +#line 441 "../src/ast/lex.re" { cl->insert(std::string(tok, tok_len())); goto next; } -#line 2180 "src/ast/lex.cc" +#line 2179 "src/ast/lex.cc" } -#line 448 "../src/ast/lex.re" +#line 444 "../src/ast/lex.re" next: -#line 2186 "src/ast/lex.cc" +#line 2185 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2233,9 +2232,9 @@ next: } ++YYCURSOR; yy362: -#line 453 "../src/ast/lex.re" +#line 449 "../src/ast/lex.re" { goto error; } -#line 2239 "src/ast/lex.cc" +#line 2238 "src/ast/lex.cc" yy363: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= ' ') { @@ -2257,14 +2256,14 @@ yy364: if (yybm[0+yych] & 128) { goto yy364; } -#line 451 "../src/ast/lex.re" +#line 447 "../src/ast/lex.re" { goto cond; } -#line 2263 "src/ast/lex.cc" +#line 2262 "src/ast/lex.cc" yy367: ++YYCURSOR; -#line 452 "../src/ast/lex.re" +#line 448 "../src/ast/lex.re" { goto end; } -#line 2268 "src/ast/lex.cc" +#line 2267 "src/ast/lex.cc" yy369: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2282,23 +2281,23 @@ yy369: YYCURSOR = YYMARKER; goto yy362; } -#line 454 "../src/ast/lex.re" +#line 450 "../src/ast/lex.re" end: yylval.clist = cl; return kind; error: delete cl; - fatal_l(get_cline(), "syntax error in condition list"); + fatal_l(get_line(), "syntax error in condition list"); } void Scanner::lex_code_indented() { - const uint32_t line = cline; + const uint32_t line = get_line(); tok = cur; code: -#line 2302 "src/ast/lex.cc" +#line 2301 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); @@ -2326,15 +2325,15 @@ code: } yy374: ++YYCURSOR; -#line 477 "../src/ast/lex.re" +#line 473 "../src/ast/lex.re" { fail_if_eof(); goto code; } -#line 2332 "src/ast/lex.cc" +#line 2331 "src/ast/lex.cc" yy376: ++YYCURSOR; yy377: -#line 482 "../src/ast/lex.re" +#line 478 "../src/ast/lex.re" { goto code; } -#line 2338 "src/ast/lex.cc" +#line 2337 "src/ast/lex.cc" yy378: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '\f') { @@ -2345,23 +2344,23 @@ yy378: if (yych == ' ') goto yy386; } yy379: -#line 470 "../src/ast/lex.re" +#line 466 "../src/ast/lex.re" { while (isspace(tok[0])) ++tok; while (cur > tok && isspace(cur[-1])) --cur; yylval.code = new Code(get_fname (), line, tok, tok_len ()); return; } -#line 2356 "src/ast/lex.cc" +#line 2355 "src/ast/lex.cc" yy380: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy378; goto yy377; yy381: ++YYCURSOR; -#line 481 "../src/ast/lex.re" +#line 477 "../src/ast/lex.re" { lex_string(cur[-1]); goto code; } -#line 2365 "src/ast/lex.cc" +#line 2364 "src/ast/lex.cc" yy383: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy388; @@ -2369,37 +2368,37 @@ yy383: goto yy377; yy384: ++YYCURSOR; -#line 478 "../src/ast/lex.re" - { fatal_l(get_cline(), "Curly braces are not allowed after ':='"); } -#line 2375 "src/ast/lex.cc" +#line 474 "../src/ast/lex.re" + { fatal_l(get_line(), "Curly braces are not allowed after ':='"); } +#line 2374 "src/ast/lex.cc" yy386: ++YYCURSOR; YYCURSOR -= 1; -#line 469 "../src/ast/lex.re" +#line 465 "../src/ast/lex.re" { goto code; } -#line 2381 "src/ast/lex.cc" +#line 2380 "src/ast/lex.cc" yy388: ++YYCURSOR; -#line 479 "../src/ast/lex.re" +#line 475 "../src/ast/lex.re" { lex_c_comment(); goto code; } -#line 2386 "src/ast/lex.cc" +#line 2385 "src/ast/lex.cc" yy390: ++YYCURSOR; -#line 480 "../src/ast/lex.re" +#line 476 "../src/ast/lex.re" { lex_cpp_comment(); goto code; } -#line 2391 "src/ast/lex.cc" +#line 2390 "src/ast/lex.cc" } -#line 483 "../src/ast/lex.re" +#line 479 "../src/ast/lex.re" } void Scanner::lex_code_in_braces() { - const uint32_t line = cline; + const uint32_t line = get_line(); uint32_t depth = 1; code: -#line 2403 "src/ast/lex.cc" +#line 2402 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2461,15 +2460,15 @@ code: } yy394: ++YYCURSOR; -#line 503 "../src/ast/lex.re" +#line 499 "../src/ast/lex.re" { fail_if_eof(); goto code; } -#line 2467 "src/ast/lex.cc" +#line 2466 "src/ast/lex.cc" yy396: ++YYCURSOR; yy397: -#line 507 "../src/ast/lex.re" +#line 503 "../src/ast/lex.re" { goto code; } -#line 2473 "src/ast/lex.cc" +#line 2472 "src/ast/lex.cc" yy398: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -2477,18 +2476,18 @@ yy398: } if (yych == '#') goto yy411; yy399: -#line 502 "../src/ast/lex.re" - { pos = cur; cline++; goto code; } -#line 2483 "src/ast/lex.cc" +#line 498 "../src/ast/lex.re" + { next_line(); goto code; } +#line 2482 "src/ast/lex.cc" yy400: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy398; goto yy397; yy401: ++YYCURSOR; -#line 506 "../src/ast/lex.re" +#line 502 "../src/ast/lex.re" { lex_string(cur[-1]); goto code; } -#line 2492 "src/ast/lex.cc" +#line 2491 "src/ast/lex.cc" yy403: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy413; @@ -2496,12 +2495,12 @@ yy403: goto yy397; yy404: ++YYCURSOR; -#line 500 "../src/ast/lex.re" +#line 496 "../src/ast/lex.re" { ++depth; goto code; } -#line 2502 "src/ast/lex.cc" +#line 2501 "src/ast/lex.cc" yy406: ++YYCURSOR; -#line 492 "../src/ast/lex.re" +#line 488 "../src/ast/lex.re" { if (--depth == 0) { yylval.code = new Code(get_fname (), line, tok, tok_len ()); @@ -2509,7 +2508,7 @@ yy406: } goto code; } -#line 2513 "src/ast/lex.cc" +#line 2512 "src/ast/lex.cc" yy408: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2535,14 +2534,14 @@ yy411: } yy413: ++YYCURSOR; -#line 504 "../src/ast/lex.re" +#line 500 "../src/ast/lex.re" { lex_c_comment(); goto code; } -#line 2541 "src/ast/lex.cc" +#line 2540 "src/ast/lex.cc" yy415: ++YYCURSOR; -#line 505 "../src/ast/lex.re" +#line 501 "../src/ast/lex.re" { lex_cpp_comment(); goto code; } -#line 2546 "src/ast/lex.cc" +#line 2545 "src/ast/lex.cc" yy417: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'i') goto yy410; @@ -2599,9 +2598,9 @@ yy425: yy427: ++YYCURSOR; YYCURSOR = yyt1; -#line 501 "../src/ast/lex.re" +#line 497 "../src/ast/lex.re" { set_sourceline (); goto code; } -#line 2605 "src/ast/lex.cc" +#line 2604 "src/ast/lex.cc" yy429: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy427; @@ -2627,7 +2626,7 @@ yy433: if (yych == '\n') goto yy410; goto yy430; } -#line 508 "../src/ast/lex.re" +#line 504 "../src/ast/lex.re" } @@ -2635,7 +2634,7 @@ void Scanner::lex_string(char delim) { loop: -#line 2639 "src/ast/lex.cc" +#line 2638 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2661,29 +2660,29 @@ loop: } yy436: ++YYCURSOR; -#line 518 "../src/ast/lex.re" +#line 514 "../src/ast/lex.re" { fail_if_eof(); goto loop; } -#line 2667 "src/ast/lex.cc" +#line 2666 "src/ast/lex.cc" yy438: ++YYCURSOR; yy439: -#line 519 "../src/ast/lex.re" +#line 515 "../src/ast/lex.re" { goto loop; } -#line 2673 "src/ast/lex.cc" +#line 2672 "src/ast/lex.cc" yy440: ++YYCURSOR; -#line 517 "../src/ast/lex.re" - { pos = cur; ++cline; goto loop; } -#line 2678 "src/ast/lex.cc" +#line 513 "../src/ast/lex.re" + { next_line(); goto loop; } +#line 2677 "src/ast/lex.cc" yy442: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy440; goto yy439; yy443: ++YYCURSOR; -#line 515 "../src/ast/lex.re" +#line 511 "../src/ast/lex.re" { if (cur[-1] == delim) return; else goto loop; } -#line 2687 "src/ast/lex.cc" +#line 2686 "src/ast/lex.cc" yy445: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '&') { @@ -2694,11 +2693,11 @@ yy445: } yy446: ++YYCURSOR; -#line 516 "../src/ast/lex.re" +#line 512 "../src/ast/lex.re" { goto loop; } -#line 2700 "src/ast/lex.cc" +#line 2699 "src/ast/lex.cc" } -#line 520 "../src/ast/lex.re" +#line 516 "../src/ast/lex.re" } @@ -2706,7 +2705,7 @@ void Scanner::lex_c_comment() { loop: -#line 2710 "src/ast/lex.cc" +#line 2709 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2722,20 +2721,20 @@ loop: } yy450: ++YYCURSOR; -#line 529 "../src/ast/lex.re" +#line 525 "../src/ast/lex.re" { fail_if_eof(); goto loop; } -#line 2728 "src/ast/lex.cc" +#line 2727 "src/ast/lex.cc" yy452: ++YYCURSOR; yy453: -#line 530 "../src/ast/lex.re" +#line 526 "../src/ast/lex.re" { goto loop; } -#line 2734 "src/ast/lex.cc" +#line 2733 "src/ast/lex.cc" yy454: ++YYCURSOR; -#line 528 "../src/ast/lex.re" - { pos = cur; ++cline; goto loop; } -#line 2739 "src/ast/lex.cc" +#line 524 "../src/ast/lex.re" + { next_line(); goto loop; } +#line 2738 "src/ast/lex.cc" yy456: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy454; @@ -2744,11 +2743,11 @@ yy457: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy453; ++YYCURSOR; -#line 527 "../src/ast/lex.re" +#line 523 "../src/ast/lex.re" { return; } -#line 2750 "src/ast/lex.cc" +#line 2749 "src/ast/lex.cc" } -#line 531 "../src/ast/lex.re" +#line 527 "../src/ast/lex.re" } @@ -2756,7 +2755,7 @@ void Scanner::lex_cpp_comment() { loop: -#line 2760 "src/ast/lex.cc" +#line 2759 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2771,26 +2770,26 @@ loop: } yy462: ++YYCURSOR; -#line 539 "../src/ast/lex.re" +#line 535 "../src/ast/lex.re" { fail_if_eof(); goto loop; } -#line 2777 "src/ast/lex.cc" +#line 2776 "src/ast/lex.cc" yy464: ++YYCURSOR; yy465: -#line 540 "../src/ast/lex.re" +#line 536 "../src/ast/lex.re" { goto loop; } -#line 2783 "src/ast/lex.cc" +#line 2782 "src/ast/lex.cc" yy466: ++YYCURSOR; -#line 538 "../src/ast/lex.re" - { pos = cur; ++cline; return; } -#line 2788 "src/ast/lex.cc" +#line 534 "../src/ast/lex.re" + { next_line(); return; } +#line 2787 "src/ast/lex.cc" yy468: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy466; goto yy465; } -#line 541 "../src/ast/lex.re" +#line 537 "../src/ast/lex.re" } @@ -2802,35 +2801,35 @@ fst: tok = cur; c = get_column(); -#line 2806 "src/ast/lex.cc" +#line 2805 "src/ast/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy472; -#line 553 "../src/ast/lex.re" +#line 549 "../src/ast/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2814 "src/ast/lex.cc" +#line 2813 "src/ast/lex.cc" yy472: ++YYCURSOR; -#line 552 "../src/ast/lex.re" - { return ast_cls(cline, c0, cls, neg); } -#line 2819 "src/ast/lex.cc" +#line 548 "../src/ast/lex.re" + { return ast_cls(get_line(), c0, cls, neg); } +#line 2818 "src/ast/lex.cc" } -#line 554 "../src/ast/lex.re" +#line 550 "../src/ast/lex.re" snd: -#line 2825 "src/ast/lex.cc" +#line 2824 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy477; yy476: -#line 557 "../src/ast/lex.re" +#line 553 "../src/ast/lex.re" { u = l; goto add; } -#line 2834 "src/ast/lex.cc" +#line 2833 "src/ast/lex.cc" yy477: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy479; @@ -2839,18 +2838,18 @@ yy477: yy479: ++YYCURSOR; YYCURSOR -= 1; -#line 558 "../src/ast/lex.re" +#line 554 "../src/ast/lex.re" { u = lex_cls_chr(); if (l > u) { - warn.swapped_range(cline, l, u); + warn.swapped_range(get_line(), l, u); std::swap(l, u); } goto add; } -#line 2852 "src/ast/lex.cc" +#line 2851 "src/ast/lex.cc" } -#line 566 "../src/ast/lex.re" +#line 562 "../src/ast/lex.re" add: cls->push_back(ASTRange(l, u, c)); @@ -2860,9 +2859,9 @@ add: uint32_t Scanner::lex_cls_chr() { tok = cur; - const uint32_t l = get_cline(), c = get_column(); + const uint32_t l = get_line(), c = get_column(); -#line 2866 "src/ast/lex.cc" +#line 2865 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2879,20 +2878,20 @@ uint32_t Scanner::lex_cls_chr() } yy483: ++YYCURSOR; -#line 578 "../src/ast/lex.re" +#line 574 "../src/ast/lex.re" { fail_if_eof(); return 0; } -#line 2885 "src/ast/lex.cc" +#line 2884 "src/ast/lex.cc" yy485: ++YYCURSOR; yy486: -#line 584 "../src/ast/lex.re" +#line 580 "../src/ast/lex.re" { return static_cast(tok[0]); } -#line 2891 "src/ast/lex.cc" +#line 2890 "src/ast/lex.cc" yy487: ++YYCURSOR; -#line 579 "../src/ast/lex.re" +#line 575 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character class"); } -#line 2896 "src/ast/lex.cc" +#line 2895 "src/ast/lex.cc" yy489: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy487; @@ -2951,36 +2950,36 @@ yy490: } } yy491: -#line 582 "../src/ast/lex.re" +#line 578 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 2957 "src/ast/lex.cc" +#line 2956 "src/ast/lex.cc" yy492: ++YYCURSOR; yy493: -#line 597 "../src/ast/lex.re" +#line 593 "../src/ast/lex.re" { - warn.useless_escape(cline, get_column(), tok[1]); + warn.useless_escape(l, c, tok[1]); return static_cast(tok[1]); } -#line 2966 "src/ast/lex.cc" +#line 2965 "src/ast/lex.cc" yy494: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy487; goto yy493; yy495: ++YYCURSOR; -#line 595 "../src/ast/lex.re" +#line 591 "../src/ast/lex.re" { return static_cast('-'); } -#line 2975 "src/ast/lex.cc" +#line 2974 "src/ast/lex.cc" yy497: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy498; if (yych <= '7') goto yy522; yy498: -#line 581 "../src/ast/lex.re" +#line 577 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2984 "src/ast/lex.cc" +#line 2983 "src/ast/lex.cc" yy499: ++YYCURSOR; goto yy498; @@ -2996,9 +2995,9 @@ yy500: if (yych <= 'f') goto yy524; } yy501: -#line 580 "../src/ast/lex.re" +#line 576 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 3002 "src/ast/lex.cc" +#line 3001 "src/ast/lex.cc" yy502: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3014,49 +3013,49 @@ yy502: } yy503: ++YYCURSOR; -#line 594 "../src/ast/lex.re" +#line 590 "../src/ast/lex.re" { return static_cast('\\'); } -#line 3020 "src/ast/lex.cc" +#line 3019 "src/ast/lex.cc" yy505: ++YYCURSOR; -#line 596 "../src/ast/lex.re" +#line 592 "../src/ast/lex.re" { return static_cast(']'); } -#line 3025 "src/ast/lex.cc" +#line 3024 "src/ast/lex.cc" yy507: ++YYCURSOR; -#line 587 "../src/ast/lex.re" +#line 583 "../src/ast/lex.re" { return static_cast('\a'); } -#line 3030 "src/ast/lex.cc" +#line 3029 "src/ast/lex.cc" yy509: ++YYCURSOR; -#line 588 "../src/ast/lex.re" +#line 584 "../src/ast/lex.re" { return static_cast('\b'); } -#line 3035 "src/ast/lex.cc" +#line 3034 "src/ast/lex.cc" yy511: ++YYCURSOR; -#line 589 "../src/ast/lex.re" +#line 585 "../src/ast/lex.re" { return static_cast('\f'); } -#line 3040 "src/ast/lex.cc" +#line 3039 "src/ast/lex.cc" yy513: ++YYCURSOR; -#line 590 "../src/ast/lex.re" +#line 586 "../src/ast/lex.re" { return static_cast('\n'); } -#line 3045 "src/ast/lex.cc" +#line 3044 "src/ast/lex.cc" yy515: ++YYCURSOR; -#line 591 "../src/ast/lex.re" +#line 587 "../src/ast/lex.re" { return static_cast('\r'); } -#line 3050 "src/ast/lex.cc" +#line 3049 "src/ast/lex.cc" yy517: ++YYCURSOR; -#line 592 "../src/ast/lex.re" +#line 588 "../src/ast/lex.re" { return static_cast('\t'); } -#line 3055 "src/ast/lex.cc" +#line 3054 "src/ast/lex.cc" yy519: ++YYCURSOR; -#line 593 "../src/ast/lex.re" +#line 589 "../src/ast/lex.re" { return static_cast('\v'); } -#line 3060 "src/ast/lex.cc" +#line 3059 "src/ast/lex.cc" yy521: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3119,9 +3118,9 @@ yy526: } yy527: ++YYCURSOR; -#line 586 "../src/ast/lex.re" +#line 582 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 3125 "src/ast/lex.cc" +#line 3124 "src/ast/lex.cc" yy529: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3148,9 +3147,9 @@ yy530: } yy531: ++YYCURSOR; -#line 585 "../src/ast/lex.re" +#line 581 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 3154 "src/ast/lex.cc" +#line 3153 "src/ast/lex.cc" yy533: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3174,7 +3173,7 @@ yy534: goto yy523; } } -#line 601 "../src/ast/lex.re" +#line 597 "../src/ast/lex.re" } @@ -3182,9 +3181,9 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) { end = false; tok = cur; - const uint32_t l = get_cline(), c = get_column(); + const uint32_t l = get_line(), c = get_column(); -#line 3188 "src/ast/lex.cc" +#line 3187 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -3201,23 +3200,23 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) } yy537: ++YYCURSOR; -#line 611 "../src/ast/lex.re" +#line 607 "../src/ast/lex.re" { fail_if_eof(); return 0; } -#line 3207 "src/ast/lex.cc" +#line 3206 "src/ast/lex.cc" yy539: ++YYCURSOR; yy540: -#line 617 "../src/ast/lex.re" +#line 613 "../src/ast/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 3216 "src/ast/lex.cc" +#line 3215 "src/ast/lex.cc" yy541: ++YYCURSOR; -#line 612 "../src/ast/lex.re" +#line 608 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character string"); } -#line 3221 "src/ast/lex.cc" +#line 3220 "src/ast/lex.cc" yy543: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy541; @@ -3271,20 +3270,20 @@ yy544: } } yy545: -#line 615 "../src/ast/lex.re" +#line 611 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 3277 "src/ast/lex.cc" +#line 3276 "src/ast/lex.cc" yy546: ++YYCURSOR; yy547: -#line 631 "../src/ast/lex.re" +#line 627 "../src/ast/lex.re" { if (tok[1] != quote) { - warn.useless_escape(cline, get_column(), tok[1]); + warn.useless_escape(l, c, tok[1]); } return static_cast(tok[1]); } -#line 3288 "src/ast/lex.cc" +#line 3287 "src/ast/lex.cc" yy548: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy541; @@ -3295,9 +3294,9 @@ yy549: if (yych <= '/') goto yy550; if (yych <= '7') goto yy572; yy550: -#line 614 "../src/ast/lex.re" +#line 610 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 3301 "src/ast/lex.cc" +#line 3300 "src/ast/lex.cc" yy551: ++YYCURSOR; goto yy550; @@ -3313,9 +3312,9 @@ yy552: if (yych <= 'f') goto yy574; } yy553: -#line 613 "../src/ast/lex.re" +#line 609 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 3319 "src/ast/lex.cc" +#line 3318 "src/ast/lex.cc" yy554: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3331,44 +3330,44 @@ yy554: } yy555: ++YYCURSOR; -#line 630 "../src/ast/lex.re" +#line 626 "../src/ast/lex.re" { return static_cast('\\'); } -#line 3337 "src/ast/lex.cc" +#line 3336 "src/ast/lex.cc" yy557: ++YYCURSOR; -#line 623 "../src/ast/lex.re" +#line 619 "../src/ast/lex.re" { return static_cast('\a'); } -#line 3342 "src/ast/lex.cc" +#line 3341 "src/ast/lex.cc" yy559: ++YYCURSOR; -#line 624 "../src/ast/lex.re" +#line 620 "../src/ast/lex.re" { return static_cast('\b'); } -#line 3347 "src/ast/lex.cc" +#line 3346 "src/ast/lex.cc" yy561: ++YYCURSOR; -#line 625 "../src/ast/lex.re" +#line 621 "../src/ast/lex.re" { return static_cast('\f'); } -#line 3352 "src/ast/lex.cc" +#line 3351 "src/ast/lex.cc" yy563: ++YYCURSOR; -#line 626 "../src/ast/lex.re" +#line 622 "../src/ast/lex.re" { return static_cast('\n'); } -#line 3357 "src/ast/lex.cc" +#line 3356 "src/ast/lex.cc" yy565: ++YYCURSOR; -#line 627 "../src/ast/lex.re" +#line 623 "../src/ast/lex.re" { return static_cast('\r'); } -#line 3362 "src/ast/lex.cc" +#line 3361 "src/ast/lex.cc" yy567: ++YYCURSOR; -#line 628 "../src/ast/lex.re" +#line 624 "../src/ast/lex.re" { return static_cast('\t'); } -#line 3367 "src/ast/lex.cc" +#line 3366 "src/ast/lex.cc" yy569: ++YYCURSOR; -#line 629 "../src/ast/lex.re" +#line 625 "../src/ast/lex.re" { return static_cast('\v'); } -#line 3372 "src/ast/lex.cc" +#line 3371 "src/ast/lex.cc" yy571: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3431,9 +3430,9 @@ yy576: } yy577: ++YYCURSOR; -#line 622 "../src/ast/lex.re" +#line 618 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 3437 "src/ast/lex.cc" +#line 3436 "src/ast/lex.cc" yy579: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3460,9 +3459,9 @@ yy580: } yy581: ++YYCURSOR; -#line 621 "../src/ast/lex.re" +#line 617 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 3466 "src/ast/lex.cc" +#line 3465 "src/ast/lex.cc" yy583: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3486,17 +3485,17 @@ yy584: goto yy573; } } -#line 637 "../src/ast/lex.re" +#line 633 "../src/ast/lex.re" } const AST *Scanner::lex_str(char quote) { - const uint32_t column = get_column(); + const uint32_t line = get_line(), column = get_column(); std::vector *str = new std::vector; for (bool end;;) { const uint32_t c = lex_str_chr(quote, end); - if (end) return ast_str(cline, column, str, quote == '\''); + if (end) return ast_str(line, column, str, quote == '\''); str->push_back(ASTChar(c, get_column())); } } @@ -3506,7 +3505,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 3510 "src/ast/lex.cc" +#line 3509 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -3564,20 +3563,20 @@ sourceline: } } ++YYCURSOR; -#line 671 "../src/ast/lex.re" +#line 669 "../src/ast/lex.re" { --cur; return; } -#line 3570 "src/ast/lex.cc" +#line 3569 "src/ast/lex.cc" yy589: ++YYCURSOR; yy590: -#line 672 "../src/ast/lex.re" +#line 670 "../src/ast/lex.re" { goto sourceline; } -#line 3576 "src/ast/lex.cc" +#line 3575 "src/ast/lex.cc" yy591: ++YYCURSOR; -#line 670 "../src/ast/lex.re" +#line 668 "../src/ast/lex.re" { tok = cur; return; } -#line 3581 "src/ast/lex.cc" +#line 3580 "src/ast/lex.cc" yy593: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy591; @@ -3594,14 +3593,16 @@ yy595: if (yybm[0+yych] & 64) { goto yy595; } -#line 656 "../src/ast/lex.re" +#line 652 "../src/ast/lex.re" { - if (!s_to_u32_unsafe (tok, cur, cline)) { - fatal_lc(get_cline(), get_column(), "line number overflow"); + uint32_t l; + if (!s_to_u32_unsafe (tok, cur, l)) { + fatal_lc(get_line(), get_column(), "line number overflow"); } + set_line(l); goto sourceline; } -#line 3605 "src/ast/lex.cc" +#line 3606 "src/ast/lex.cc" yy598: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3618,14 +3619,14 @@ yy600: goto yy590; yy601: ++YYCURSOR; -#line 663 "../src/ast/lex.re" +#line 661 "../src/ast/lex.re" { std::string &name = get_input().escaped_name; name = std::string(tok + 1, tok_len () - 2); // strip quotes strrreplace(name, "\\", "\\\\"); goto sourceline; } -#line 3629 "src/ast/lex.cc" +#line 3630 "src/ast/lex.cc" yy603: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3634,7 +3635,7 @@ yy603: if (yych == '\n') goto yy600; goto yy598; } -#line 673 "../src/ast/lex.re" +#line 671 "../src/ast/lex.re" } @@ -3642,7 +3643,7 @@ void Scanner::fail_if_eof() const { if (is_eof()) { const uint32_t col = static_cast(cur - pos) - 1; - fatal_lc(get_cline(), col, "unexpected end of input"); + fatal_lc(get_line(), col, "unexpected end of input"); } } diff --git a/re2c/bootstrap/src/ast/lex.h b/re2c/bootstrap/src/ast/lex.h index 0d8b8957..e92fde67 100644 --- a/re2c/bootstrap/src/ast/lex.h +++ b/re2c/bootstrap/src/ast/lex.h @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Wed Dec 26 11:34:46 2018 */ +/* Generated by re2c 1.1.1 on Thu Dec 27 21:57:09 2018 */ #include #include "src/util/forbid_copy.h" @@ -18,7 +18,6 @@ struct ScannerState char *yyt1;char *yyt2; ptrdiff_t tchar; - uint32_t cline; inline ScannerState() : lexer_state (LEX_NORMAL) @@ -34,7 +33,6 @@ struct ScannerState , eof(NULL) , yyt1(lim), yyt2(lim) , tchar(0) - , cline(1) { memset(lim, 0, YYMAXFILL); } diff --git a/re2c/bootstrap/src/ast/lex_conf.cc b/re2c/bootstrap/src/ast/lex_conf.cc index ba90734f..05db59cf 100644 --- a/re2c/bootstrap/src/ast/lex_conf.cc +++ b/re2c/bootstrap/src/ast/lex_conf.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Sat Dec 22 19:57:50 2018 */ +/* Generated by re2c 1.1.1 on Wed Dec 26 20:02:53 2018 */ #line 1 "../src/ast/lex_conf.re" #include "src/util/c99_stdint.h" #include @@ -21,7 +21,7 @@ namespace re2c void Scanner::lex_conf(Opt &opts) { tok = cur; - const uint32_t l = get_cline(), c = get_column(); + const uint32_t l = get_line(), c = get_column(); #line 27 "src/ast/lex_conf.cc" { @@ -3462,7 +3462,7 @@ void Scanner::lex_conf_encoding_policy(Opt &opts) ++cur; yy739: #line 182 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), + { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); } #line 3468 "src/ast/lex_conf.cc" yy740: @@ -3565,7 +3565,7 @@ yy766: ++cur; yy767: #line 196 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), + { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'default', 'custom')"); } #line 3571 "src/ast/lex_conf.cc" yy768: @@ -3643,7 +3643,7 @@ void Scanner::lex_conf_empty_class(Opt &opts) ++cur; yy787: #line 209 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), + { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); } #line 3649 "src/ast/lex_conf.cc" yy788: @@ -3751,7 +3751,7 @@ void Scanner::lex_conf_dfa_minimization(Opt &opts) ++cur; yy815: #line 223 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), + { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'table', 'moore')"); } #line 3757 "src/ast/lex_conf.cc" yy816: @@ -3865,7 +3865,7 @@ void Scanner::lex_conf_assign () ++cur; yy832: #line 244 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), "missing '=' in configuration"); } + { fatal_lc(get_line(), get_column(), "missing '=' in configuration"); } #line 3870 "src/ast/lex_conf.cc" yy833: yych = (unsigned char)*(mar = ++cur); @@ -3954,7 +3954,7 @@ void Scanner::lex_conf_semicolon () ++cur; yy843: #line 252 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), "missing ending ';' in configuration"); } + { fatal_lc(get_line(), get_column(), "missing ending ';' in configuration"); } #line 3959 "src/ast/lex_conf.cc" yy844: yych = (unsigned char)*(mar = ++cur); @@ -4040,7 +4040,7 @@ int32_t Scanner::lex_conf_number () ++cur; yy853: #line 267 "../src/ast/lex_conf.re" - { fatal_lc(get_cline(), get_column(), + { fatal_lc(get_line(), get_column(), "bad configuration value (expected number)"); } #line 4046 "src/ast/lex_conf.cc" yy854: @@ -4055,7 +4055,7 @@ yy856: { int32_t n = 0; if (!s_to_i32_unsafe (tok, cur, n)) { - fatal_lc(get_cline(), get_column(), "configuration value overflow"); + fatal_lc(get_line(), get_column(), "configuration value overflow"); } lex_conf_semicolon (); return n; @@ -4163,7 +4163,7 @@ yy865: goto end; } if (c > 0xFF) { - fatal_lc(get_cline(), get_column(), + fatal_lc(get_line(), get_column(), "multibyte character in configuration string: 0x%X", c); } else { s += static_cast(c); diff --git a/re2c/bootstrap/src/ast/parser.cc b/re2c/bootstrap/src/ast/parser.cc index 91f47f47..2aadcc0e 100644 --- a/re2c/bootstrap/src/ast/parser.cc +++ b/re2c/bootstrap/src/ast/parser.cc @@ -1303,7 +1303,7 @@ yyreduce: { if (!context.symtab.insert(std::make_pair(*(yyvsp[-2].str), (yyvsp[-1].regexp))).second) { - fatal_l(context.input.get_cline(), "sym already defined"); + fatal_l(context.input.get_line(), "sym already defined"); } delete (yyvsp[-2].str); } @@ -1313,7 +1313,7 @@ yyreduce: case 8: { - fatal_l(context.input.get_cline(), + fatal_l(context.input.get_line(), "trailing contexts are not allowed in named definitions"); } @@ -1406,7 +1406,7 @@ yyreduce: case 20: { - const AST *r = ast_nil(context.input.get_cline(), 0); + const AST *r = ast_nil(context.input.get_line(), 0); find(context.specs, "0").rules.push_back(ASTRule(r, (yyvsp[0].code))); delete (yyvsp[-1].clist); } @@ -1426,7 +1426,7 @@ yyreduce: case 23: { - (yyval.code) = new Code(context.input.get_fname(), context.input.get_cline()); + (yyval.code) = new Code(context.input.get_fname(), context.input.get_line()); (yyval.code)->cond = *(yyvsp[0].str); delete (yyvsp[0].str); } @@ -1445,7 +1445,7 @@ yyreduce: { (yyval.regexp) = ast_cat(ast_cap((yyvsp[-2].regexp)), - ast_cat(ast_tag(context.input.get_cline(), 0, NULL, false), (yyvsp[0].regexp))); + ast_cat(ast_tag(context.input.get_line(), 0, NULL, false), (yyvsp[0].regexp))); } break; @@ -1547,7 +1547,7 @@ yyreduce: { symtab_t::iterator i = context.symtab.find(*(yyvsp[0].str)); if (i == context.symtab.end()) { - fatal_l(context.input.get_cline(), + fatal_l(context.input.get_line(), "undefined symbol '%s'", (yyvsp[0].str)->c_str()); } (yyval.regexp) = i->second; @@ -1803,7 +1803,7 @@ extern "C" { void yyerror(context_t &context, const char* s) { - fatal_l(context.input.get_cline(), "%s", s); + fatal_l(context.input.get_line(), "%s", s); } int yylex(context_t &context) diff --git a/re2c/src/ast/input.cc b/re2c/src/ast/input.cc index 3e8baf34..9323f765 100644 --- a/re2c/src/ast/input.cc +++ b/re2c/src/ast/input.cc @@ -11,6 +11,7 @@ Input::Input() , escaped_name() , so(Scanner::ENDPOS) , eo(Scanner::ENDPOS) + , line(1) {} bool Input::open(const std::string &filename) diff --git a/re2c/src/ast/input.h b/re2c/src/ast/input.h index c868ee90..376588e0 100644 --- a/re2c/src/ast/input.h +++ b/re2c/src/ast/input.h @@ -4,6 +4,7 @@ #include #include #include +#include "src/util/c99_stdint.h" #include "src/util/forbid_copy.h" namespace re2c { @@ -15,6 +16,7 @@ struct Input std::string escaped_name; const char *so; // start offset in buffer const char *eo; // end offset in buffer + uint32_t line; Input(); ~Input(); diff --git a/re2c/src/ast/lex.re b/re2c/src/ast/lex.re index 517a8e9f..3d94dfa2 100644 --- a/re2c/src/ast/lex.re +++ b/re2c/src/ast/lex.re @@ -72,7 +72,6 @@ struct ScannerState /*!stags:re2c format = "char *@@;"; */ ptrdiff_t tchar; - uint32_t cline; inline ScannerState() : lexer_state (LEX_NORMAL) @@ -88,7 +87,6 @@ struct ScannerState , eof(NULL) /*!stags:re2c format = ", @@(lim)"; */ , tchar(0) - , cline(1) { memset(lim, 0, YYMAXFILL); } @@ -167,7 +165,7 @@ echo: out.wraw(tok, ptr); out.wdelay_line_info_output(); out.wdelay_types(); - out.wdelay_line_info_input(cline, get_fname()); + out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); goto echo; } @@ -195,7 +193,7 @@ echo: "/*!header:re2c:off" { out.wraw(tok, ptr); out.header_mode(false); - out.wdelay_line_info_input(cline, get_fname()); + out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); goto echo; } @@ -219,8 +217,7 @@ echo: } eol { - cline++; - pos = cur; + next_line(); goto echo; } @@ -230,18 +227,17 @@ echo: void Scanner::lex_end_of_comment(Output &out) { - uint32_t ignored = 0; - for (;;) {/*!re2c - eof { fatal_lc(get_cline(), get_column(), "expected end of block"); } - + bool multiline = false; + for (;;) { + /*!re2c + eof { fatal_lc(get_line(), get_column(), "expected end of block"); } * { continue; } - eol { ++ignored; continue; } + eol { next_line(); multiline = true; continue; } eoc { - if (ignored > 0) { - cline += ignored; - out.wdelay_line_info_input(cline, get_fname()); + if (multiline) { + out.wdelay_line_info_input(get_line(), get_fname()); } - tok = pos = cur; + tok = cur; return; } */} @@ -252,7 +248,7 @@ void Scanner::lex_include() const char *x, *y; /*!re2c * { - fatal_lc(get_cline(), get_column() + fatal_lc(get_line(), get_column() , "syntax error in include directive"); } @@ -266,17 +262,18 @@ void Scanner::lex_include() void Scanner::lex_tags(Output &out, bool mtags) { std::string fmt, sep; - for (;;) {/*!re2c - * { fatal_lc(get_cline(), get_column(), "unrecognized configuration"); } + for (;;) { + /*!re2c + * { fatal_lc(get_line(), get_column(), "unrecognized configuration"); } "format" { fmt = lex_conf_string(); continue; } "separator" { sep = lex_conf_string(); continue; } space+ { continue; } - eol { ++cline; continue; } + eol { next_line(); continue; } eoc { out.wdelay_tags(new ConfTags(fmt, sep), mtags); - tok = pos = cur; + tok = cur; return; } */} @@ -311,7 +308,7 @@ scan: [@#] name { const std::string *name = new std::string(tok + 1, tok_len() - 1); - yylval.regexp = ast_tag(cline, get_column(), name, tok[0] == '#'); + yylval.regexp = ast_tag(get_line(), get_column(), name, tok[0] == '#'); return TOKEN_REGEXP; } @@ -319,7 +316,7 @@ scan: "{" [0-9]+ "}" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { - fatal_lc(get_cline(), get_column(), "repetition count overflow"); + fatal_lc(get_line(), get_column(), "repetition count overflow"); } yylval.bounds.max = yylval.bounds.min; return TOKEN_CLOSESIZE; @@ -327,30 +324,30 @@ scan: "{" [0-9]+ @p "," [0-9]+ "}" { if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + fatal_lc(get_line(), get_column(), "repetition lower bound overflow"); } if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max)) { - fatal_lc(get_cline(), get_column(), "repetition upper bound overflow"); + fatal_lc(get_line(), get_column(), "repetition upper bound overflow"); } return TOKEN_CLOSESIZE; } "{" [0-9]+ ",}" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + fatal_lc(get_line(), get_column(), "repetition lower bound overflow"); } yylval.bounds.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } "{" [0-9]* "," { - fatal_lc(get_cline(), get_column(), + fatal_lc(get_line(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } "{" name "}" { if (!globopts->FFlag) { - fatal_lc(get_cline(), get_column(), + fatal_lc(get_line(), get_column(), "curly braces for names only allowed with -F switch"); } yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces @@ -377,13 +374,13 @@ scan: col = static_cast(s - tok); str->push_back(ASTChar(chr, col)); } - yylval.regexp = ast_str(cline, get_column(), str, false); + yylval.regexp = ast_str(get_line(), get_column(), str, false); return TOKEN_REGEXP; } } "." { - yylval.regexp = ast_dot(cline, get_column()); + yylval.regexp = ast_dot(get_line(), get_column()); return TOKEN_REGEXP; } @@ -395,8 +392,7 @@ scan: } eol { - pos = cur; - cline++; + next_line(); if (lexer_state == LEX_FLEX_NAME) { lexer_state = LEX_NORMAL; return TOKEN_FID_END; @@ -407,7 +403,7 @@ scan: } * { - fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); + fatal_lc(get_line(), get_column(), "unexpected character: '%c'", *tok); goto scan; } */ @@ -457,12 +453,12 @@ end: return kind; error: delete cl; - fatal_l(get_cline(), "syntax error in condition list"); + fatal_l(get_line(), "syntax error in condition list"); } void Scanner::lex_code_indented() { - const uint32_t line = cline; + const uint32_t line = get_line(); tok = cur; code: /*!re2c @@ -475,7 +471,7 @@ code: } eof { fail_if_eof(); goto code; } - [{}] { fatal_l(get_cline(), "Curly braces are not allowed after ':='"); } + [{}] { fatal_l(get_line(), "Curly braces are not allowed after ':='"); } "/*" { lex_c_comment(); goto code; } "//" { lex_cpp_comment(); goto code; } ["'] { lex_string(cur[-1]); goto code; } @@ -485,7 +481,7 @@ code: void Scanner::lex_code_in_braces() { - const uint32_t line = cline; + const uint32_t line = get_line(); uint32_t depth = 1; code: /*!re2c @@ -499,7 +495,7 @@ code: "{" { ++depth; goto code; } linedir / lineinf { set_sourceline (); goto code; } - eol { pos = cur; cline++; goto code; } + eol { next_line(); goto code; } eof { fail_if_eof(); goto code; } "/*" { lex_c_comment(); goto code; } "//" { lex_cpp_comment(); goto code; } @@ -514,7 +510,7 @@ loop: /*!re2c ["'] { if (cur[-1] == delim) return; else goto loop; } esc [\\"'] { goto loop; } - eol { pos = cur; ++cline; goto loop; } + eol { next_line(); goto loop; } eof { fail_if_eof(); goto loop; } * { goto loop; } */ @@ -525,7 +521,7 @@ void Scanner::lex_c_comment() loop: /*!re2c eoc { return; } - eol { pos = cur; ++cline; goto loop; } + eol { next_line(); goto loop; } eof { fail_if_eof(); goto loop; } * { goto loop; } */ @@ -535,7 +531,7 @@ void Scanner::lex_cpp_comment() { loop: /*!re2c - eol { pos = cur; ++cline; return; } + eol { next_line(); return; } eof { fail_if_eof(); goto loop; } * { goto loop; } */ @@ -549,7 +545,7 @@ fst: tok = cur; c = get_column(); /*!re2c - "]" { return ast_cls(cline, c0, cls, neg); } + "]" { return ast_cls(get_line(), c0, cls, neg); } "" { l = lex_cls_chr(); goto snd; } */ snd: @@ -558,7 +554,7 @@ snd: "-" / [^\]] { u = lex_cls_chr(); if (l > u) { - warn.swapped_range(cline, l, u); + warn.swapped_range(get_line(), l, u); std::swap(l, u); } goto add; @@ -572,7 +568,7 @@ add: uint32_t Scanner::lex_cls_chr() { tok = cur; - const uint32_t l = get_cline(), c = get_column(); + const uint32_t l = get_line(), c = get_column(); /*!re2c * { fatal_lc(l, c, "syntax error"); } eof { fail_if_eof(); return 0; } @@ -595,7 +591,7 @@ uint32_t Scanner::lex_cls_chr() esc "-" { return static_cast('-'); } esc "]" { return static_cast(']'); } esc (.\eof){ - warn.useless_escape(cline, get_column(), tok[1]); + warn.useless_escape(l, c, tok[1]); return static_cast(tok[1]); } */ @@ -605,7 +601,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) { end = false; tok = cur; - const uint32_t l = get_cline(), c = get_column(); + const uint32_t l = get_line(), c = get_column(); /*!re2c * { fatal_lc(l, c, "syntax error"); } eof { fail_if_eof(); return 0; } @@ -630,7 +626,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) esc "\\" { return static_cast('\\'); } esc (.\eof){ if (tok[1] != quote) { - warn.useless_escape(cline, get_column(), tok[1]); + warn.useless_escape(l, c, tok[1]); } return static_cast(tok[1]); } @@ -639,11 +635,11 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) const AST *Scanner::lex_str(char quote) { - const uint32_t column = get_column(); + const uint32_t line = get_line(), column = get_column(); std::vector *str = new std::vector; for (bool end;;) { const uint32_t c = lex_str_chr(quote, end); - if (end) return ast_str(cline, column, str, quote == '\''); + if (end) return ast_str(line, column, str, quote == '\''); str->push_back(ASTChar(c, get_column())); } } @@ -654,9 +650,11 @@ sourceline: tok = cur; /*!re2c lineno { - if (!s_to_u32_unsafe (tok, cur, cline)) { - fatal_lc(get_cline(), get_column(), "line number overflow"); + uint32_t l; + if (!s_to_u32_unsafe (tok, cur, l)) { + fatal_lc(get_line(), get_column(), "line number overflow"); } + set_line(l); goto sourceline; } @@ -677,7 +675,7 @@ void Scanner::fail_if_eof() const { if (is_eof()) { const uint32_t col = static_cast(cur - pos) - 1; - fatal_lc(get_cline(), col, "unexpected end of input"); + fatal_lc(get_line(), col, "unexpected end of input"); } } diff --git a/re2c/src/ast/lex_conf.re b/re2c/src/ast/lex_conf.re index 979280e5..72d7cfb4 100644 --- a/re2c/src/ast/lex_conf.re +++ b/re2c/src/ast/lex_conf.re @@ -38,7 +38,7 @@ namespace re2c void Scanner::lex_conf(Opt &opts) { tok = cur; - const uint32_t l = get_cline(), c = get_column(); + const uint32_t l = get_line(), c = get_column(); /*!re2c "flags:" ("b" | "bit-vectors") { opts.set_bFlag (lex_conf_bool()); return; } "flags:" ("d" | "debug-output") { opts.set_dFlag (lex_conf_bool()); return; } @@ -179,7 +179,7 @@ void Scanner::lex_conf_encoding_policy(Opt &opts) { lex_conf_assign (); /*!re2c - * { fatal_lc(get_cline(), get_column(), + * { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); } "ignore" { opts.set_encoding_policy(Enc::POLICY_IGNORE); goto end; } "substitute" { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); goto end; } @@ -193,7 +193,7 @@ void Scanner::lex_conf_input(Opt &opts) { lex_conf_assign (); /*!re2c - * { fatal_lc(get_cline(), get_column(), + * { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'default', 'custom')"); } "default" { opts.set_input_api(INPUT_DEFAULT); goto end; } "custom" { opts.set_input_api(INPUT_CUSTOM); goto end; } @@ -206,7 +206,7 @@ void Scanner::lex_conf_empty_class(Opt &opts) { lex_conf_assign (); /*!re2c - * { fatal_lc(get_cline(), get_column(), + * { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); } "match-empty" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); goto end; } "match-none" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); goto end; } @@ -220,7 +220,7 @@ void Scanner::lex_conf_dfa_minimization(Opt &opts) { lex_conf_assign (); /*!re2c - * { fatal_lc(get_cline(), get_column(), + * { fatal_lc(get_line(), get_column(), "bad configuration value (expected: 'table', 'moore')"); } "table" { opts.set_dfa_minimization(DFA_MINIMIZATION_TABLE); goto end; } "moore" { opts.set_dfa_minimization(DFA_MINIMIZATION_MOORE); goto end; } @@ -241,7 +241,7 @@ void Scanner::lex_conf_enc(Enc::type_t enc, Opt &opts) void Scanner::lex_conf_assign () { /*!re2c - * { fatal_lc(get_cline(), get_column(), "missing '=' in configuration"); } + * { fatal_lc(get_line(), get_column(), "missing '=' in configuration"); } conf_assign { return; } */ } @@ -249,7 +249,7 @@ void Scanner::lex_conf_assign () void Scanner::lex_conf_semicolon () { /*!re2c - * { fatal_lc(get_cline(), get_column(), "missing ending ';' in configuration"); } + * { fatal_lc(get_line(), get_column(), "missing ending ';' in configuration"); } space* ";" { return; } */ } @@ -264,12 +264,12 @@ int32_t Scanner::lex_conf_number () lex_conf_assign (); tok = cur; /*!re2c - * { fatal_lc(get_cline(), get_column(), + * { fatal_lc(get_line(), get_column(), "bad configuration value (expected number)"); } number { int32_t n = 0; if (!s_to_i32_unsafe (tok, cur, n)) { - fatal_lc(get_cline(), get_column(), "configuration value overflow"); + fatal_lc(get_line(), get_column(), "configuration value overflow"); } lex_conf_semicolon (); return n; @@ -291,7 +291,7 @@ std::string Scanner::lex_conf_string () goto end; } if (c > 0xFF) { - fatal_lc(get_cline(), get_column(), + fatal_lc(get_line(), get_column(), "multibyte character in configuration string: 0x%X", c); } else { s += static_cast(c); diff --git a/re2c/src/ast/parser.ypp b/re2c/src/ast/parser.ypp index e1921a19..f69e3a9f 100644 --- a/re2c/src/ast/parser.ypp +++ b/re2c/src/ast/parser.ypp @@ -80,13 +80,13 @@ spec def : name expr enddef { if (!context.symtab.insert(std::make_pair(*$1, $2)).second) { - fatal_l(context.input.get_cline(), "sym already defined"); + fatal_l(context.input.get_line(), "sym already defined"); } delete $1; } /* errors */ | name expr '/' { - fatal_l(context.input.get_cline(), + fatal_l(context.input.get_line(), "trailing contexts are not allowed in named definitions"); }; @@ -142,7 +142,7 @@ rule } | TOKEN_CZERO ccode { - const AST *r = ast_nil(context.input.get_cline(), 0); + const AST *r = ast_nil(context.input.get_line(), 0); find(context.specs, "0").rules.push_back(ASTRule(r, $2)); delete $1; }; @@ -157,7 +157,7 @@ ccode } | TOKEN_CJUMP { - $$ = new Code(context.input.get_fname(), context.input.get_cline()); + $$ = new Code(context.input.get_fname(), context.input.get_line()); $$->cond = *$1; delete $1; }; @@ -167,7 +167,7 @@ trailexpr $$ = ast_cap($1); } | expr '/' expr { $$ = ast_cat(ast_cap($1), - ast_cat(ast_tag(context.input.get_cline(), 0, NULL, false), $3)); + ast_cat(ast_tag(context.input.get_line(), 0, NULL, false), $3)); }; expr: @@ -231,7 +231,7 @@ primary | TOKEN_ID { symtab_t::iterator i = context.symtab.find(*$1); if (i == context.symtab.end()) { - fatal_l(context.input.get_cline(), + fatal_l(context.input.get_line(), "undefined symbol '%s'", $1->c_str()); } $$ = i->second; @@ -249,7 +249,7 @@ extern "C" { void yyerror(context_t &context, const char* s) { - fatal_l(context.input.get_cline(), "%s", s); + fatal_l(context.input.get_line(), "%s", s); } int yylex(context_t &context) diff --git a/re2c/src/ast/scanner.cc b/re2c/src/ast/scanner.cc index 6a8d9baa..6271c1be 100644 --- a/re2c/src/ast/scanner.cc +++ b/re2c/src/ast/scanner.cc @@ -22,7 +22,11 @@ size_t Scanner::get_input_index() const { size_t i = files.size(); assert(i > 0); - do --i; while (i > 0 && files[i]->so > cur); + for (;;) { + --i; + Input *in = files[i]; + if (i == 0 || (cur >= in->so && cur <= in->eo)) break; + } return i; } @@ -105,7 +109,13 @@ void Scanner::pop_finished_files() // bottom of the stack. size_t i = files.size(); assert(i > 0); - do --i; while (i > 0 && files[i]->eo <= tok); + for (;;) { + --i; + Input *in = files[i]; + if (i == 0 || in->eo >= tok) break; + files.pop_back(); + delete in; + } } bool Scanner::fill(size_t need) diff --git a/re2c/src/ast/scanner.h b/re2c/src/ast/scanner.h index 0a5f3074..742c3f64 100644 --- a/re2c/src/ast/scanner.h +++ b/re2c/src/ast/scanner.h @@ -41,7 +41,7 @@ public: ~Scanner(); bool init(const std::string &filename); bool include(const std::string &filename); - uint32_t get_cline() const; + uint32_t get_line() const; uint32_t get_column() const; const std::string & get_fname() const; ParseMode echo(Output &out); @@ -56,6 +56,8 @@ private: size_t get_input_index() const; Input& get_input(); const Input& get_cinput() const; + inline void set_line(uint32_t l); + inline void next_line(); size_t tok_len() const; void set_sourceline (); void lex_end_of_comment(Output &out); @@ -106,9 +108,20 @@ inline const std::string & Scanner::get_fname() const return get_cinput().escaped_name; } -inline uint32_t Scanner::get_cline() const +inline uint32_t Scanner::get_line() const { - return cline; + return get_cinput().line; +} + +inline void Scanner::set_line(uint32_t l) +{ + get_input().line = l; +} + +inline void Scanner::next_line() +{ + pos = cur; + ++get_input().line; } inline uint32_t Scanner::get_column() const diff --git a/re2c/src/ast/validate.cc b/re2c/src/ast/validate.cc index 647b95df..b6100a85 100644 --- a/re2c/src/ast/validate.cc +++ b/re2c/src/ast/validate.cc @@ -11,7 +11,7 @@ namespace re2c { void validate_mode(Scanner::ParseMode mode, bool rflag, bool rules, Scanner &input) { - const uint32_t l = input.get_cline(); + const uint32_t l = input.get_line(); if (mode == Scanner::Rules) { if (!rflag) { fatal_l(l, "found 'rules:re2c' block without -r flag"); diff --git a/re2c/src/compile.cc b/re2c/src/compile.cc index bb756404..2c8fcb01 100644 --- a/re2c/src/compile.cc +++ b/re2c/src/compile.cc @@ -132,7 +132,7 @@ void compile(Scanner &input, Output &output, Opt &opts) output.header_mode(0); output.new_block(opts); output.wversion_time(); - output.wdelay_line_info_input(input.get_cline(), input.get_fname()); + output.wdelay_line_info_input(input.get_line(), input.get_fname()); if (globopts->target == TARGET_SKELETON) { emit_prolog(output); @@ -169,7 +169,7 @@ void compile(Scanner &input, Output &output, Opt &opts) normalize_ast(specs); // compile AST to DFA - output.block().line = input.get_cline(); + output.block().line = input.get_line(); dfas_t dfas; for (specs_t::const_iterator i = specs.begin(); i != specs.end(); ++i) { dfas.push_back(ast_to_dfa(*i, output)); @@ -183,7 +183,7 @@ void compile(Scanner &input, Output &output, Opt &opts) } } - output.wdelay_line_info_input(input.get_cline(), input.get_fname()); + output.wdelay_line_info_input(input.get_line(), input.get_fname()); } if (globopts->target == TARGET_SKELETON) { diff --git a/re2c/test/include/include001a.c b/re2c/test/include/include001a.c new file mode 100644 index 00000000..b0c1c25b --- /dev/null +++ b/re2c/test/include/include001a.c @@ -0,0 +1,36 @@ +/* Generated by re2c */ +#line 1 "include/include001a.re" +#line 3 "include001c.re" + + + +#line 5 "include001b.re" + + + + +#line 13 "include/include001a.c" +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'b': goto yy3; + case 'c': goto yy5; + default: goto yy2; + } +yy2: +yy3: + ++YYCURSOR; +#line 4 "include/include001a.re" + {} +#line 28 "include/include001a.c" +yy5: + ++YYCURSOR; +#line 5 "include/include001a.re" + {} +#line 33 "include/include001a.c" +} +#line 6 "include/include001a.re" + +re2c: warning: line 6: control flow is undefined for strings that match '[\x0-\x61\x64-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/include/include001a.i.c b/re2c/test/include/include001a.i.c deleted file mode 100644 index e480a912..00000000 --- a/re2c/test/include/include001a.i.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Generated by re2c */ - - - - - - - -{ - YYCTYPE yych; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'b': goto yy3; - case 'c': goto yy5; - default: goto yy2; - } -yy2: -yy3: - ++YYCURSOR; - {} -yy5: - ++YYCURSOR; - {} -} - -re2c: warning: line 14: control flow is undefined for strings that match '[\x0-\x61\x64-\xFF]', use default rule '*' [-Wundefined-control-flow] diff --git a/re2c/test/include/include001a.i.re b/re2c/test/include/include001a.i.re deleted file mode 100644 index 22766df3..00000000 --- a/re2c/test/include/include001a.i.re +++ /dev/null @@ -1,6 +0,0 @@ -/*!include:re2c "include001b.i.re" */ - -/*!re2c - b {} - c {} -*/ diff --git a/re2c/test/include/include001a.re b/re2c/test/include/include001a.re new file mode 100644 index 00000000..21e4b1f7 --- /dev/null +++ b/re2c/test/include/include001a.re @@ -0,0 +1,6 @@ +/*!include:re2c "include001b.re" */ + +/*!re2c + b {} + c {} +*/ diff --git a/re2c/test/include/include001b.c b/re2c/test/include/include001b.c new file mode 100644 index 00000000..b7ac2a55 --- /dev/null +++ b/re2c/test/include/include001b.c @@ -0,0 +1,8 @@ +/* Generated by re2c */ +#line 1 "include/include001b.re" +#line 3 "include001c.re" + + + +#line 5 "include/include001b.re" + diff --git a/re2c/test/include/include001b.i.c b/re2c/test/include/include001b.i.c deleted file mode 100644 index f62102ad..00000000 --- a/re2c/test/include/include001b.i.c +++ /dev/null @@ -1,5 +0,0 @@ -/* Generated by re2c */ - - - - diff --git a/re2c/test/include/include001b.i.re b/re2c/test/include/include001b.i.re deleted file mode 100644 index 02a3a8a7..00000000 --- a/re2c/test/include/include001b.i.re +++ /dev/null @@ -1,5 +0,0 @@ -/*!include:re2c "include001c.i.re" */ - -/*!re2c - b = "b"; -*/ diff --git a/re2c/test/include/include001b.re b/re2c/test/include/include001b.re new file mode 100644 index 00000000..54dca6fd --- /dev/null +++ b/re2c/test/include/include001b.re @@ -0,0 +1,5 @@ +/*!include:re2c "include001c.re" */ + +/*!re2c + b = "b"; +*/ diff --git a/re2c/test/include/include001c.c b/re2c/test/include/include001c.c new file mode 100644 index 00000000..a757504a --- /dev/null +++ b/re2c/test/include/include001c.c @@ -0,0 +1,4 @@ +/* Generated by re2c */ +#line 1 "include/include001c.re" +#line 3 "include/include001c.re" + diff --git a/re2c/test/include/include001c.i.c b/re2c/test/include/include001c.i.c deleted file mode 100644 index f6b3cb39..00000000 --- a/re2c/test/include/include001c.i.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Generated by re2c */ - diff --git a/re2c/test/include/include001c.i.re b/re2c/test/include/include001c.re similarity index 100% rename from re2c/test/include/include001c.i.re rename to re2c/test/include/include001c.re