From: Ulya Trofimovich Date: Mon, 25 Jun 2018 21:42:33 +0000 (+0100) Subject: Fixed processing of #line directives in input files. X-Git-Tag: 1.1~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96aea70f17481c9b40b60f58190d86d4b391adbf;p=re2c Fixed processing of #line directives in input files. The correct behaviour was broken somewhere in between 0.16 and 1.0: re2c was forgetting to output the chunk of input file that precedes the #line directive. Reported by pskocik in #98. --- diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 83282857..33aec282 100644 --- a/re2c/bootstrap/src/ast/lex.cc +++ b/re2c/bootstrap/src/ast/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.0.3 on Sat Apr 14 21:01:06 2018 */ +/* Generated by re2c 1.0.3 on Mon Jun 25 23:10:51 2018 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include @@ -26,7 +26,7 @@ extern YYSTYPE yylval; #define YYCURSOR cur #define YYLIMIT lim #define YYMARKER mar -#define YYCTXMARKER ctx +#define YYCTXMARKER ctx #define YYFILL(n) { fill (n); } namespace re2c @@ -121,7 +121,7 @@ echo: yy4: ++YYCURSOR; yy5: -#line 153 "../src/ast/lex.re" +#line 154 "../src/ast/lex.re" { goto echo; } #line 127 "src/ast/lex.cc" yy6: @@ -132,7 +132,7 @@ yy6: } if (yych == '#') goto yy14; yy7: -#line 147 "../src/ast/lex.re" +#line 148 "../src/ast/lex.re" { cline++; pos = cur; @@ -446,10 +446,11 @@ yy73: YYCURSOR = YYCTXMARKER; #line 142 "../src/ast/lex.re" { + out.wraw(tok, ptr + 1); set_sourceline(); goto echo; } -#line 453 "src/ast/lex.cc" +#line 454 "src/ast/lex.cc" yy75: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy73; @@ -564,7 +565,7 @@ yy100: lex_end_of_comment(out); goto echo; } -#line 568 "src/ast/lex.cc" +#line 569 "src/ast/lex.cc" yy102: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'h') goto yy111; @@ -592,7 +593,7 @@ yy107: out.wraw(tok, ptr); return Reuse; } -#line 596 "src/ast/lex.cc" +#line 597 "src/ast/lex.cc" yy109: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy116; @@ -641,7 +642,7 @@ yy119: lex_tags(out, true); goto echo; } -#line 645 "src/ast/lex.cc" +#line 646 "src/ast/lex.cc" yy121: ++YYCURSOR; #line 78 "../src/ast/lex.re" @@ -649,7 +650,7 @@ yy121: out.wraw(tok, ptr); return Rules; } -#line 653 "src/ast/lex.cc" +#line 654 "src/ast/lex.cc" yy123: ++YYCURSOR; #line 124 "../src/ast/lex.re" @@ -658,7 +659,7 @@ yy123: lex_tags(out, false); goto echo; } -#line 662 "src/ast/lex.cc" +#line 663 "src/ast/lex.cc" yy125: ++YYCURSOR; #line 115 "../src/ast/lex.re" @@ -670,7 +671,7 @@ yy125: lex_end_of_comment(out); goto echo; } -#line 674 "src/ast/lex.cc" +#line 675 "src/ast/lex.cc" yy127: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy131; @@ -683,7 +684,7 @@ yy128: lex_end_of_comment(out); goto echo; } -#line 687 "src/ast/lex.cc" +#line 688 "src/ast/lex.cc" yy130: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy132; @@ -705,7 +706,7 @@ yy133: lex_end_of_comment(out); goto echo; } -#line 709 "src/ast/lex.cc" +#line 710 "src/ast/lex.cc" yy135: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy13; @@ -717,9 +718,9 @@ yy135: lex_end_of_comment(out); goto echo; } -#line 721 "src/ast/lex.cc" +#line 722 "src/ast/lex.cc" } -#line 154 "../src/ast/lex.re" +#line 155 "../src/ast/lex.re" } @@ -727,7 +728,7 @@ void Scanner::lex_end_of_comment(OutputFile &out) { uint32_t ignored = 0; for (;;) { -#line 731 "src/ast/lex.cc" +#line 732 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -743,20 +744,20 @@ void Scanner::lex_end_of_comment(OutputFile &out) } yy140: ++YYCURSOR; -#line 161 "../src/ast/lex.re" +#line 162 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "expected end of block"); } -#line 749 "src/ast/lex.cc" +#line 750 "src/ast/lex.cc" yy142: ++YYCURSOR; yy143: -#line 163 "../src/ast/lex.re" +#line 164 "../src/ast/lex.re" { continue; } -#line 755 "src/ast/lex.cc" +#line 756 "src/ast/lex.cc" yy144: ++YYCURSOR; -#line 164 "../src/ast/lex.re" +#line 165 "../src/ast/lex.re" { ++ignored; continue; } -#line 760 "src/ast/lex.cc" +#line 761 "src/ast/lex.cc" yy146: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy144; @@ -765,7 +766,7 @@ yy147: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy143; ++YYCURSOR; -#line 165 "../src/ast/lex.re" +#line 166 "../src/ast/lex.re" { if (ignored > 0) { cline += ignored; @@ -774,9 +775,9 @@ yy147: tok = pos = cur; return; } -#line 778 "src/ast/lex.cc" +#line 779 "src/ast/lex.cc" } -#line 173 "../src/ast/lex.re" +#line 174 "../src/ast/lex.re" } } @@ -784,7 +785,7 @@ void Scanner::lex_tags(OutputFile &out, bool mtags) { std::string fmt, sep; for (;;) { -#line 788 "src/ast/lex.cc" +#line 789 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -842,9 +843,9 @@ void Scanner::lex_tags(OutputFile &out, bool mtags) } ++YYCURSOR; yy153: -#line 180 "../src/ast/lex.re" +#line 181 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "unrecognized configuration"); } -#line 848 "src/ast/lex.cc" +#line 849 "src/ast/lex.cc" yy154: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -852,14 +853,14 @@ yy154: if (yybm[0+yych] & 128) { goto yy154; } -#line 185 "../src/ast/lex.re" +#line 186 "../src/ast/lex.re" { continue; } -#line 858 "src/ast/lex.cc" +#line 859 "src/ast/lex.cc" yy157: ++YYCURSOR; -#line 186 "../src/ast/lex.re" +#line 187 "../src/ast/lex.re" { ++cline; continue; } -#line 863 "src/ast/lex.cc" +#line 864 "src/ast/lex.cc" yy159: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy157; @@ -878,13 +879,13 @@ yy162: goto yy153; yy163: ++YYCURSOR; -#line 187 "../src/ast/lex.re" +#line 188 "../src/ast/lex.re" { out.wdelay_tags(new ConfTags(fmt, sep), mtags); tok = pos = cur; return; } -#line 888 "src/ast/lex.cc" +#line 889 "src/ast/lex.cc" yy165: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy168; @@ -921,9 +922,9 @@ yy173: goto yy166; yy174: ++YYCURSOR; -#line 182 "../src/ast/lex.re" +#line 183 "../src/ast/lex.re" { fmt = lex_conf_string(); continue; } -#line 927 "src/ast/lex.cc" +#line 928 "src/ast/lex.cc" yy176: yych = (YYCTYPE)*++YYCURSOR; if (yych != 't') goto yy166; @@ -932,11 +933,11 @@ yy176: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'r') goto yy166; ++YYCURSOR; -#line 183 "../src/ast/lex.re" +#line 184 "../src/ast/lex.re" { sep = lex_conf_string(); continue; } -#line 938 "src/ast/lex.cc" +#line 939 "src/ast/lex.cc" } -#line 192 "../src/ast/lex.re" +#line 193 "../src/ast/lex.re" } } @@ -947,7 +948,7 @@ scan: tchar = cur - pos; tok = cur; -#line 951 "src/ast/lex.cc" +#line 952 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1047,12 +1048,12 @@ scan: yy183: ++YYCURSOR; yy184: -#line 352 "../src/ast/lex.re" +#line 353 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); goto scan; } -#line 1056 "src/ast/lex.cc" +#line 1057 "src/ast/lex.cc" yy185: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1060,11 +1061,11 @@ yy185: if (yybm[0+yych] & 16) { goto yy185; } -#line 331 "../src/ast/lex.re" +#line 332 "../src/ast/lex.re" { goto scan; } -#line 1068 "src/ast/lex.cc" +#line 1069 "src/ast/lex.cc" yy188: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1075,7 +1076,7 @@ yy188: if (yych == '#') goto yy214; } yy189: -#line 340 "../src/ast/lex.re" +#line 341 "../src/ast/lex.re" { if (cur == eof) return 0; pos = cur; @@ -1087,7 +1088,7 @@ yy189: goto scan; } } -#line 1091 "src/ast/lex.cc" +#line 1092 "src/ast/lex.cc" yy190: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy188; @@ -1095,14 +1096,14 @@ yy190: yy191: ++YYCURSOR; yy192: -#line 244 "../src/ast/lex.re" +#line 245 "../src/ast/lex.re" { return *tok; } -#line 1101 "src/ast/lex.cc" +#line 1102 "src/ast/lex.cc" yy193: ++YYCURSOR; -#line 234 "../src/ast/lex.re" +#line 235 "../src/ast/lex.re" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; } -#line 1106 "src/ast/lex.cc" +#line 1107 "src/ast/lex.cc" yy195: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '^') { @@ -1120,21 +1121,21 @@ yy196: goto yy184; yy197: ++YYCURSOR; -#line 233 "../src/ast/lex.re" +#line 234 "../src/ast/lex.re" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; } -#line 1126 "src/ast/lex.cc" +#line 1127 "src/ast/lex.cc" yy199: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy219; goto yy192; yy200: ++YYCURSOR; -#line 326 "../src/ast/lex.re" +#line 327 "../src/ast/lex.re" { yylval.regexp = ast_dot(cline, get_column()); return TOKEN_REGEXP; } -#line 1138 "src/ast/lex.cc" +#line 1139 "src/ast/lex.cc" yy202: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy221; @@ -1177,9 +1178,9 @@ yy205: yy206: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy233; -#line 235 "../src/ast/lex.re" +#line 236 "../src/ast/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1183 "src/ast/lex.cc" +#line 1184 "src/ast/lex.cc" yy208: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy235; @@ -1202,13 +1203,13 @@ yy209: } } yy210: -#line 202 "../src/ast/lex.re" +#line 203 "../src/ast/lex.re" { depth = 1; code_line = cline; goto code; } -#line 1212 "src/ast/lex.cc" +#line 1213 "src/ast/lex.cc" yy211: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1259,51 +1260,51 @@ yy216: } } yy218: -#line 238 "../src/ast/lex.re" +#line 239 "../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] == '#'); return TOKEN_REGEXP; } -#line 1269 "src/ast/lex.cc" +#line 1270 "src/ast/lex.cc" yy219: ++YYCURSOR; -#line 228 "../src/ast/lex.re" +#line 229 "../src/ast/lex.re" { tok = cur; return 0; } -#line 1277 "src/ast/lex.cc" +#line 1278 "src/ast/lex.cc" yy221: ++YYCURSOR; -#line 222 "../src/ast/lex.re" +#line 223 "../src/ast/lex.re" { depth = 1; goto comment; } -#line 1285 "src/ast/lex.cc" +#line 1286 "src/ast/lex.cc" yy223: ++YYCURSOR; -#line 219 "../src/ast/lex.re" +#line 220 "../src/ast/lex.re" { goto nextLine; } -#line 1292 "src/ast/lex.cc" +#line 1293 "src/ast/lex.cc" yy225: yych = (YYCTYPE)*++YYCURSOR; if (yych == '>') goto yy243; -#line 212 "../src/ast/lex.re" +#line 213 "../src/ast/lex.re" { tok += 2; /* skip ":=" */ depth = 0; code_line = cline; goto code; } -#line 1303 "src/ast/lex.cc" +#line 1304 "src/ast/lex.cc" yy227: ++YYCURSOR; YYCURSOR -= 1; -#line 309 "../src/ast/lex.re" +#line 310 "../src/ast/lex.re" { if (!globopts->FFlag) { yylval.str = new std::string (tok, tok_len()); @@ -1320,7 +1321,7 @@ yy227: return TOKEN_REGEXP; } } -#line 1324 "src/ast/lex.cc" +#line 1325 "src/ast/lex.cc" yy229: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1340,17 +1341,17 @@ yy229: yy231: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 304 "../src/ast/lex.re" +#line 305 "../src/ast/lex.re" { yylval.str = new std::string (tok, tok_len ()); return TOKEN_ID; } -#line 1349 "src/ast/lex.cc" +#line 1350 "src/ast/lex.cc" yy233: ++YYCURSOR; -#line 236 "../src/ast/lex.re" +#line 237 "../src/ast/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1354 "src/ast/lex.cc" +#line 1355 "src/ast/lex.cc" yy235: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy247; @@ -1358,11 +1359,11 @@ yy235: yy236: ++YYCURSOR; yy237: -#line 277 "../src/ast/lex.re" +#line 278 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 1366 "src/ast/lex.cc" +#line 1367 "src/ast/lex.cc" yy238: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1402,15 +1403,15 @@ yy242: yy243: ++YYCURSOR; YYCURSOR -= 2; -#line 208 "../src/ast/lex.re" +#line 209 "../src/ast/lex.re" { return *tok; } -#line 1410 "src/ast/lex.cc" +#line 1411 "src/ast/lex.cc" yy245: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 291 "../src/ast/lex.re" +#line 292 "../src/ast/lex.re" { yylval.str = new std::string (tok, tok_len ()); if (globopts->FFlag) @@ -1423,7 +1424,7 @@ yy245: return TOKEN_ID; } } -#line 1427 "src/ast/lex.cc" +#line 1428 "src/ast/lex.cc" yy247: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy254; @@ -1437,7 +1438,7 @@ yy248: goto yy237; yy249: ++YYCURSOR; -#line 246 "../src/ast/lex.re" +#line 247 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { @@ -1446,10 +1447,10 @@ yy249: yylval.bounds.max = yylval.bounds.min; return TOKEN_CLOSESIZE; } -#line 1450 "src/ast/lex.cc" +#line 1451 "src/ast/lex.cc" yy251: ++YYCURSOR; -#line 281 "../src/ast/lex.re" +#line 282 "../src/ast/lex.re" { if (!globopts->FFlag) { fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch"); @@ -1457,7 +1458,7 @@ yy251: yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return TOKEN_ID; } -#line 1461 "src/ast/lex.cc" +#line 1462 "src/ast/lex.cc" yy253: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy259; @@ -1476,7 +1477,7 @@ yy255: goto yy213; yy257: ++YYCURSOR; -#line 268 "../src/ast/lex.re" +#line 269 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { @@ -1485,19 +1486,19 @@ yy257: yylval.bounds.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1489 "src/ast/lex.cc" +#line 1490 "src/ast/lex.cc" yy259: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy264; goto yy213; yy260: ++YYCURSOR; -#line 289 "../src/ast/lex.re" +#line 290 "../src/ast/lex.re" { return TOKEN_CONF; } -#line 1498 "src/ast/lex.cc" +#line 1499 "src/ast/lex.cc" yy262: ++YYCURSOR; -#line 255 "../src/ast/lex.re" +#line 256 "../src/ast/lex.re" { const char * p = strchr (tok, ','); if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) @@ -1510,7 +1511,7 @@ yy262: } return TOKEN_CLOSESIZE; } -#line 1514 "src/ast/lex.cc" +#line 1515 "src/ast/lex.cc" yy264: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy266; @@ -1566,12 +1567,12 @@ yy269: yy271: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 335 "../src/ast/lex.re" +#line 336 "../src/ast/lex.re" { set_sourceline (); return TOKEN_LINE_INFO; } -#line 1575 "src/ast/lex.cc" +#line 1576 "src/ast/lex.cc" yy273: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy271; @@ -1596,12 +1597,12 @@ yy277: if (yych == '\n') goto yy213; goto yy274; } -#line 356 "../src/ast/lex.re" +#line 357 "../src/ast/lex.re" code: -#line 1605 "src/ast/lex.cc" +#line 1606 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1662,7 +1663,7 @@ code: } yy280: ++YYCURSOR; -#line 419 "../src/ast/lex.re" +#line 420 "../src/ast/lex.re" { if (cur == eof) { @@ -1674,15 +1675,15 @@ yy280: } goto code; } -#line 1678 "src/ast/lex.cc" +#line 1679 "src/ast/lex.cc" yy282: ++YYCURSOR; yy283: -#line 433 "../src/ast/lex.re" +#line 434 "../src/ast/lex.re" { goto code; } -#line 1686 "src/ast/lex.cc" +#line 1687 "src/ast/lex.cc" yy284: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1701,7 +1702,7 @@ yy284: } } yy285: -#line 400 "../src/ast/lex.re" +#line 401 "../src/ast/lex.re" { if (depth == 0) { @@ -1721,7 +1722,7 @@ yy285: cline++; goto code; } -#line 1725 "src/ast/lex.cc" +#line 1726 "src/ast/lex.cc" yy286: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1734,7 +1735,7 @@ yy287: goto yy304; yy288: ++YYCURSOR; -#line 372 "../src/ast/lex.re" +#line 373 "../src/ast/lex.re" { if (depth == 0) { @@ -1746,10 +1747,10 @@ yy288: } goto code; } -#line 1750 "src/ast/lex.cc" +#line 1751 "src/ast/lex.cc" yy290: ++YYCURSOR; -#line 360 "../src/ast/lex.re" +#line 361 "../src/ast/lex.re" { if (depth == 0) { @@ -1762,7 +1763,7 @@ yy290: } goto code; } -#line 1766 "src/ast/lex.cc" +#line 1767 "src/ast/lex.cc" yy292: yyaccept = 2; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1774,7 +1775,7 @@ yy292: } yy293: YYCURSOR -= 1; -#line 387 "../src/ast/lex.re" +#line 388 "../src/ast/lex.re" { if (depth == 0) { @@ -1788,7 +1789,7 @@ yy293: cline++; goto code; } -#line 1792 "src/ast/lex.cc" +#line 1793 "src/ast/lex.cc" yy294: ++YYCURSOR; goto yy293; @@ -1823,11 +1824,11 @@ yy299: if (yych >= '#') goto yy302; yy300: ++YYCURSOR; -#line 430 "../src/ast/lex.re" +#line 431 "../src/ast/lex.re" { goto code; } -#line 1831 "src/ast/lex.cc" +#line 1832 "src/ast/lex.cc" yy302: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1917,12 +1918,12 @@ yy316: yy318: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 383 "../src/ast/lex.re" +#line 384 "../src/ast/lex.re" { set_sourceline (); goto code; } -#line 1926 "src/ast/lex.cc" +#line 1927 "src/ast/lex.cc" yy320: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy318; @@ -1951,12 +1952,12 @@ yy324: if (yych == '\n') goto yy297; goto yy321; } -#line 436 "../src/ast/lex.re" +#line 437 "../src/ast/lex.re" comment: -#line 1960 "src/ast/lex.cc" +#line 1961 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2003,7 +2004,7 @@ comment: } ++YYCURSOR; yy328: -#line 468 "../src/ast/lex.re" +#line 469 "../src/ast/lex.re" { if (cur == eof) { @@ -2011,7 +2012,7 @@ yy328: } goto comment; } -#line 2015 "src/ast/lex.cc" +#line 2016 "src/ast/lex.cc" yy329: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -2019,7 +2020,7 @@ yy329: } if (yych == '#') goto yy336; yy330: -#line 459 "../src/ast/lex.re" +#line 460 "../src/ast/lex.re" { if (cur == eof) { @@ -2029,7 +2030,7 @@ yy330: cline++; goto comment; } -#line 2033 "src/ast/lex.cc" +#line 2034 "src/ast/lex.cc" yy331: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy338; @@ -2063,7 +2064,7 @@ yy336: } yy338: ++YYCURSOR; -#line 440 "../src/ast/lex.re" +#line 441 "../src/ast/lex.re" { if (--depth == 0) { @@ -2074,16 +2075,16 @@ yy338: goto comment; } } -#line 2078 "src/ast/lex.cc" +#line 2079 "src/ast/lex.cc" yy340: ++YYCURSOR; -#line 450 "../src/ast/lex.re" +#line 451 "../src/ast/lex.re" { ++depth; fatal_lc(get_cline(), get_column(), "ambiguous /* found"); goto comment; } -#line 2087 "src/ast/lex.cc" +#line 2088 "src/ast/lex.cc" yy342: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'i') goto yy335; @@ -2140,12 +2141,12 @@ yy350: yy352: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 455 "../src/ast/lex.re" +#line 456 "../src/ast/lex.re" { set_sourceline (); goto comment; } -#line 2149 "src/ast/lex.cc" +#line 2150 "src/ast/lex.cc" yy354: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy352; @@ -2170,28 +2171,28 @@ yy358: if (yych == '\n') goto yy335; goto yy355; } -#line 475 "../src/ast/lex.re" +#line 476 "../src/ast/lex.re" nextLine: -#line 2179 "src/ast/lex.cc" +#line 2180 "src/ast/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\n') goto yy363; ++YYCURSOR; -#line 486 "../src/ast/lex.re" +#line 487 "../src/ast/lex.re" { if(cur == eof) { return 0; } goto nextLine; } -#line 2192 "src/ast/lex.cc" +#line 2193 "src/ast/lex.cc" yy363: ++YYCURSOR; -#line 479 "../src/ast/lex.re" +#line 480 "../src/ast/lex.re" { if(cur == eof) { return 0; } @@ -2199,9 +2200,9 @@ yy363: cline++; goto scan; } -#line 2203 "src/ast/lex.cc" +#line 2204 "src/ast/lex.cc" } -#line 491 "../src/ast/lex.re" +#line 492 "../src/ast/lex.re" } @@ -2213,35 +2214,35 @@ fst: tok = cur; c = get_column(); -#line 2217 "src/ast/lex.cc" +#line 2218 "src/ast/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy368; -#line 503 "../src/ast/lex.re" +#line 504 "../src/ast/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2225 "src/ast/lex.cc" +#line 2226 "src/ast/lex.cc" yy368: ++YYCURSOR; -#line 502 "../src/ast/lex.re" +#line 503 "../src/ast/lex.re" { return ast_cls(cline, c0, cls, neg); } -#line 2230 "src/ast/lex.cc" +#line 2231 "src/ast/lex.cc" } -#line 504 "../src/ast/lex.re" +#line 505 "../src/ast/lex.re" snd: -#line 2236 "src/ast/lex.cc" +#line 2237 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy373; yy372: -#line 507 "../src/ast/lex.re" +#line 508 "../src/ast/lex.re" { u = l; goto add; } -#line 2245 "src/ast/lex.cc" +#line 2246 "src/ast/lex.cc" yy373: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy375; @@ -2250,7 +2251,7 @@ yy373: yy375: ++YYCURSOR; YYCURSOR -= 1; -#line 508 "../src/ast/lex.re" +#line 509 "../src/ast/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2259,9 +2260,9 @@ yy375: } goto add; } -#line 2263 "src/ast/lex.cc" +#line 2264 "src/ast/lex.cc" } -#line 516 "../src/ast/lex.re" +#line 517 "../src/ast/lex.re" add: cls->push_back(ASTRange(l, u, c)); @@ -2273,7 +2274,7 @@ uint32_t Scanner::lex_cls_chr() tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2277 "src/ast/lex.cc" +#line 2278 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2287,14 +2288,14 @@ uint32_t Scanner::lex_cls_chr() } ++YYCURSOR; yy380: -#line 533 "../src/ast/lex.re" +#line 534 "../src/ast/lex.re" { return static_cast(tok[0]); } -#line 2293 "src/ast/lex.cc" +#line 2294 "src/ast/lex.cc" yy381: ++YYCURSOR; -#line 528 "../src/ast/lex.re" +#line 529 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character class"); } -#line 2298 "src/ast/lex.cc" +#line 2299 "src/ast/lex.cc" yy383: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy381; @@ -2346,30 +2347,30 @@ yy384: yy385: ++YYCURSOR; yy386: -#line 546 "../src/ast/lex.re" +#line 547 "../src/ast/lex.re" { warn.useless_escape(cline, get_column(), tok[1]); return static_cast(tok[1]); } -#line 2355 "src/ast/lex.cc" +#line 2356 "src/ast/lex.cc" yy387: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy381; goto yy386; yy388: ++YYCURSOR; -#line 544 "../src/ast/lex.re" +#line 545 "../src/ast/lex.re" { return static_cast('-'); } -#line 2364 "src/ast/lex.cc" +#line 2365 "src/ast/lex.cc" yy390: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy391; if (yych <= '7') goto yy415; yy391: -#line 530 "../src/ast/lex.re" +#line 531 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2373 "src/ast/lex.cc" +#line 2374 "src/ast/lex.cc" yy392: ++YYCURSOR; goto yy391; @@ -2385,9 +2386,9 @@ yy393: if (yych <= 'f') goto yy417; } yy394: -#line 529 "../src/ast/lex.re" +#line 530 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2391 "src/ast/lex.cc" +#line 2392 "src/ast/lex.cc" yy395: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2403,49 +2404,49 @@ yy395: } yy396: ++YYCURSOR; -#line 543 "../src/ast/lex.re" +#line 544 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2409 "src/ast/lex.cc" +#line 2410 "src/ast/lex.cc" yy398: ++YYCURSOR; -#line 545 "../src/ast/lex.re" +#line 546 "../src/ast/lex.re" { return static_cast(']'); } -#line 2414 "src/ast/lex.cc" +#line 2415 "src/ast/lex.cc" yy400: ++YYCURSOR; -#line 536 "../src/ast/lex.re" +#line 537 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2419 "src/ast/lex.cc" +#line 2420 "src/ast/lex.cc" yy402: ++YYCURSOR; -#line 537 "../src/ast/lex.re" +#line 538 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2424 "src/ast/lex.cc" +#line 2425 "src/ast/lex.cc" yy404: ++YYCURSOR; -#line 538 "../src/ast/lex.re" +#line 539 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2429 "src/ast/lex.cc" +#line 2430 "src/ast/lex.cc" yy406: ++YYCURSOR; -#line 539 "../src/ast/lex.re" +#line 540 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2434 "src/ast/lex.cc" +#line 2435 "src/ast/lex.cc" yy408: ++YYCURSOR; -#line 540 "../src/ast/lex.re" +#line 541 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2439 "src/ast/lex.cc" +#line 2440 "src/ast/lex.cc" yy410: ++YYCURSOR; -#line 541 "../src/ast/lex.re" +#line 542 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2444 "src/ast/lex.cc" +#line 2445 "src/ast/lex.cc" yy412: ++YYCURSOR; -#line 542 "../src/ast/lex.re" +#line 543 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2449 "src/ast/lex.cc" +#line 2450 "src/ast/lex.cc" yy414: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2508,9 +2509,9 @@ yy419: } yy420: ++YYCURSOR; -#line 535 "../src/ast/lex.re" +#line 536 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2514 "src/ast/lex.cc" +#line 2515 "src/ast/lex.cc" yy422: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2537,9 +2538,9 @@ yy423: } yy424: ++YYCURSOR; -#line 534 "../src/ast/lex.re" +#line 535 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2543 "src/ast/lex.cc" +#line 2544 "src/ast/lex.cc" yy426: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2563,7 +2564,7 @@ yy427: goto yy416; } } -#line 550 "../src/ast/lex.re" +#line 551 "../src/ast/lex.re" } @@ -2573,7 +2574,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2577 "src/ast/lex.cc" +#line 2578 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2587,17 +2588,17 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) } ++YYCURSOR; yy431: -#line 565 "../src/ast/lex.re" +#line 566 "../src/ast/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2596 "src/ast/lex.cc" +#line 2597 "src/ast/lex.cc" yy432: ++YYCURSOR; -#line 560 "../src/ast/lex.re" +#line 561 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character string"); } -#line 2601 "src/ast/lex.cc" +#line 2602 "src/ast/lex.cc" yy434: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy432; @@ -2646,14 +2647,14 @@ yy435: yy436: ++YYCURSOR; yy437: -#line 579 "../src/ast/lex.re" +#line 580 "../src/ast/lex.re" { if (tok[1] != quote) { warn.useless_escape(cline, get_column(), tok[1]); } return static_cast(tok[1]); } -#line 2657 "src/ast/lex.cc" +#line 2658 "src/ast/lex.cc" yy438: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy432; @@ -2664,9 +2665,9 @@ yy439: if (yych <= '/') goto yy440; if (yych <= '7') goto yy462; yy440: -#line 562 "../src/ast/lex.re" +#line 563 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2670 "src/ast/lex.cc" +#line 2671 "src/ast/lex.cc" yy441: ++YYCURSOR; goto yy440; @@ -2682,9 +2683,9 @@ yy442: if (yych <= 'f') goto yy464; } yy443: -#line 561 "../src/ast/lex.re" +#line 562 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2688 "src/ast/lex.cc" +#line 2689 "src/ast/lex.cc" yy444: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2700,44 +2701,44 @@ yy444: } yy445: ++YYCURSOR; -#line 578 "../src/ast/lex.re" +#line 579 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2706 "src/ast/lex.cc" +#line 2707 "src/ast/lex.cc" yy447: ++YYCURSOR; -#line 571 "../src/ast/lex.re" +#line 572 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2711 "src/ast/lex.cc" +#line 2712 "src/ast/lex.cc" yy449: ++YYCURSOR; -#line 572 "../src/ast/lex.re" +#line 573 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2716 "src/ast/lex.cc" +#line 2717 "src/ast/lex.cc" yy451: ++YYCURSOR; -#line 573 "../src/ast/lex.re" +#line 574 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2721 "src/ast/lex.cc" +#line 2722 "src/ast/lex.cc" yy453: ++YYCURSOR; -#line 574 "../src/ast/lex.re" +#line 575 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2726 "src/ast/lex.cc" +#line 2727 "src/ast/lex.cc" yy455: ++YYCURSOR; -#line 575 "../src/ast/lex.re" +#line 576 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2731 "src/ast/lex.cc" +#line 2732 "src/ast/lex.cc" yy457: ++YYCURSOR; -#line 576 "../src/ast/lex.re" +#line 577 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2736 "src/ast/lex.cc" +#line 2737 "src/ast/lex.cc" yy459: ++YYCURSOR; -#line 577 "../src/ast/lex.re" +#line 578 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2741 "src/ast/lex.cc" +#line 2742 "src/ast/lex.cc" yy461: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2800,9 +2801,9 @@ yy466: } yy467: ++YYCURSOR; -#line 570 "../src/ast/lex.re" +#line 571 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2806 "src/ast/lex.cc" +#line 2807 "src/ast/lex.cc" yy469: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2829,9 +2830,9 @@ yy470: } yy471: ++YYCURSOR; -#line 569 "../src/ast/lex.re" +#line 570 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2835 "src/ast/lex.cc" +#line 2836 "src/ast/lex.cc" yy473: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2855,7 +2856,7 @@ yy474: goto yy463; } } -#line 585 "../src/ast/lex.re" +#line 586 "../src/ast/lex.re" } @@ -2875,7 +2876,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2879 "src/ast/lex.cc" +#line 2880 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2914,82 +2915,100 @@ sourceline: }; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; - if (yych <= '!') { - if (yych == '\n') goto yy479; + if (yych <= '\r') { + if (yych <= '\t') { + if (yych >= 0x01) goto yy479; + } else { + if (yych <= '\n') goto yy481; + if (yych <= '\f') goto yy479; + goto yy483; + } } else { - if (yych <= '"') goto yy481; - if (yych <= '0') goto yy477; - if (yych <= '9') goto yy482; + if (yych <= '"') { + if (yych <= '!') goto yy479; + goto yy484; + } else { + if (yych <= '0') goto yy479; + if (yych <= '9') goto yy485; + goto yy479; + } } -yy477: ++YYCURSOR; -yy478: -#line 627 "../src/ast/lex.re" - { goto sourceline; } -#line 2930 "src/ast/lex.cc" +#line 623 "../src/ast/lex.re" + { + --cur; + tok = cur; + return; + } +#line 2944 "src/ast/lex.cc" yy479: ++YYCURSOR; -#line 617 "../src/ast/lex.re" +yy480: +#line 629 "../src/ast/lex.re" + { goto sourceline; } +#line 2950 "src/ast/lex.cc" +yy481: + ++YYCURSOR; +#line 618 "../src/ast/lex.re" { - if (cur == eof) { - --cur; - } else { - pos = cur; - } tok = cur; return; } -#line 2943 "src/ast/lex.cc" -yy481: +#line 2958 "src/ast/lex.cc" +yy483: + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '\n') goto yy481; + goto yy480; +yy484: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy478; - goto yy486; -yy482: + if (yych == '\n') goto yy480; + goto yy489; +yy485: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yybm[0+yych] & 64) { - goto yy482; + goto yy485; } -#line 604 "../src/ast/lex.re" +#line 605 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { fatal_lc(get_cline(), get_column(), "line number overflow"); } goto sourceline; } -#line 2962 "src/ast/lex.cc" -yy485: +#line 2981 "src/ast/lex.cc" +yy488: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy486: +yy489: if (yybm[0+yych] & 128) { - goto yy485; + goto yy488; } - if (yych <= '\n') goto yy487; - if (yych <= '"') goto yy488; - goto yy490; -yy487: + if (yych <= '\n') goto yy490; + if (yych <= '"') goto yy491; + goto yy493; +yy490: YYCURSOR = YYMARKER; - goto yy478; -yy488: + goto yy480; +yy491: ++YYCURSOR; -#line 611 "../src/ast/lex.re" +#line 612 "../src/ast/lex.re" { - in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // -2 to omit quotes + in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes strrreplace (in.escaped_file_name, "\\", "\\\\"); goto sourceline; } -#line 2985 "src/ast/lex.cc" -yy490: +#line 3004 "src/ast/lex.cc" +yy493: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy487; - goto yy485; + if (yych == '\n') goto yy490; + goto yy488; } -#line 628 "../src/ast/lex.re" +#line 630 "../src/ast/lex.re" } diff --git a/re2c/src/ast/lex.re b/re2c/src/ast/lex.re index bb8d6650..1e09274e 100644 --- a/re2c/src/ast/lex.re +++ b/re2c/src/ast/lex.re @@ -24,7 +24,7 @@ extern YYSTYPE yylval; #define YYCURSOR cur #define YYLIMIT lim #define YYMARKER mar -#define YYCTXMARKER ctx +#define YYCTXMARKER ctx #define YYFILL(n) { fill (n); } namespace re2c @@ -38,7 +38,7 @@ namespace re2c */ /*!re2c -zero = "\000"; +eof = "\000"; dstring = "\"" ((. \ [\\"] ) | "\\" .)* "\""; sstring = "'" ((. \ [\\'] ) | "\\" .)* "'" ; letter = [a-zA-Z]; @@ -133,13 +133,14 @@ echo: goto echo; } - zero { + eof { if (cur != eof) goto echo; out.wraw(tok, ptr); return Stop; } eol space* "#" space* "line" space+ / lineinf { + out.wraw(tok, ptr + 1); set_sourceline(); goto echo; } @@ -158,7 +159,7 @@ void Scanner::lex_end_of_comment(OutputFile &out) { uint32_t ignored = 0; for (;;) {/*!re2c - zero { fatal_lc(get_cline(), get_column(), "expected end of block"); } + eof { fatal_lc(get_cline(), get_column(), "expected end of block"); } * { continue; } eol { ++ignored; continue; } @@ -416,7 +417,7 @@ code: cline++; goto code; } - zero { + eof { if (cur == eof) { if (depth) @@ -609,17 +610,18 @@ sourceline: } dstring { - in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // -2 to omit quotes + in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes strrreplace (in.escaped_file_name, "\\", "\\\\"); goto sourceline; } - "\n" { - if (cur == eof) { - --cur; - } else { - pos = cur; - } + eol { + tok = cur; + return; + } + + eof { + --cur; tok = cur; return; } diff --git a/re2c/test/line-02.c b/re2c/test/line-02.c new file mode 100644 index 00000000..a5e1095b --- /dev/null +++ b/re2c/test/line-02.c @@ -0,0 +1,160 @@ +/* Generated by re2c */ +#line 1 "line-02.re" +/* Generated by re2c 0.16 on Mon Jun 25 20:07:34 2018 */ +typedef enum num_t { ERR, BIN, OCT, DEC, HEX } num_t; +static num_t lex(const char *YYCURSOR) +{ + const char *YYMARKER; + +{ + char yych; + yych = *YYCURSOR; + switch (yych) { + case '0': goto yy4; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy5; + default: goto yy2; + } +yy2: + ++YYCURSOR; +yy3: + { return ERR; } +yy4: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 0x00: goto yy6; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': goto yy8; + case 'B': + case 'b': goto yy11; + case 'X': + case 'x': goto yy12; + default: goto yy3; + } +yy5: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 0x00: goto yy13; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy15; + default: goto yy3; + } +yy6: + ++YYCURSOR; + { return OCT; } +yy8: + ++YYCURSOR; + yych = *YYCURSOR; + switch (yych) { + case 0x00: goto yy6; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': goto yy8; + default: goto yy10; + } +yy10: + YYCURSOR = YYMARKER; + goto yy3; +yy11: + yych = *++YYCURSOR; + if (yych <= 0x00) goto yy10; + goto yy18; +yy12: + yych = *++YYCURSOR; + if (yych <= 0x00) goto yy10; + goto yy20; +yy13: + ++YYCURSOR; + { return DEC; } +yy15: + ++YYCURSOR; + yych = *YYCURSOR; + switch (yych) { + case 0x00: goto yy13; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy15; + default: goto yy10; + } +yy17: + ++YYCURSOR; + yych = *YYCURSOR; +yy18: + switch (yych) { + case 0x00: goto yy21; + case '0': + case '1': goto yy17; + default: goto yy10; + } +yy19: + ++YYCURSOR; + yych = *YYCURSOR; +yy20: + switch (yych) { + case 0x00: goto yy23; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': goto yy19; + default: goto yy10; + } +yy21: + ++YYCURSOR; + { return BIN; } +yy23: + ++YYCURSOR; + { return HEX; } +} + +} diff --git a/re2c/test/line-02.re b/re2c/test/line-02.re new file mode 100644 index 00000000..f6d408f9 --- /dev/null +++ b/re2c/test/line-02.re @@ -0,0 +1,171 @@ +/* Generated by re2c 0.16 on Mon Jun 25 20:07:34 2018 */ +#line 1 "test.re" +typedef enum num_t { ERR, BIN, OCT, DEC, HEX } num_t; +static num_t lex(const char *YYCURSOR) +{ + const char *YYMARKER; + +#line 9 "test.c" +{ + char yych; + yych = *YYCURSOR; + switch (yych) { + case '0': goto yy4; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy5; + default: goto yy2; + } +yy2: + ++YYCURSOR; +yy3: +#line 15 "test.re" + { return ERR; } +#line 31 "test.c" +yy4: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 0x00: goto yy6; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': goto yy8; + case 'B': + case 'b': goto yy11; + case 'X': + case 'x': goto yy12; + default: goto yy3; + } +yy5: + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 0x00: goto yy13; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy15; + default: goto yy3; + } +yy6: + ++YYCURSOR; +#line 17 "test.re" + { return OCT; } +#line 70 "test.c" +yy8: + ++YYCURSOR; + yych = *YYCURSOR; + switch (yych) { + case 0x00: goto yy6; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': goto yy8; + default: goto yy10; + } +yy10: + YYCURSOR = YYMARKER; + goto yy3; +yy11: + yych = *++YYCURSOR; + if (yych <= 0x00) goto yy10; + goto yy18; +yy12: + yych = *++YYCURSOR; + if (yych <= 0x00) goto yy10; + goto yy20; +yy13: + ++YYCURSOR; +#line 18 "test.re" + { return DEC; } +#line 101 "test.c" +yy15: + ++YYCURSOR; + yych = *YYCURSOR; + switch (yych) { + case 0x00: goto yy13; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy15; + default: goto yy10; + } +yy17: + ++YYCURSOR; + yych = *YYCURSOR; +yy18: + switch (yych) { + case 0x00: goto yy21; + case '0': + case '1': goto yy17; + default: goto yy10; + } +yy19: + ++YYCURSOR; + yych = *YYCURSOR; +yy20: + switch (yych) { + case 0x00: goto yy23; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': goto yy19; + default: goto yy10; + } +yy21: + ++YYCURSOR; +#line 16 "test.re" + { return BIN; } +#line 163 "test.c" +yy23: + ++YYCURSOR; +#line 19 "test.re" + { return HEX; } +#line 168 "test.c" +} +#line 20 "test.re" + +}