From badd5f6b62d3412af93c4f0fbcdab2070da40d37 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 27 Dec 2018 22:38:59 +0000 Subject: [PATCH] Tweaking a couple of labels in lexer to simplify updating of token pointer. --- re2c/bootstrap/src/ast/lex.cc | 764 +++++++++++++++++----------------- re2c/bootstrap/src/ast/lex.h | 2 +- re2c/src/ast/lex.re | 266 ++++++------ 3 files changed, 533 insertions(+), 499 deletions(-) diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 99e4469e..f341d984 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 Thu Dec 27 22:16:41 2018 */ +/* Generated by re2c 1.1.1 on Thu Dec 27 22:37:13 2018 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include @@ -40,11 +40,11 @@ Scanner::ParseMode Scanner::echo(Output &out) { if (is_eof()) return Stop; +next: tok = cur; -echo: +loop: ptr = cur; - #line 49 "src/ast/lex.cc" { YYCTYPE yych; @@ -105,17 +105,19 @@ echo: ++YYCURSOR; #line 204 "../src/ast/lex.re" { - if (!is_eof()) goto echo; - out.wraw(tok, ptr); - return Stop; + if (is_eof()) { + out.wraw(tok, ptr); + return Stop; + } + goto loop; } -#line 113 "src/ast/lex.cc" +#line 115 "src/ast/lex.cc" yy4: ++YYCURSOR; yy5: -#line 221 "../src/ast/lex.re" - { goto echo; } -#line 119 "src/ast/lex.cc" +#line 223 "../src/ast/lex.re" + { goto loop; } +#line 121 "src/ast/lex.cc" yy6: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -124,12 +126,12 @@ yy6: } if (yych == '#') goto yy14; yy7: -#line 216 "../src/ast/lex.re" +#line 218 "../src/ast/lex.re" { next_line(); - goto echo; + goto loop; } -#line 133 "src/ast/lex.cc" +#line 135 "src/ast/lex.cc" yy8: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy6; @@ -177,7 +179,7 @@ yy16: out.wraw(tok, ptr); return Parse; } -#line 181 "src/ast/lex.cc" +#line 183 "src/ast/lex.cc" yy18: yych = (YYCTYPE)*++YYCURSOR; if (yych == '!') goto yy20; @@ -473,13 +475,13 @@ yy80: yy82: ++YYCURSOR; YYCURSOR = yyt1; -#line 210 "../src/ast/lex.re" +#line 212 "../src/ast/lex.re" { out.wraw(tok, ptr + 1); set_sourceline(); - goto echo; + goto next; } -#line 483 "src/ast/lex.cc" +#line 485 "src/ast/lex.cc" yy84: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy82; @@ -617,9 +619,9 @@ yy115: out.wraw(tok, ptr); out.wdelay_yymaxfill(); lex_end_of_comment(out); - goto echo; + goto next; } -#line 623 "src/ast/lex.cc" +#line 625 "src/ast/lex.cc" yy117: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'h') goto yy128; @@ -647,7 +649,7 @@ yy122: out.wraw(tok, ptr); return Reuse; } -#line 651 "src/ast/lex.cc" +#line 653 "src/ast/lex.cc" yy124: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy133; @@ -710,9 +712,9 @@ yy138: { out.wraw(tok, ptr); lex_tags(out, true); - goto echo; + goto next; } -#line 716 "src/ast/lex.cc" +#line 718 "src/ast/lex.cc" yy140: ++YYCURSOR; #line 124 "../src/ast/lex.re" @@ -720,16 +722,16 @@ yy140: out.wraw(tok, ptr); return Rules; } -#line 724 "src/ast/lex.cc" +#line 726 "src/ast/lex.cc" yy142: ++YYCURSOR; #line 170 "../src/ast/lex.re" { out.wraw(tok, ptr); lex_tags(out, false); - goto echo; + goto next; } -#line 733 "src/ast/lex.cc" +#line 735 "src/ast/lex.cc" yy144: ++YYCURSOR; #line 161 "../src/ast/lex.re" @@ -739,9 +741,9 @@ yy144: out.wdelay_types(); out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); - goto echo; + goto next; } -#line 745 "src/ast/lex.cc" +#line 747 "src/ast/lex.cc" yy146: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy152; @@ -756,9 +758,9 @@ yy148: { out.wraw(tok, ptr); lex_end_of_comment(out); - goto echo; + goto next; } -#line 762 "src/ast/lex.cc" +#line 764 "src/ast/lex.cc" yy150: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy154; @@ -781,9 +783,9 @@ yy154: { out.wraw(tok, ptr); lex_include(); - goto echo; + goto next; } -#line 787 "src/ast/lex.cc" +#line 789 "src/ast/lex.cc" yy156: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy160; @@ -795,9 +797,9 @@ yy157: out.wraw(tok, ptr); out.wdelay_state_goto(0); lex_end_of_comment(out); - goto echo; + goto next; } -#line 801 "src/ast/lex.cc" +#line 803 "src/ast/lex.cc" yy159: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'f') goto yy161; @@ -819,9 +821,9 @@ yy162: out.header_mode(true); out.need_header = true; lex_end_of_comment(out); - goto echo; + goto next; } -#line 825 "src/ast/lex.cc" +#line 827 "src/ast/lex.cc" yy164: ++YYCURSOR; #line 147 "../src/ast/lex.re" @@ -829,9 +831,9 @@ yy164: out.wraw(tok, ptr); out.wdelay_yymaxnmatch(); lex_end_of_comment(out); - goto echo; + goto next; } -#line 835 "src/ast/lex.cc" +#line 837 "src/ast/lex.cc" yy166: ++YYCURSOR; #line 190 "../src/ast/lex.re" @@ -840,20 +842,20 @@ yy166: out.header_mode(false); out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); - goto echo; + goto next; } -#line 846 "src/ast/lex.cc" +#line 848 "src/ast/lex.cc" } -#line 222 "../src/ast/lex.re" +#line 224 "../src/ast/lex.re" } void Scanner::lex_end_of_comment(Output &out) { bool multiline = false; - for (;;) { - -#line 857 "src/ast/lex.cc" +loop: + +#line 859 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -869,20 +871,26 @@ void Scanner::lex_end_of_comment(Output &out) } yy170: ++YYCURSOR; -#line 230 "../src/ast/lex.re" - { fatal_lc(get_line(), get_column(), "expected end of block"); } -#line 875 "src/ast/lex.cc" +#line 233 "../src/ast/lex.re" + { + fatal_lc(get_line(), get_column(), "expected end of block"); + } +#line 879 "src/ast/lex.cc" yy172: ++YYCURSOR; yy173: -#line 231 "../src/ast/lex.re" - { continue; } -#line 881 "src/ast/lex.cc" +#line 232 "../src/ast/lex.re" + { goto loop; } +#line 885 "src/ast/lex.cc" yy174: ++YYCURSOR; -#line 232 "../src/ast/lex.re" - { next_line(); multiline = true; continue; } -#line 886 "src/ast/lex.cc" +#line 236 "../src/ast/lex.re" + { + next_line(); + multiline = true; + goto loop; + } +#line 894 "src/ast/lex.cc" yy176: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy174; @@ -891,25 +899,24 @@ yy177: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy173; ++YYCURSOR; -#line 233 "../src/ast/lex.re" +#line 241 "../src/ast/lex.re" { - if (multiline) { - out.wdelay_line_info_input(get_line(), get_fname()); - } - tok = cur; - return; + if (multiline) { + out.wdelay_line_info_input(get_line(), get_fname()); } -#line 903 "src/ast/lex.cc" -} -#line 240 "../src/ast/lex.re" + return; + } +#line 910 "src/ast/lex.cc" } +#line 247 "../src/ast/lex.re" + } void Scanner::lex_include() { const char *x, *y; -#line 913 "src/ast/lex.cc" +#line 920 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -952,12 +959,11 @@ void Scanner::lex_include() if (yych == ' ') goto yy184; ++YYCURSOR; yy183: -#line 247 "../src/ast/lex.re" +#line 254 "../src/ast/lex.re" { - fatal_lc(get_line(), get_column() - , "syntax error in include directive"); + fatal_lc(get_line(), get_column(), "syntax error in include directive"); } -#line 961 "src/ast/lex.cc" +#line 967 "src/ast/lex.cc" yy184: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 64) { @@ -1033,23 +1039,23 @@ yy194: ++YYCURSOR; x = yyt1; y = yyt2; -#line 252 "../src/ast/lex.re" +#line 258 "../src/ast/lex.re" { include(std::string(x + 1, static_cast(y - x) - 2)); return; } -#line 1042 "src/ast/lex.cc" +#line 1048 "src/ast/lex.cc" } -#line 256 "../src/ast/lex.re" +#line 262 "../src/ast/lex.re" } void Scanner::lex_tags(Output &out, bool mtags) { std::string fmt, sep; - for (;;) { - -#line 1053 "src/ast/lex.cc" +loop: + +#line 1059 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1107,9 +1113,11 @@ void Scanner::lex_tags(Output &out, bool mtags) } ++YYCURSOR; yy200: -#line 264 "../src/ast/lex.re" - { fatal_lc(get_line(), get_column(), "unrecognized configuration"); } -#line 1113 "src/ast/lex.cc" +#line 270 "../src/ast/lex.re" + { + fatal_lc(get_line(), get_column(), "unrecognized configuration"); + } +#line 1121 "src/ast/lex.cc" yy201: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1117,14 +1125,19 @@ yy201: if (yybm[0+yych] & 128) { goto yy201; } -#line 269 "../src/ast/lex.re" - { continue; } -#line 1123 "src/ast/lex.cc" +#line 281 "../src/ast/lex.re" + { + goto loop; + } +#line 1133 "src/ast/lex.cc" yy204: ++YYCURSOR; -#line 270 "../src/ast/lex.re" - { next_line(); continue; } -#line 1128 "src/ast/lex.cc" +#line 284 "../src/ast/lex.re" + { + next_line(); + goto loop; + } +#line 1141 "src/ast/lex.cc" yy206: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy204; @@ -1143,13 +1156,12 @@ yy209: goto yy200; yy210: ++YYCURSOR; -#line 271 "../src/ast/lex.re" +#line 288 "../src/ast/lex.re" { - out.wdelay_tags(new ConfTags(fmt, sep), mtags); - tok = cur; - return; - } -#line 1153 "src/ast/lex.cc" + out.wdelay_tags(new ConfTags(fmt, sep), mtags); + return; + } +#line 1165 "src/ast/lex.cc" yy212: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy215; @@ -1186,9 +1198,12 @@ yy220: goto yy213; yy221: ++YYCURSOR; -#line 266 "../src/ast/lex.re" - { fmt = lex_conf_string(); continue; } -#line 1192 "src/ast/lex.cc" +#line 273 "../src/ast/lex.re" + { + fmt = lex_conf_string(); + goto loop; + } +#line 1207 "src/ast/lex.cc" yy223: yych = (YYCTYPE)*++YYCURSOR; if (yych != 't') goto yy213; @@ -1197,12 +1212,15 @@ yy223: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'r') goto yy213; ++YYCURSOR; -#line 267 "../src/ast/lex.re" - { sep = lex_conf_string(); continue; } -#line 1203 "src/ast/lex.cc" -} -#line 276 "../src/ast/lex.re" +#line 277 "../src/ast/lex.re" + { + sep = lex_conf_string(); + goto loop; + } +#line 1221 "src/ast/lex.cc" } +#line 292 "../src/ast/lex.re" + } int Scanner::scan() @@ -1211,7 +1229,7 @@ int Scanner::scan() scan: tok = cur; -#line 1215 "src/ast/lex.cc" +#line 1233 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1321,12 +1339,12 @@ scan: yy230: ++YYCURSOR; yy231: -#line 401 "../src/ast/lex.re" +#line 417 "../src/ast/lex.re" { fatal_lc(get_line(), get_column(), "unexpected character: '%c'", *tok); goto scan; } -#line 1330 "src/ast/lex.cc" +#line 1348 "src/ast/lex.cc" yy232: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1334,9 +1352,9 @@ yy232: if (yybm[0+yych] & 16) { goto yy232; } -#line 383 "../src/ast/lex.re" +#line 399 "../src/ast/lex.re" { goto scan; } -#line 1340 "src/ast/lex.cc" +#line 1358 "src/ast/lex.cc" yy235: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1347,7 +1365,7 @@ yy235: if (yych == '#') goto yy265; } yy236: -#line 390 "../src/ast/lex.re" +#line 406 "../src/ast/lex.re" { next_line(); if (lexer_state == LEX_FLEX_NAME) { @@ -1358,16 +1376,16 @@ yy236: goto scan; } } -#line 1362 "src/ast/lex.cc" +#line 1380 "src/ast/lex.cc" yy237: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy235; goto yy231; yy238: ++YYCURSOR; -#line 301 "../src/ast/lex.re" +#line 317 "../src/ast/lex.re" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; } -#line 1371 "src/ast/lex.cc" +#line 1389 "src/ast/lex.cc" yy240: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '^') { @@ -1382,30 +1400,30 @@ yy240: yy241: ++YYCURSOR; yy242: -#line 311 "../src/ast/lex.re" +#line 327 "../src/ast/lex.re" { return *tok; } -#line 1388 "src/ast/lex.cc" +#line 1406 "src/ast/lex.cc" yy243: yych = (YYCTYPE)*++YYCURSOR; if (yych == '}') goto yy270; goto yy231; yy244: ++YYCURSOR; -#line 300 "../src/ast/lex.re" +#line 316 "../src/ast/lex.re" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; } -#line 1397 "src/ast/lex.cc" +#line 1415 "src/ast/lex.cc" yy246: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy270; goto yy242; yy247: ++YYCURSOR; -#line 378 "../src/ast/lex.re" +#line 394 "../src/ast/lex.re" { yylval.regexp = ast_dot(get_line(), get_column()); return TOKEN_REGEXP; } -#line 1409 "src/ast/lex.cc" +#line 1427 "src/ast/lex.cc" yy249: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy272; @@ -1417,9 +1435,9 @@ yy250: goto yy231; yy251: ++YYCURSOR; -#line 293 "../src/ast/lex.re" +#line 309 "../src/ast/lex.re" { return lex_clist(); } -#line 1423 "src/ast/lex.cc" +#line 1441 "src/ast/lex.cc" yy253: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1433,7 +1451,7 @@ yy255: if (yybm[0+yych] & 32) { goto yy254; } -#line 355 "../src/ast/lex.re" +#line 371 "../src/ast/lex.re" { if (!globopts->FFlag || lex_namedef_context_re2c()) { yylval.str = new std::string (tok, tok_len()); @@ -1456,13 +1474,13 @@ yy255: return TOKEN_REGEXP; } } -#line 1460 "src/ast/lex.cc" +#line 1478 "src/ast/lex.cc" yy257: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy280; -#line 302 "../src/ast/lex.re" +#line 318 "../src/ast/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1466 "src/ast/lex.cc" +#line 1484 "src/ast/lex.cc" yy259: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy282; @@ -1485,9 +1503,9 @@ yy260: } } yy261: -#line 285 "../src/ast/lex.re" +#line 301 "../src/ast/lex.re" { lex_code_in_braces(); return TOKEN_CODE; } -#line 1491 "src/ast/lex.cc" +#line 1509 "src/ast/lex.cc" yy262: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1546,36 +1564,36 @@ yy267: } } yy269: -#line 305 "../src/ast/lex.re" +#line 321 "../src/ast/lex.re" { const std::string *name = new std::string(tok + 1, tok_len() - 1); yylval.regexp = ast_tag(get_line(), get_column(), name, tok[0] == '#'); return TOKEN_REGEXP; } -#line 1556 "src/ast/lex.cc" +#line 1574 "src/ast/lex.cc" yy270: ++YYCURSOR; -#line 298 "../src/ast/lex.re" +#line 314 "../src/ast/lex.re" { tok = cur; return 0; } -#line 1561 "src/ast/lex.cc" +#line 1579 "src/ast/lex.cc" yy272: ++YYCURSOR; -#line 296 "../src/ast/lex.re" +#line 312 "../src/ast/lex.re" { lex_c_comment(); goto scan; } -#line 1566 "src/ast/lex.cc" +#line 1584 "src/ast/lex.cc" yy274: ++YYCURSOR; -#line 295 "../src/ast/lex.re" +#line 311 "../src/ast/lex.re" { lex_cpp_comment(); goto scan; } -#line 1571 "src/ast/lex.cc" +#line 1589 "src/ast/lex.cc" yy276: yyaccept = 3; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych == '>') goto yy278; yy277: -#line 286 "../src/ast/lex.re" +#line 302 "../src/ast/lex.re" { lex_code_indented(); return TOKEN_CODE; } -#line 1579 "src/ast/lex.cc" +#line 1597 "src/ast/lex.cc" yy278: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1608,9 +1626,9 @@ yy278: } yy280: ++YYCURSOR; -#line 303 "../src/ast/lex.re" +#line 319 "../src/ast/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1614 "src/ast/lex.cc" +#line 1632 "src/ast/lex.cc" yy282: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy293; @@ -1618,12 +1636,12 @@ yy282: yy283: ++YYCURSOR; yy284: -#line 339 "../src/ast/lex.re" +#line 355 "../src/ast/lex.re" { fatal_lc(get_line(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 1627 "src/ast/lex.cc" +#line 1645 "src/ast/lex.cc" yy285: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1681,12 +1699,12 @@ yy290: } yy292: p = yyt1; -#line 288 "../src/ast/lex.re" +#line 304 "../src/ast/lex.re" { yylval.str = new std::string(p, static_cast(cur - p)); return tok[0] == ':' ? TOKEN_CJUMP : TOKEN_CNEXT; } -#line 1690 "src/ast/lex.cc" +#line 1708 "src/ast/lex.cc" yy293: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy300; @@ -1700,7 +1718,7 @@ yy294: goto yy284; yy295: ++YYCURSOR; -#line 313 "../src/ast/lex.re" +#line 329 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { fatal_lc(get_line(), get_column(), "repetition count overflow"); @@ -1708,10 +1726,10 @@ yy295: yylval.bounds.max = yylval.bounds.min; return TOKEN_CLOSESIZE; } -#line 1712 "src/ast/lex.cc" +#line 1730 "src/ast/lex.cc" yy297: ++YYCURSOR; -#line 344 "../src/ast/lex.re" +#line 360 "../src/ast/lex.re" { if (!globopts->FFlag) { fatal_lc(get_line(), get_column(), @@ -1720,7 +1738,7 @@ yy297: yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return TOKEN_ID; } -#line 1724 "src/ast/lex.cc" +#line 1742 "src/ast/lex.cc" yy299: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy305; @@ -1739,7 +1757,7 @@ yy301: goto yy264; yy303: ++YYCURSOR; -#line 331 "../src/ast/lex.re" +#line 347 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { fatal_lc(get_line(), get_column(), "repetition lower bound overflow"); @@ -1747,20 +1765,20 @@ yy303: yylval.bounds.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1751 "src/ast/lex.cc" +#line 1769 "src/ast/lex.cc" yy305: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy310; goto yy264; yy306: ++YYCURSOR; -#line 353 "../src/ast/lex.re" +#line 369 "../src/ast/lex.re" { return TOKEN_CONF; } -#line 1760 "src/ast/lex.cc" +#line 1778 "src/ast/lex.cc" yy308: ++YYCURSOR; p = yyt1; -#line 321 "../src/ast/lex.re" +#line 337 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) { fatal_lc(get_line(), get_column(), "repetition lower bound overflow"); @@ -1770,7 +1788,7 @@ yy308: } return TOKEN_CLOSESIZE; } -#line 1774 "src/ast/lex.cc" +#line 1792 "src/ast/lex.cc" yy310: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy312; @@ -1826,12 +1844,12 @@ yy315: yy317: ++YYCURSOR; YYCURSOR = yyt1; -#line 385 "../src/ast/lex.re" +#line 401 "../src/ast/lex.re" { set_sourceline (); return TOKEN_LINE_INFO; } -#line 1835 "src/ast/lex.cc" +#line 1853 "src/ast/lex.cc" yy319: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy317; @@ -1857,14 +1875,14 @@ yy323: if (yych == '\n') goto yy264; goto yy320; } -#line 405 "../src/ast/lex.re" +#line 421 "../src/ast/lex.re" } bool Scanner::lex_namedef_context_re2c() { -#line 1868 "src/ast/lex.cc" +#line 1886 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1919,9 +1937,9 @@ bool Scanner::lex_namedef_context_re2c() } } yy326: -#line 412 "../src/ast/lex.re" +#line 428 "../src/ast/lex.re" { return false; } -#line 1925 "src/ast/lex.cc" +#line 1943 "src/ast/lex.cc" yy327: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1938,18 +1956,18 @@ yy330: if (yych == '>') goto yy329; ++YYCURSOR; YYCURSOR = yyt1; -#line 411 "../src/ast/lex.re" +#line 427 "../src/ast/lex.re" { return true; } -#line 1944 "src/ast/lex.cc" +#line 1962 "src/ast/lex.cc" } -#line 413 "../src/ast/lex.re" +#line 429 "../src/ast/lex.re" } bool Scanner::lex_namedef_context_flex() { -#line 1953 "src/ast/lex.cc" +#line 1971 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1996,9 +2014,9 @@ bool Scanner::lex_namedef_context_flex() yyt1 = YYCURSOR; goto yy336; } -#line 421 "../src/ast/lex.re" +#line 437 "../src/ast/lex.re" { return false; } -#line 2002 "src/ast/lex.cc" +#line 2020 "src/ast/lex.cc" yy336: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2013,17 +2031,17 @@ yy336: if (yych == '{') goto yy339; } YYCURSOR = yyt1; -#line 420 "../src/ast/lex.re" +#line 436 "../src/ast/lex.re" { return true; } -#line 2019 "src/ast/lex.cc" +#line 2037 "src/ast/lex.cc" yy339: ++YYCURSOR; YYCURSOR = yyt1; -#line 419 "../src/ast/lex.re" +#line 435 "../src/ast/lex.re" { return false; } -#line 2025 "src/ast/lex.cc" +#line 2043 "src/ast/lex.cc" } -#line 422 "../src/ast/lex.re" +#line 438 "../src/ast/lex.re" } @@ -2032,7 +2050,7 @@ int Scanner::lex_clist() int kind = TOKEN_CLIST; CondList *cl = new CondList; -#line 2036 "src/ast/lex.cc" +#line 2054 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2082,30 +2100,30 @@ yy341: if (yych <= '!') goto yy345; if (yych == '>') goto yy348; yy344: -#line 432 "../src/ast/lex.re" +#line 448 "../src/ast/lex.re" { goto cond; } -#line 2088 "src/ast/lex.cc" +#line 2106 "src/ast/lex.cc" yy345: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\t') goto yy345; if (yych == ' ') goto yy345; -#line 430 "../src/ast/lex.re" +#line 446 "../src/ast/lex.re" { kind = TOKEN_CSETUP; goto cond; } -#line 2097 "src/ast/lex.cc" +#line 2115 "src/ast/lex.cc" yy348: ++YYCURSOR; -#line 431 "../src/ast/lex.re" +#line 447 "../src/ast/lex.re" { kind = TOKEN_CZERO; goto end; } -#line 2102 "src/ast/lex.cc" +#line 2120 "src/ast/lex.cc" } -#line 433 "../src/ast/lex.re" +#line 449 "../src/ast/lex.re" cond: tok = cur; -#line 2109 "src/ast/lex.cc" +#line 2127 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2157,14 +2175,14 @@ cond: } yy352: ++YYCURSOR; -#line 439 "../src/ast/lex.re" +#line 455 "../src/ast/lex.re" { goto error; } -#line 2163 "src/ast/lex.cc" +#line 2181 "src/ast/lex.cc" yy354: ++YYCURSOR; -#line 438 "../src/ast/lex.re" +#line 454 "../src/ast/lex.re" { if (!cl->empty()) goto error; cl->insert("*"); goto next; } -#line 2168 "src/ast/lex.cc" +#line 2186 "src/ast/lex.cc" yy356: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2172,15 +2190,15 @@ yy356: if (yybm[0+yych] & 128) { goto yy356; } -#line 437 "../src/ast/lex.re" +#line 453 "../src/ast/lex.re" { cl->insert(std::string(tok, tok_len())); goto next; } -#line 2178 "src/ast/lex.cc" +#line 2196 "src/ast/lex.cc" } -#line 440 "../src/ast/lex.re" +#line 456 "../src/ast/lex.re" next: -#line 2184 "src/ast/lex.cc" +#line 2202 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2231,9 +2249,9 @@ next: } ++YYCURSOR; yy362: -#line 445 "../src/ast/lex.re" +#line 461 "../src/ast/lex.re" { goto error; } -#line 2237 "src/ast/lex.cc" +#line 2255 "src/ast/lex.cc" yy363: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= ' ') { @@ -2255,14 +2273,14 @@ yy364: if (yybm[0+yych] & 128) { goto yy364; } -#line 443 "../src/ast/lex.re" +#line 459 "../src/ast/lex.re" { goto cond; } -#line 2261 "src/ast/lex.cc" +#line 2279 "src/ast/lex.cc" yy367: ++YYCURSOR; -#line 444 "../src/ast/lex.re" +#line 460 "../src/ast/lex.re" { goto end; } -#line 2266 "src/ast/lex.cc" +#line 2284 "src/ast/lex.cc" yy369: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2280,7 +2298,7 @@ yy369: YYCURSOR = YYMARKER; goto yy362; } -#line 446 "../src/ast/lex.re" +#line 462 "../src/ast/lex.re" end: yylval.clist = cl; @@ -2296,7 +2314,7 @@ void Scanner::lex_code_indented() tok = cur; code: -#line 2300 "src/ast/lex.cc" +#line 2318 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); @@ -2324,15 +2342,15 @@ code: } yy374: ++YYCURSOR; -#line 469 "../src/ast/lex.re" +#line 485 "../src/ast/lex.re" { fail_if_eof(); goto code; } -#line 2330 "src/ast/lex.cc" +#line 2348 "src/ast/lex.cc" yy376: ++YYCURSOR; yy377: -#line 474 "../src/ast/lex.re" +#line 490 "../src/ast/lex.re" { goto code; } -#line 2336 "src/ast/lex.cc" +#line 2354 "src/ast/lex.cc" yy378: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '\f') { @@ -2343,23 +2361,23 @@ yy378: if (yych == ' ') goto yy386; } yy379: -#line 462 "../src/ast/lex.re" +#line 478 "../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 2354 "src/ast/lex.cc" +#line 2372 "src/ast/lex.cc" yy380: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy378; goto yy377; yy381: ++YYCURSOR; -#line 473 "../src/ast/lex.re" +#line 489 "../src/ast/lex.re" { lex_string(cur[-1]); goto code; } -#line 2363 "src/ast/lex.cc" +#line 2381 "src/ast/lex.cc" yy383: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy388; @@ -2367,27 +2385,27 @@ yy383: goto yy377; yy384: ++YYCURSOR; -#line 470 "../src/ast/lex.re" +#line 486 "../src/ast/lex.re" { fatal_l(get_line(), "Curly braces are not allowed after ':='"); } -#line 2373 "src/ast/lex.cc" +#line 2391 "src/ast/lex.cc" yy386: ++YYCURSOR; YYCURSOR -= 1; -#line 461 "../src/ast/lex.re" +#line 477 "../src/ast/lex.re" { goto code; } -#line 2379 "src/ast/lex.cc" +#line 2397 "src/ast/lex.cc" yy388: ++YYCURSOR; -#line 471 "../src/ast/lex.re" +#line 487 "../src/ast/lex.re" { lex_c_comment(); goto code; } -#line 2384 "src/ast/lex.cc" +#line 2402 "src/ast/lex.cc" yy390: ++YYCURSOR; -#line 472 "../src/ast/lex.re" +#line 488 "../src/ast/lex.re" { lex_cpp_comment(); goto code; } -#line 2389 "src/ast/lex.cc" +#line 2407 "src/ast/lex.cc" } -#line 475 "../src/ast/lex.re" +#line 491 "../src/ast/lex.re" } @@ -2397,7 +2415,7 @@ void Scanner::lex_code_in_braces() uint32_t depth = 1; code: -#line 2401 "src/ast/lex.cc" +#line 2419 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2459,15 +2477,15 @@ code: } yy394: ++YYCURSOR; -#line 495 "../src/ast/lex.re" +#line 511 "../src/ast/lex.re" { fail_if_eof(); goto code; } -#line 2465 "src/ast/lex.cc" +#line 2483 "src/ast/lex.cc" yy396: ++YYCURSOR; yy397: -#line 499 "../src/ast/lex.re" +#line 515 "../src/ast/lex.re" { goto code; } -#line 2471 "src/ast/lex.cc" +#line 2489 "src/ast/lex.cc" yy398: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -2475,18 +2493,18 @@ yy398: } if (yych == '#') goto yy411; yy399: -#line 494 "../src/ast/lex.re" +#line 510 "../src/ast/lex.re" { next_line(); goto code; } -#line 2481 "src/ast/lex.cc" +#line 2499 "src/ast/lex.cc" yy400: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy398; goto yy397; yy401: ++YYCURSOR; -#line 498 "../src/ast/lex.re" +#line 514 "../src/ast/lex.re" { lex_string(cur[-1]); goto code; } -#line 2490 "src/ast/lex.cc" +#line 2508 "src/ast/lex.cc" yy403: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy413; @@ -2494,12 +2512,12 @@ yy403: goto yy397; yy404: ++YYCURSOR; -#line 492 "../src/ast/lex.re" +#line 508 "../src/ast/lex.re" { ++depth; goto code; } -#line 2500 "src/ast/lex.cc" +#line 2518 "src/ast/lex.cc" yy406: ++YYCURSOR; -#line 484 "../src/ast/lex.re" +#line 500 "../src/ast/lex.re" { if (--depth == 0) { yylval.code = new Code(get_fname (), line, tok, tok_len ()); @@ -2507,7 +2525,7 @@ yy406: } goto code; } -#line 2511 "src/ast/lex.cc" +#line 2529 "src/ast/lex.cc" yy408: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2533,14 +2551,14 @@ yy411: } yy413: ++YYCURSOR; -#line 496 "../src/ast/lex.re" +#line 512 "../src/ast/lex.re" { lex_c_comment(); goto code; } -#line 2539 "src/ast/lex.cc" +#line 2557 "src/ast/lex.cc" yy415: ++YYCURSOR; -#line 497 "../src/ast/lex.re" +#line 513 "../src/ast/lex.re" { lex_cpp_comment(); goto code; } -#line 2544 "src/ast/lex.cc" +#line 2562 "src/ast/lex.cc" yy417: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'i') goto yy410; @@ -2597,9 +2615,9 @@ yy425: yy427: ++YYCURSOR; YYCURSOR = yyt1; -#line 493 "../src/ast/lex.re" +#line 509 "../src/ast/lex.re" { set_sourceline (); goto code; } -#line 2603 "src/ast/lex.cc" +#line 2621 "src/ast/lex.cc" yy429: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy427; @@ -2625,7 +2643,7 @@ yy433: if (yych == '\n') goto yy410; goto yy430; } -#line 500 "../src/ast/lex.re" +#line 516 "../src/ast/lex.re" } @@ -2633,7 +2651,7 @@ void Scanner::lex_string(char delim) { loop: -#line 2637 "src/ast/lex.cc" +#line 2655 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2659,29 +2677,29 @@ loop: } yy436: ++YYCURSOR; -#line 510 "../src/ast/lex.re" +#line 526 "../src/ast/lex.re" { fail_if_eof(); goto loop; } -#line 2665 "src/ast/lex.cc" +#line 2683 "src/ast/lex.cc" yy438: ++YYCURSOR; yy439: -#line 511 "../src/ast/lex.re" +#line 527 "../src/ast/lex.re" { goto loop; } -#line 2671 "src/ast/lex.cc" +#line 2689 "src/ast/lex.cc" yy440: ++YYCURSOR; -#line 509 "../src/ast/lex.re" +#line 525 "../src/ast/lex.re" { next_line(); goto loop; } -#line 2676 "src/ast/lex.cc" +#line 2694 "src/ast/lex.cc" yy442: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy440; goto yy439; yy443: ++YYCURSOR; -#line 507 "../src/ast/lex.re" +#line 523 "../src/ast/lex.re" { if (cur[-1] == delim) return; else goto loop; } -#line 2685 "src/ast/lex.cc" +#line 2703 "src/ast/lex.cc" yy445: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '&') { @@ -2692,11 +2710,11 @@ yy445: } yy446: ++YYCURSOR; -#line 508 "../src/ast/lex.re" +#line 524 "../src/ast/lex.re" { goto loop; } -#line 2698 "src/ast/lex.cc" +#line 2716 "src/ast/lex.cc" } -#line 512 "../src/ast/lex.re" +#line 528 "../src/ast/lex.re" } @@ -2704,7 +2722,7 @@ void Scanner::lex_c_comment() { loop: -#line 2708 "src/ast/lex.cc" +#line 2726 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2720,20 +2738,20 @@ loop: } yy450: ++YYCURSOR; -#line 521 "../src/ast/lex.re" +#line 537 "../src/ast/lex.re" { fail_if_eof(); goto loop; } -#line 2726 "src/ast/lex.cc" +#line 2744 "src/ast/lex.cc" yy452: ++YYCURSOR; yy453: -#line 522 "../src/ast/lex.re" +#line 538 "../src/ast/lex.re" { goto loop; } -#line 2732 "src/ast/lex.cc" +#line 2750 "src/ast/lex.cc" yy454: ++YYCURSOR; -#line 520 "../src/ast/lex.re" +#line 536 "../src/ast/lex.re" { next_line(); goto loop; } -#line 2737 "src/ast/lex.cc" +#line 2755 "src/ast/lex.cc" yy456: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy454; @@ -2742,11 +2760,11 @@ yy457: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy453; ++YYCURSOR; -#line 519 "../src/ast/lex.re" +#line 535 "../src/ast/lex.re" { return; } -#line 2748 "src/ast/lex.cc" +#line 2766 "src/ast/lex.cc" } -#line 523 "../src/ast/lex.re" +#line 539 "../src/ast/lex.re" } @@ -2754,7 +2772,7 @@ void Scanner::lex_cpp_comment() { loop: -#line 2758 "src/ast/lex.cc" +#line 2776 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2769,26 +2787,26 @@ loop: } yy462: ++YYCURSOR; -#line 531 "../src/ast/lex.re" +#line 547 "../src/ast/lex.re" { fail_if_eof(); goto loop; } -#line 2775 "src/ast/lex.cc" +#line 2793 "src/ast/lex.cc" yy464: ++YYCURSOR; yy465: -#line 532 "../src/ast/lex.re" +#line 548 "../src/ast/lex.re" { goto loop; } -#line 2781 "src/ast/lex.cc" +#line 2799 "src/ast/lex.cc" yy466: ++YYCURSOR; -#line 530 "../src/ast/lex.re" +#line 546 "../src/ast/lex.re" { next_line(); return; } -#line 2786 "src/ast/lex.cc" +#line 2804 "src/ast/lex.cc" yy468: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy466; goto yy465; } -#line 533 "../src/ast/lex.re" +#line 549 "../src/ast/lex.re" } @@ -2799,36 +2817,36 @@ const AST *Scanner::lex_cls(bool neg) fst: tok = cur; c = get_column(); - -#line 2804 "src/ast/lex.cc" + +#line 2822 "src/ast/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy472; -#line 545 "../src/ast/lex.re" +#line 561 "../src/ast/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2812 "src/ast/lex.cc" +#line 2830 "src/ast/lex.cc" yy472: ++YYCURSOR; -#line 544 "../src/ast/lex.re" +#line 560 "../src/ast/lex.re" { return ast_cls(get_line(), c0, cls, neg); } -#line 2817 "src/ast/lex.cc" +#line 2835 "src/ast/lex.cc" } -#line 546 "../src/ast/lex.re" +#line 562 "../src/ast/lex.re" snd: - -#line 2823 "src/ast/lex.cc" + +#line 2841 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy477; yy476: -#line 549 "../src/ast/lex.re" +#line 565 "../src/ast/lex.re" { u = l; goto add; } -#line 2832 "src/ast/lex.cc" +#line 2850 "src/ast/lex.cc" yy477: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy479; @@ -2837,18 +2855,18 @@ yy477: yy479: ++YYCURSOR; YYCURSOR -= 1; -#line 550 "../src/ast/lex.re" +#line 566 "../src/ast/lex.re" { - u = lex_cls_chr(); - if (l > u) { - warn.swapped_range(get_line(), l, u); - std::swap(l, u); - } - goto add; + u = lex_cls_chr(); + if (l > u) { + warn.swapped_range(get_line(), l, u); + std::swap(l, u); } -#line 2850 "src/ast/lex.cc" + goto add; + } +#line 2868 "src/ast/lex.cc" } -#line 558 "../src/ast/lex.re" +#line 574 "../src/ast/lex.re" add: cls->push_back(ASTRange(l, u, c)); @@ -2859,8 +2877,8 @@ uint32_t Scanner::lex_cls_chr() { tok = cur; const uint32_t l = get_line(), c = get_column(); - -#line 2864 "src/ast/lex.cc" + +#line 2882 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2877,20 +2895,20 @@ uint32_t Scanner::lex_cls_chr() } yy483: ++YYCURSOR; -#line 570 "../src/ast/lex.re" +#line 586 "../src/ast/lex.re" { fail_if_eof(); return 0; } -#line 2883 "src/ast/lex.cc" +#line 2901 "src/ast/lex.cc" yy485: ++YYCURSOR; yy486: -#line 576 "../src/ast/lex.re" +#line 592 "../src/ast/lex.re" { return static_cast(tok[0]); } -#line 2889 "src/ast/lex.cc" +#line 2907 "src/ast/lex.cc" yy487: ++YYCURSOR; -#line 571 "../src/ast/lex.re" +#line 587 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character class"); } -#line 2894 "src/ast/lex.cc" +#line 2912 "src/ast/lex.cc" yy489: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy487; @@ -2949,36 +2967,36 @@ yy490: } } yy491: -#line 574 "../src/ast/lex.re" +#line 590 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 2955 "src/ast/lex.cc" +#line 2973 "src/ast/lex.cc" yy492: ++YYCURSOR; yy493: -#line 589 "../src/ast/lex.re" +#line 605 "../src/ast/lex.re" { - warn.useless_escape(l, c, tok[1]); - return static_cast(tok[1]); - } -#line 2964 "src/ast/lex.cc" + warn.useless_escape(l, c, tok[1]); + return static_cast(tok[1]); + } +#line 2982 "src/ast/lex.cc" yy494: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy487; goto yy493; yy495: ++YYCURSOR; -#line 587 "../src/ast/lex.re" +#line 603 "../src/ast/lex.re" { return static_cast('-'); } -#line 2973 "src/ast/lex.cc" +#line 2991 "src/ast/lex.cc" yy497: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy498; if (yych <= '7') goto yy522; yy498: -#line 573 "../src/ast/lex.re" +#line 589 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2982 "src/ast/lex.cc" +#line 3000 "src/ast/lex.cc" yy499: ++YYCURSOR; goto yy498; @@ -2994,9 +3012,9 @@ yy500: if (yych <= 'f') goto yy524; } yy501: -#line 572 "../src/ast/lex.re" +#line 588 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 3000 "src/ast/lex.cc" +#line 3018 "src/ast/lex.cc" yy502: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3012,49 +3030,49 @@ yy502: } yy503: ++YYCURSOR; -#line 586 "../src/ast/lex.re" +#line 602 "../src/ast/lex.re" { return static_cast('\\'); } -#line 3018 "src/ast/lex.cc" +#line 3036 "src/ast/lex.cc" yy505: ++YYCURSOR; -#line 588 "../src/ast/lex.re" +#line 604 "../src/ast/lex.re" { return static_cast(']'); } -#line 3023 "src/ast/lex.cc" +#line 3041 "src/ast/lex.cc" yy507: ++YYCURSOR; -#line 579 "../src/ast/lex.re" +#line 595 "../src/ast/lex.re" { return static_cast('\a'); } -#line 3028 "src/ast/lex.cc" +#line 3046 "src/ast/lex.cc" yy509: ++YYCURSOR; -#line 580 "../src/ast/lex.re" +#line 596 "../src/ast/lex.re" { return static_cast('\b'); } -#line 3033 "src/ast/lex.cc" +#line 3051 "src/ast/lex.cc" yy511: ++YYCURSOR; -#line 581 "../src/ast/lex.re" +#line 597 "../src/ast/lex.re" { return static_cast('\f'); } -#line 3038 "src/ast/lex.cc" +#line 3056 "src/ast/lex.cc" yy513: ++YYCURSOR; -#line 582 "../src/ast/lex.re" +#line 598 "../src/ast/lex.re" { return static_cast('\n'); } -#line 3043 "src/ast/lex.cc" +#line 3061 "src/ast/lex.cc" yy515: ++YYCURSOR; -#line 583 "../src/ast/lex.re" +#line 599 "../src/ast/lex.re" { return static_cast('\r'); } -#line 3048 "src/ast/lex.cc" +#line 3066 "src/ast/lex.cc" yy517: ++YYCURSOR; -#line 584 "../src/ast/lex.re" +#line 600 "../src/ast/lex.re" { return static_cast('\t'); } -#line 3053 "src/ast/lex.cc" +#line 3071 "src/ast/lex.cc" yy519: ++YYCURSOR; -#line 585 "../src/ast/lex.re" +#line 601 "../src/ast/lex.re" { return static_cast('\v'); } -#line 3058 "src/ast/lex.cc" +#line 3076 "src/ast/lex.cc" yy521: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3117,9 +3135,9 @@ yy526: } yy527: ++YYCURSOR; -#line 578 "../src/ast/lex.re" +#line 594 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 3123 "src/ast/lex.cc" +#line 3141 "src/ast/lex.cc" yy529: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3146,9 +3164,9 @@ yy530: } yy531: ++YYCURSOR; -#line 577 "../src/ast/lex.re" +#line 593 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 3152 "src/ast/lex.cc" +#line 3170 "src/ast/lex.cc" yy533: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3172,7 +3190,7 @@ yy534: goto yy523; } } -#line 593 "../src/ast/lex.re" +#line 609 "../src/ast/lex.re" } @@ -3181,8 +3199,8 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) end = false; tok = cur; const uint32_t l = get_line(), c = get_column(); - -#line 3186 "src/ast/lex.cc" + +#line 3204 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -3199,23 +3217,23 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) } yy537: ++YYCURSOR; -#line 603 "../src/ast/lex.re" +#line 619 "../src/ast/lex.re" { fail_if_eof(); return 0; } -#line 3205 "src/ast/lex.cc" +#line 3223 "src/ast/lex.cc" yy539: ++YYCURSOR; yy540: -#line 609 "../src/ast/lex.re" +#line 625 "../src/ast/lex.re" { - end = tok[0] == quote; - return static_cast(tok[0]); - } -#line 3214 "src/ast/lex.cc" + end = tok[0] == quote; + return static_cast(tok[0]); + } +#line 3232 "src/ast/lex.cc" yy541: ++YYCURSOR; -#line 604 "../src/ast/lex.re" +#line 620 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character string"); } -#line 3219 "src/ast/lex.cc" +#line 3237 "src/ast/lex.cc" yy543: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy541; @@ -3269,20 +3287,20 @@ yy544: } } yy545: -#line 607 "../src/ast/lex.re" +#line 623 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 3275 "src/ast/lex.cc" +#line 3293 "src/ast/lex.cc" yy546: ++YYCURSOR; yy547: -#line 623 "../src/ast/lex.re" +#line 639 "../src/ast/lex.re" { - if (tok[1] != quote) { - warn.useless_escape(l, c, tok[1]); - } - return static_cast(tok[1]); + if (tok[1] != quote) { + warn.useless_escape(l, c, tok[1]); } -#line 3286 "src/ast/lex.cc" + return static_cast(tok[1]); + } +#line 3304 "src/ast/lex.cc" yy548: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy541; @@ -3293,9 +3311,9 @@ yy549: if (yych <= '/') goto yy550; if (yych <= '7') goto yy572; yy550: -#line 606 "../src/ast/lex.re" +#line 622 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 3299 "src/ast/lex.cc" +#line 3317 "src/ast/lex.cc" yy551: ++YYCURSOR; goto yy550; @@ -3311,9 +3329,9 @@ yy552: if (yych <= 'f') goto yy574; } yy553: -#line 605 "../src/ast/lex.re" +#line 621 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 3317 "src/ast/lex.cc" +#line 3335 "src/ast/lex.cc" yy554: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3329,44 +3347,44 @@ yy554: } yy555: ++YYCURSOR; -#line 622 "../src/ast/lex.re" +#line 638 "../src/ast/lex.re" { return static_cast('\\'); } -#line 3335 "src/ast/lex.cc" +#line 3353 "src/ast/lex.cc" yy557: ++YYCURSOR; -#line 615 "../src/ast/lex.re" +#line 631 "../src/ast/lex.re" { return static_cast('\a'); } -#line 3340 "src/ast/lex.cc" +#line 3358 "src/ast/lex.cc" yy559: ++YYCURSOR; -#line 616 "../src/ast/lex.re" +#line 632 "../src/ast/lex.re" { return static_cast('\b'); } -#line 3345 "src/ast/lex.cc" +#line 3363 "src/ast/lex.cc" yy561: ++YYCURSOR; -#line 617 "../src/ast/lex.re" +#line 633 "../src/ast/lex.re" { return static_cast('\f'); } -#line 3350 "src/ast/lex.cc" +#line 3368 "src/ast/lex.cc" yy563: ++YYCURSOR; -#line 618 "../src/ast/lex.re" +#line 634 "../src/ast/lex.re" { return static_cast('\n'); } -#line 3355 "src/ast/lex.cc" +#line 3373 "src/ast/lex.cc" yy565: ++YYCURSOR; -#line 619 "../src/ast/lex.re" +#line 635 "../src/ast/lex.re" { return static_cast('\r'); } -#line 3360 "src/ast/lex.cc" +#line 3378 "src/ast/lex.cc" yy567: ++YYCURSOR; -#line 620 "../src/ast/lex.re" +#line 636 "../src/ast/lex.re" { return static_cast('\t'); } -#line 3365 "src/ast/lex.cc" +#line 3383 "src/ast/lex.cc" yy569: ++YYCURSOR; -#line 621 "../src/ast/lex.re" +#line 637 "../src/ast/lex.re" { return static_cast('\v'); } -#line 3370 "src/ast/lex.cc" +#line 3388 "src/ast/lex.cc" yy571: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3429,9 +3447,9 @@ yy576: } yy577: ++YYCURSOR; -#line 614 "../src/ast/lex.re" +#line 630 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 3435 "src/ast/lex.cc" +#line 3453 "src/ast/lex.cc" yy579: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3458,9 +3476,9 @@ yy580: } yy581: ++YYCURSOR; -#line 613 "../src/ast/lex.re" +#line 629 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 3464 "src/ast/lex.cc" +#line 3482 "src/ast/lex.cc" yy583: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3484,7 +3502,7 @@ yy584: goto yy573; } } -#line 629 "../src/ast/lex.re" +#line 645 "../src/ast/lex.re" } @@ -3504,7 +3522,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 3508 "src/ast/lex.cc" +#line 3526 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -3562,20 +3580,20 @@ sourceline: } } ++YYCURSOR; -#line 665 "../src/ast/lex.re" +#line 681 "../src/ast/lex.re" { --cur; return; } -#line 3568 "src/ast/lex.cc" +#line 3586 "src/ast/lex.cc" yy589: ++YYCURSOR; yy590: -#line 666 "../src/ast/lex.re" +#line 682 "../src/ast/lex.re" { goto sourceline; } -#line 3574 "src/ast/lex.cc" +#line 3592 "src/ast/lex.cc" yy591: ++YYCURSOR; -#line 664 "../src/ast/lex.re" +#line 680 "../src/ast/lex.re" { tok = cur; return; } -#line 3579 "src/ast/lex.cc" +#line 3597 "src/ast/lex.cc" yy593: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy591; @@ -3592,7 +3610,7 @@ yy595: if (yybm[0+yych] & 64) { goto yy595; } -#line 648 "../src/ast/lex.re" +#line 664 "../src/ast/lex.re" { uint32_t l; if (!s_to_u32_unsafe (tok, cur, l)) { @@ -3601,7 +3619,7 @@ yy595: set_line(l); goto sourceline; } -#line 3605 "src/ast/lex.cc" +#line 3623 "src/ast/lex.cc" yy598: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3618,14 +3636,14 @@ yy600: goto yy590; yy601: ++YYCURSOR; -#line 657 "../src/ast/lex.re" +#line 673 "../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 3647 "src/ast/lex.cc" yy603: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3634,7 +3652,7 @@ yy603: if (yych == '\n') goto yy600; goto yy598; } -#line 667 "../src/ast/lex.re" +#line 683 "../src/ast/lex.re" } diff --git a/re2c/bootstrap/src/ast/lex.h b/re2c/bootstrap/src/ast/lex.h index 1ead31af..a5b65e9e 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 Thu Dec 27 22:16:41 2018 */ +/* Generated by re2c 1.1.1 on Thu Dec 27 22:37:13 2018 */ #include #include "src/util/forbid_copy.h" diff --git a/re2c/src/ast/lex.re b/re2c/src/ast/lex.re index 90104e38..21fa7375 100644 --- a/re2c/src/ast/lex.re +++ b/re2c/src/ast/lex.re @@ -111,10 +111,10 @@ Scanner::ParseMode Scanner::echo(Output &out) { if (is_eof()) return Stop; +next: tok = cur; -echo: +loop: ptr = cur; - /*!re2c "%{" | "/*!re2c" { out.wraw(tok, ptr); @@ -134,28 +134,28 @@ echo: "/*!ignore:re2c" { out.wraw(tok, ptr); lex_end_of_comment(out); - goto echo; + goto next; } "/*!max:re2c" { out.wraw(tok, ptr); out.wdelay_yymaxfill(); lex_end_of_comment(out); - goto echo; + goto next; } "/*!maxnmatch:re2c" { out.wraw(tok, ptr); out.wdelay_yymaxnmatch(); lex_end_of_comment(out); - goto echo; + goto next; } "/*!getstate:re2c" { out.wraw(tok, ptr); out.wdelay_state_goto(0); lex_end_of_comment(out); - goto echo; + goto next; } "/*!types:re2c" { @@ -164,19 +164,19 @@ echo: out.wdelay_types(); out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); - goto echo; + goto next; } "/*!stags:re2c" { out.wraw(tok, ptr); lex_tags(out, false); - goto echo; + goto next; } "/*!mtags:re2c" { out.wraw(tok, ptr); lex_tags(out, true); - goto echo; + goto next; } "/*!header:re2c:on" { @@ -184,7 +184,7 @@ echo: out.header_mode(true); out.need_header = true; lex_end_of_comment(out); - goto echo; + goto next; } "/*!header:re2c:off" { @@ -192,52 +192,59 @@ echo: out.header_mode(false); out.wdelay_line_info_input(get_line(), get_fname()); lex_end_of_comment(out); - goto echo; + goto next; } "/*!include:re2c" { out.wraw(tok, ptr); lex_include(); - goto echo; + goto next; } eof { - if (!is_eof()) goto echo; - out.wraw(tok, ptr); - return Stop; + if (is_eof()) { + out.wraw(tok, ptr); + return Stop; + } + goto loop; } linedir / lineinf { out.wraw(tok, ptr + 1); set_sourceline(); - goto echo; + goto next; } eol { next_line(); - goto echo; + goto loop; } - * { goto echo; } + * { goto loop; } */ } void Scanner::lex_end_of_comment(Output &out) { bool multiline = false; - for (;;) { - /*!re2c - eof { fatal_lc(get_line(), get_column(), "expected end of block"); } - * { continue; } - eol { next_line(); multiline = true; continue; } - eoc { - if (multiline) { - out.wdelay_line_info_input(get_line(), get_fname()); - } - tok = cur; - return; +loop: +/*!re2c + * { goto loop; } + eof { + fatal_lc(get_line(), get_column(), "expected end of block"); + } + eol { + next_line(); + multiline = true; + goto loop; + } + eoc { + if (multiline) { + out.wdelay_line_info_input(get_line(), get_fname()); } - */} + return; + } +*/ } void Scanner::lex_include() @@ -245,8 +252,7 @@ void Scanner::lex_include() const char *x, *y; /*!re2c * { - fatal_lc(get_line(), get_column() - , "syntax error in include directive"); + fatal_lc(get_line(), get_column(), "syntax error in include directive"); } space+ @x dstring @y space* eoc { @@ -259,21 +265,31 @@ void Scanner::lex_include() void Scanner::lex_tags(Output &out, bool mtags) { std::string fmt, sep; - 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 { next_line(); continue; } - eoc { - out.wdelay_tags(new ConfTags(fmt, sep), mtags); - tok = cur; - return; - } - */} +loop: +/*!re2c + * { + fatal_lc(get_line(), get_column(), "unrecognized configuration"); + } + "format" { + fmt = lex_conf_string(); + goto loop; + } + "separator" { + sep = lex_conf_string(); + goto loop; + } + space+ { + goto loop; + } + eol { + next_line(); + goto loop; + } + eoc { + out.wdelay_tags(new ConfTags(fmt, sep), mtags); + return; + } +*/ } int Scanner::scan() @@ -290,7 +306,7 @@ scan: return tok[0] == ':' ? TOKEN_CJUMP : TOKEN_CNEXT; } - "<" { return lex_clist(); } + "<" { return lex_clist(); } "//" { lex_cpp_comment(); goto scan; } "/*" { lex_c_comment(); goto scan; } @@ -434,9 +450,9 @@ int Scanner::lex_clist() cond: tok = cur; /*!re2c - name { cl->insert(std::string(tok, tok_len())); goto next; } - "*" { if (!cl->empty()) goto error; cl->insert("*"); goto next; } - * { goto error; } + name { cl->insert(std::string(tok, tok_len())); goto next; } + "*" { if (!cl->empty()) goto error; cl->insert("*"); goto next; } + * { goto error; } */ next: /*!re2c @@ -466,12 +482,12 @@ code: return; } - eof { fail_if_eof(); goto code; } - [{}] { 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; } - * { goto code; } + eof { fail_if_eof(); goto code; } + [{}] { 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; } + * { goto code; } */ } @@ -540,22 +556,22 @@ const AST *Scanner::lex_cls(bool neg) fst: tok = cur; c = get_column(); - /*!re2c - "]" { return ast_cls(get_line(), c0, cls, neg); } - "" { l = lex_cls_chr(); goto snd; } - */ +/*!re2c + "]" { return ast_cls(get_line(), c0, cls, neg); } + "" { l = lex_cls_chr(); goto snd; } +*/ snd: - /*!re2c - "" { u = l; goto add; } - "-" / [^\]] { - u = lex_cls_chr(); - if (l > u) { - warn.swapped_range(get_line(), l, u); - std::swap(l, u); - } - goto add; +/*!re2c + "" { u = l; goto add; } + "-" / [^\]] { + u = lex_cls_chr(); + if (l > u) { + warn.swapped_range(get_line(), l, u); + std::swap(l, u); } - */ + goto add; + } +*/ add: cls->push_back(ASTRange(l, u, c)); goto fst; @@ -565,32 +581,32 @@ uint32_t Scanner::lex_cls_chr() { tok = cur; const uint32_t l = get_line(), c = get_column(); - /*!re2c - * { fatal_lc(l, c, "syntax error"); } - eof { fail_if_eof(); return 0; } - esc? eol { fatal_lc(l, c, "newline in character class"); } - esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } - esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); } - esc { fatal_lc(l, c, "syntax error in escape sequence"); } - - . \ esc { return static_cast(tok[0]); } - esc_hex { return unesc_hex(tok, cur); } - esc_oct { return unesc_oct(tok, cur); } - esc "a" { return static_cast('\a'); } - esc "b" { return static_cast('\b'); } - esc "f" { return static_cast('\f'); } - esc "n" { return static_cast('\n'); } - esc "r" { return static_cast('\r'); } - esc "t" { return static_cast('\t'); } - esc "v" { return static_cast('\v'); } - esc "\\" { return static_cast('\\'); } - esc "-" { return static_cast('-'); } - esc "]" { return static_cast(']'); } - esc (.\eof){ - warn.useless_escape(l, c, tok[1]); - return static_cast(tok[1]); - } - */ +/*!re2c + * { fatal_lc(l, c, "syntax error"); } + eof { fail_if_eof(); return 0; } + esc? eol { fatal_lc(l, c, "newline in character class"); } + esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } + esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); } + esc { fatal_lc(l, c, "syntax error in escape sequence"); } + + . \ esc { return static_cast(tok[0]); } + esc_hex { return unesc_hex(tok, cur); } + esc_oct { return unesc_oct(tok, cur); } + esc "a" { return static_cast('\a'); } + esc "b" { return static_cast('\b'); } + esc "f" { return static_cast('\f'); } + esc "n" { return static_cast('\n'); } + esc "r" { return static_cast('\r'); } + esc "t" { return static_cast('\t'); } + esc "v" { return static_cast('\v'); } + esc "\\" { return static_cast('\\'); } + esc "-" { return static_cast('-'); } + esc "]" { return static_cast(']'); } + esc (.\eof){ + warn.useless_escape(l, c, tok[1]); + return static_cast(tok[1]); + } +*/ } uint32_t Scanner::lex_str_chr(char quote, bool &end) @@ -598,35 +614,35 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) end = false; tok = cur; const uint32_t l = get_line(), c = get_column(); - /*!re2c - * { fatal_lc(l, c, "syntax error"); } - eof { fail_if_eof(); return 0; } - esc? eol { fatal_lc(l, c, "newline in character string"); } - esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } - esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); } - esc { fatal_lc(l, c, "syntax error in escape sequence"); } - - . \ esc { - end = tok[0] == quote; - return static_cast(tok[0]); - } - esc_hex { return unesc_hex(tok, cur); } - esc_oct { return unesc_oct(tok, cur); } - esc "a" { return static_cast('\a'); } - esc "b" { return static_cast('\b'); } - esc "f" { return static_cast('\f'); } - esc "n" { return static_cast('\n'); } - esc "r" { return static_cast('\r'); } - esc "t" { return static_cast('\t'); } - esc "v" { return static_cast('\v'); } - esc "\\" { return static_cast('\\'); } - esc (.\eof){ - if (tok[1] != quote) { - warn.useless_escape(l, c, tok[1]); - } - return static_cast(tok[1]); +/*!re2c + * { fatal_lc(l, c, "syntax error"); } + eof { fail_if_eof(); return 0; } + esc? eol { fatal_lc(l, c, "newline in character string"); } + esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } + esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); } + esc { fatal_lc(l, c, "syntax error in escape sequence"); } + + . \ esc { + end = tok[0] == quote; + return static_cast(tok[0]); + } + esc_hex { return unesc_hex(tok, cur); } + esc_oct { return unesc_oct(tok, cur); } + esc "a" { return static_cast('\a'); } + esc "b" { return static_cast('\b'); } + esc "f" { return static_cast('\f'); } + esc "n" { return static_cast('\n'); } + esc "r" { return static_cast('\r'); } + esc "t" { return static_cast('\t'); } + esc "v" { return static_cast('\v'); } + esc "\\" { return static_cast('\\'); } + esc (.\eof){ + if (tok[1] != quote) { + warn.useless_escape(l, c, tok[1]); } - */ + return static_cast(tok[1]); + } +*/ } const AST *Scanner::lex_str(char quote) -- 2.40.0