From: Ulya Trofimovich Date: Thu, 17 Jan 2019 22:52:04 +0000 (+0000) Subject: Fixed operator precedence with --flex-syntax option. X-Git-Tag: 1.2~214 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4dea13a1c7a467908e5bf452803e5f5cc17bbf08;p=re2c Fixed operator precedence with --flex-syntax option. Operator precedence was broken because re2c tried to parse whole strings of characters at once instead of parsing one character at a time (in much the same way as it would parse properly quotes string literals in the original re2c format). This caused ab* being parsed as (ab)*, which is clearly wrong (should be a(b)*). This fixes bug #242: "Operator precedence with --flex-syntax is broken." --- diff --git a/re2c/bootstrap/src/parse/lex.cc b/re2c/bootstrap/src/parse/lex.cc index 19c3415c..f4bda69f 100644 --- a/re2c/bootstrap/src/parse/lex.cc +++ b/re2c/bootstrap/src/parse/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Thu Jan 10 23:17:36 2019 */ +/* Generated by re2c 1.1.1 on Thu Jan 17 22:27:03 2019 */ #line 1 "../src/parse/lex.re" #include "src/util/c99_stdint.h" #include @@ -1276,7 +1276,7 @@ scan: yy223: ++YYCURSOR; yy224: -#line 403 "../src/parse/lex.re" +#line 402 "../src/parse/lex.re" { fatal_lc(get_line(), get_column(), "unexpected character: '%c'", *tok); goto scan; @@ -1289,7 +1289,7 @@ yy225: if (yybm[0+yych] & 16) { goto yy225; } -#line 385 "../src/parse/lex.re" +#line 384 "../src/parse/lex.re" { goto scan; } #line 1295 "src/parse/lex.cc" yy228: @@ -1302,7 +1302,7 @@ yy228: if (yych == '#') goto yy258; } yy229: -#line 392 "../src/parse/lex.re" +#line 391 "../src/parse/lex.re" { next_line(); if (lexer_state == LEX_FLEX_NAME) { @@ -1355,7 +1355,7 @@ yy239: goto yy235; yy240: ++YYCURSOR; -#line 380 "../src/parse/lex.re" +#line 379 "../src/parse/lex.re" { yylval.regexp = ast_dot(get_line(), get_column()); return TOKEN_REGEXP; @@ -1400,24 +1400,23 @@ yy248: return TOKEN_FID; } else { + // consume one character, otherwise we risk breaking operator + // precedence in cases like ab*: it should be a(b)*, not (ab)* + cur = tok + 1; + std::vector *str = new std::vector; - for (const char *s = tok; s < cur; ++s) { - const uint32_t - chr = static_cast(*s), - col = static_cast(s - tok); - str->push_back(ASTChar(chr, col)); - } + str->push_back(ASTChar(static_cast(tok[0]), 0)); yylval.regexp = ast_str(get_line(), get_column(), str, false); return TOKEN_REGEXP; } } -#line 1415 "src/parse/lex.cc" +#line 1414 "src/parse/lex.cc" yy250: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy273; #line 304 "../src/parse/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1421 "src/parse/lex.cc" +#line 1420 "src/parse/lex.cc" yy252: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy275; @@ -1442,7 +1441,7 @@ yy253: yy254: #line 287 "../src/parse/lex.re" { lex_code_in_braces(); return TOKEN_CODE; } -#line 1446 "src/parse/lex.cc" +#line 1445 "src/parse/lex.cc" yy255: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1507,22 +1506,22 @@ yy262: , newstr(tok + 1, cur), tok[0] == '#'); return TOKEN_REGEXP; } -#line 1511 "src/parse/lex.cc" +#line 1510 "src/parse/lex.cc" yy263: ++YYCURSOR; #line 300 "../src/parse/lex.re" { tok = cur; return 0; } -#line 1516 "src/parse/lex.cc" +#line 1515 "src/parse/lex.cc" yy265: ++YYCURSOR; #line 298 "../src/parse/lex.re" { lex_c_comment(); goto scan; } -#line 1521 "src/parse/lex.cc" +#line 1520 "src/parse/lex.cc" yy267: ++YYCURSOR; #line 297 "../src/parse/lex.re" { lex_cpp_comment(); goto scan; } -#line 1526 "src/parse/lex.cc" +#line 1525 "src/parse/lex.cc" yy269: yyaccept = 3; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1530,7 +1529,7 @@ yy269: yy270: #line 288 "../src/parse/lex.re" { lex_code_indented(); return TOKEN_CODE; } -#line 1534 "src/parse/lex.cc" +#line 1533 "src/parse/lex.cc" yy271: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1565,7 +1564,7 @@ yy273: ++YYCURSOR; #line 305 "../src/parse/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1569 "src/parse/lex.cc" +#line 1568 "src/parse/lex.cc" yy275: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy286; @@ -1578,7 +1577,7 @@ yy277: fatal_lc(get_line(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 1582 "src/parse/lex.cc" +#line 1581 "src/parse/lex.cc" yy278: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1641,7 +1640,7 @@ yy285: yylval.str = newstr(p, cur); return tok[0] == ':' ? TOKEN_CJUMP : TOKEN_CNEXT; } -#line 1645 "src/parse/lex.cc" +#line 1644 "src/parse/lex.cc" yy286: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy293; @@ -1663,7 +1662,7 @@ yy288: yylval.bounds.max = yylval.bounds.min; return TOKEN_CLOSESIZE; } -#line 1667 "src/parse/lex.cc" +#line 1666 "src/parse/lex.cc" yy290: ++YYCURSOR; #line 346 "../src/parse/lex.re" @@ -1675,7 +1674,7 @@ yy290: yylval.str = newstr(tok + 1, cur - 1); return TOKEN_ID; } -#line 1679 "src/parse/lex.cc" +#line 1678 "src/parse/lex.cc" yy292: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy298; @@ -1702,7 +1701,7 @@ yy296: yylval.bounds.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1706 "src/parse/lex.cc" +#line 1705 "src/parse/lex.cc" yy298: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy303; @@ -1711,7 +1710,7 @@ yy299: ++YYCURSOR; #line 355 "../src/parse/lex.re" { return TOKEN_CONF; } -#line 1715 "src/parse/lex.cc" +#line 1714 "src/parse/lex.cc" yy301: ++YYCURSOR; p = yyt1; @@ -1725,7 +1724,7 @@ yy301: } return TOKEN_CLOSESIZE; } -#line 1729 "src/parse/lex.cc" +#line 1728 "src/parse/lex.cc" yy303: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy305; @@ -1781,12 +1780,12 @@ yy308: yy310: ++YYCURSOR; YYCURSOR = yyt1; -#line 387 "../src/parse/lex.re" +#line 386 "../src/parse/lex.re" { set_sourceline (); return TOKEN_LINE_INFO; } -#line 1790 "src/parse/lex.cc" +#line 1789 "src/parse/lex.cc" yy312: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy310; @@ -1812,14 +1811,14 @@ yy316: if (yych == '\n') goto yy257; goto yy313; } -#line 407 "../src/parse/lex.re" +#line 406 "../src/parse/lex.re" } bool Scanner::lex_namedef_context_re2c() { -#line 1823 "src/parse/lex.cc" +#line 1822 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1874,9 +1873,9 @@ bool Scanner::lex_namedef_context_re2c() } } yy319: -#line 414 "../src/parse/lex.re" +#line 413 "../src/parse/lex.re" { return false; } -#line 1880 "src/parse/lex.cc" +#line 1879 "src/parse/lex.cc" yy320: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1893,18 +1892,18 @@ yy323: if (yych == '>') goto yy322; ++YYCURSOR; YYCURSOR = yyt1; -#line 413 "../src/parse/lex.re" +#line 412 "../src/parse/lex.re" { return true; } -#line 1899 "src/parse/lex.cc" +#line 1898 "src/parse/lex.cc" } -#line 415 "../src/parse/lex.re" +#line 414 "../src/parse/lex.re" } bool Scanner::lex_namedef_context_flex() { -#line 1908 "src/parse/lex.cc" +#line 1907 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1951,9 +1950,9 @@ bool Scanner::lex_namedef_context_flex() yyt1 = YYCURSOR; goto yy329; } -#line 423 "../src/parse/lex.re" +#line 422 "../src/parse/lex.re" { return false; } -#line 1957 "src/parse/lex.cc" +#line 1956 "src/parse/lex.cc" yy329: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1968,17 +1967,17 @@ yy329: if (yych == '{') goto yy332; } YYCURSOR = yyt1; -#line 422 "../src/parse/lex.re" +#line 421 "../src/parse/lex.re" { return true; } -#line 1974 "src/parse/lex.cc" +#line 1973 "src/parse/lex.cc" yy332: ++YYCURSOR; YYCURSOR = yyt1; -#line 421 "../src/parse/lex.re" +#line 420 "../src/parse/lex.re" { return false; } -#line 1980 "src/parse/lex.cc" +#line 1979 "src/parse/lex.cc" } -#line 424 "../src/parse/lex.re" +#line 423 "../src/parse/lex.re" } @@ -1987,7 +1986,7 @@ int Scanner::lex_clist() int kind = TOKEN_CLIST; CondList *cl = new CondList; -#line 1991 "src/parse/lex.cc" +#line 1990 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2037,30 +2036,30 @@ yy334: if (yych <= '!') goto yy338; if (yych == '>') goto yy341; yy337: -#line 434 "../src/parse/lex.re" +#line 433 "../src/parse/lex.re" { goto cond; } -#line 2043 "src/parse/lex.cc" +#line 2042 "src/parse/lex.cc" yy338: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\t') goto yy338; if (yych == ' ') goto yy338; -#line 432 "../src/parse/lex.re" +#line 431 "../src/parse/lex.re" { kind = TOKEN_CSETUP; goto cond; } -#line 2052 "src/parse/lex.cc" +#line 2051 "src/parse/lex.cc" yy341: ++YYCURSOR; -#line 433 "../src/parse/lex.re" +#line 432 "../src/parse/lex.re" { kind = TOKEN_CZERO; goto end; } -#line 2057 "src/parse/lex.cc" +#line 2056 "src/parse/lex.cc" } -#line 435 "../src/parse/lex.re" +#line 434 "../src/parse/lex.re" cond: tok = cur; -#line 2064 "src/parse/lex.cc" +#line 2063 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2112,14 +2111,14 @@ cond: } yy345: ++YYCURSOR; -#line 441 "../src/parse/lex.re" +#line 440 "../src/parse/lex.re" { goto error; } -#line 2118 "src/parse/lex.cc" +#line 2117 "src/parse/lex.cc" yy347: ++YYCURSOR; -#line 440 "../src/parse/lex.re" +#line 439 "../src/parse/lex.re" { if (!cl->empty()) goto error; cl->insert("*"); goto next; } -#line 2123 "src/parse/lex.cc" +#line 2122 "src/parse/lex.cc" yy349: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2127,15 +2126,15 @@ yy349: if (yybm[0+yych] & 128) { goto yy349; } -#line 439 "../src/parse/lex.re" +#line 438 "../src/parse/lex.re" { cl->insert(getstr(tok, cur)); goto next; } -#line 2133 "src/parse/lex.cc" +#line 2132 "src/parse/lex.cc" } -#line 442 "../src/parse/lex.re" +#line 441 "../src/parse/lex.re" next: -#line 2139 "src/parse/lex.cc" +#line 2138 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2186,9 +2185,9 @@ next: } ++YYCURSOR; yy355: -#line 447 "../src/parse/lex.re" +#line 446 "../src/parse/lex.re" { goto error; } -#line 2192 "src/parse/lex.cc" +#line 2191 "src/parse/lex.cc" yy356: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= ' ') { @@ -2210,14 +2209,14 @@ yy357: if (yybm[0+yych] & 128) { goto yy357; } -#line 445 "../src/parse/lex.re" +#line 444 "../src/parse/lex.re" { goto cond; } -#line 2216 "src/parse/lex.cc" +#line 2215 "src/parse/lex.cc" yy360: ++YYCURSOR; -#line 446 "../src/parse/lex.re" +#line 445 "../src/parse/lex.re" { goto end; } -#line 2221 "src/parse/lex.cc" +#line 2220 "src/parse/lex.cc" yy362: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2235,7 +2234,7 @@ yy362: YYCURSOR = YYMARKER; goto yy355; } -#line 448 "../src/parse/lex.re" +#line 447 "../src/parse/lex.re" end: yylval.clist = cl; @@ -2251,7 +2250,7 @@ void Scanner::lex_code_indented() tok = cur; code: -#line 2255 "src/parse/lex.cc" +#line 2254 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); @@ -2279,15 +2278,15 @@ code: } yy367: ++YYCURSOR; -#line 471 "../src/parse/lex.re" +#line 470 "../src/parse/lex.re" { fail_if_eof(); goto code; } -#line 2285 "src/parse/lex.cc" +#line 2284 "src/parse/lex.cc" yy369: ++YYCURSOR; yy370: -#line 476 "../src/parse/lex.re" +#line 475 "../src/parse/lex.re" { goto code; } -#line 2291 "src/parse/lex.cc" +#line 2290 "src/parse/lex.cc" yy371: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '\f') { @@ -2298,23 +2297,23 @@ yy371: if (yych == ' ') goto yy379; } yy372: -#line 464 "../src/parse/lex.re" +#line 463 "../src/parse/lex.re" { while (isspace(tok[0])) ++tok; while (cur > tok && isspace(cur[-1])) --cur; yylval.code = new Code(get_fname (), line, getstr(tok, cur)); return; } -#line 2309 "src/parse/lex.cc" +#line 2308 "src/parse/lex.cc" yy373: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy371; goto yy370; yy374: ++YYCURSOR; -#line 475 "../src/parse/lex.re" +#line 474 "../src/parse/lex.re" { lex_string(cur[-1]); goto code; } -#line 2318 "src/parse/lex.cc" +#line 2317 "src/parse/lex.cc" yy376: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy381; @@ -2322,27 +2321,27 @@ yy376: goto yy370; yy377: ++YYCURSOR; -#line 472 "../src/parse/lex.re" +#line 471 "../src/parse/lex.re" { fatal_l(get_line(), "Curly braces are not allowed after ':='"); } -#line 2328 "src/parse/lex.cc" +#line 2327 "src/parse/lex.cc" yy379: ++YYCURSOR; YYCURSOR -= 1; -#line 463 "../src/parse/lex.re" +#line 462 "../src/parse/lex.re" { goto code; } -#line 2334 "src/parse/lex.cc" +#line 2333 "src/parse/lex.cc" yy381: ++YYCURSOR; -#line 473 "../src/parse/lex.re" +#line 472 "../src/parse/lex.re" { lex_c_comment(); goto code; } -#line 2339 "src/parse/lex.cc" +#line 2338 "src/parse/lex.cc" yy383: ++YYCURSOR; -#line 474 "../src/parse/lex.re" +#line 473 "../src/parse/lex.re" { lex_cpp_comment(); goto code; } -#line 2344 "src/parse/lex.cc" +#line 2343 "src/parse/lex.cc" } -#line 477 "../src/parse/lex.re" +#line 476 "../src/parse/lex.re" } @@ -2352,7 +2351,7 @@ void Scanner::lex_code_in_braces() uint32_t depth = 1; code: -#line 2356 "src/parse/lex.cc" +#line 2355 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2414,15 +2413,15 @@ code: } yy387: ++YYCURSOR; -#line 497 "../src/parse/lex.re" +#line 496 "../src/parse/lex.re" { fail_if_eof(); goto code; } -#line 2420 "src/parse/lex.cc" +#line 2419 "src/parse/lex.cc" yy389: ++YYCURSOR; yy390: -#line 501 "../src/parse/lex.re" +#line 500 "../src/parse/lex.re" { goto code; } -#line 2426 "src/parse/lex.cc" +#line 2425 "src/parse/lex.cc" yy391: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -2430,18 +2429,18 @@ yy391: } if (yych == '#') goto yy404; yy392: -#line 496 "../src/parse/lex.re" +#line 495 "../src/parse/lex.re" { next_line(); goto code; } -#line 2436 "src/parse/lex.cc" +#line 2435 "src/parse/lex.cc" yy393: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy391; goto yy390; yy394: ++YYCURSOR; -#line 500 "../src/parse/lex.re" +#line 499 "../src/parse/lex.re" { lex_string(cur[-1]); goto code; } -#line 2445 "src/parse/lex.cc" +#line 2444 "src/parse/lex.cc" yy396: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy406; @@ -2449,12 +2448,12 @@ yy396: goto yy390; yy397: ++YYCURSOR; -#line 494 "../src/parse/lex.re" +#line 493 "../src/parse/lex.re" { ++depth; goto code; } -#line 2455 "src/parse/lex.cc" +#line 2454 "src/parse/lex.cc" yy399: ++YYCURSOR; -#line 486 "../src/parse/lex.re" +#line 485 "../src/parse/lex.re" { if (--depth == 0) { yylval.code = new Code(get_fname (), line, getstr(tok, cur)); @@ -2462,7 +2461,7 @@ yy399: } goto code; } -#line 2466 "src/parse/lex.cc" +#line 2465 "src/parse/lex.cc" yy401: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2488,14 +2487,14 @@ yy404: } yy406: ++YYCURSOR; -#line 498 "../src/parse/lex.re" +#line 497 "../src/parse/lex.re" { lex_c_comment(); goto code; } -#line 2494 "src/parse/lex.cc" +#line 2493 "src/parse/lex.cc" yy408: ++YYCURSOR; -#line 499 "../src/parse/lex.re" +#line 498 "../src/parse/lex.re" { lex_cpp_comment(); goto code; } -#line 2499 "src/parse/lex.cc" +#line 2498 "src/parse/lex.cc" yy410: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'i') goto yy403; @@ -2552,9 +2551,9 @@ yy418: yy420: ++YYCURSOR; YYCURSOR = yyt1; -#line 495 "../src/parse/lex.re" +#line 494 "../src/parse/lex.re" { set_sourceline (); goto code; } -#line 2558 "src/parse/lex.cc" +#line 2557 "src/parse/lex.cc" yy422: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy420; @@ -2580,7 +2579,7 @@ yy426: if (yych == '\n') goto yy403; goto yy423; } -#line 502 "../src/parse/lex.re" +#line 501 "../src/parse/lex.re" } @@ -2588,7 +2587,7 @@ void Scanner::lex_string(char delim) { loop: -#line 2592 "src/parse/lex.cc" +#line 2591 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2614,29 +2613,29 @@ loop: } yy429: ++YYCURSOR; -#line 512 "../src/parse/lex.re" +#line 511 "../src/parse/lex.re" { fail_if_eof(); goto loop; } -#line 2620 "src/parse/lex.cc" +#line 2619 "src/parse/lex.cc" yy431: ++YYCURSOR; yy432: -#line 513 "../src/parse/lex.re" +#line 512 "../src/parse/lex.re" { goto loop; } -#line 2626 "src/parse/lex.cc" +#line 2625 "src/parse/lex.cc" yy433: ++YYCURSOR; -#line 511 "../src/parse/lex.re" +#line 510 "../src/parse/lex.re" { next_line(); goto loop; } -#line 2631 "src/parse/lex.cc" +#line 2630 "src/parse/lex.cc" yy435: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy433; goto yy432; yy436: ++YYCURSOR; -#line 509 "../src/parse/lex.re" +#line 508 "../src/parse/lex.re" { if (cur[-1] == delim) return; else goto loop; } -#line 2640 "src/parse/lex.cc" +#line 2639 "src/parse/lex.cc" yy438: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '&') { @@ -2647,11 +2646,11 @@ yy438: } yy439: ++YYCURSOR; -#line 510 "../src/parse/lex.re" +#line 509 "../src/parse/lex.re" { goto loop; } -#line 2653 "src/parse/lex.cc" +#line 2652 "src/parse/lex.cc" } -#line 514 "../src/parse/lex.re" +#line 513 "../src/parse/lex.re" } @@ -2659,7 +2658,7 @@ void Scanner::lex_c_comment() { loop: -#line 2663 "src/parse/lex.cc" +#line 2662 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2675,20 +2674,20 @@ loop: } yy443: ++YYCURSOR; -#line 523 "../src/parse/lex.re" +#line 522 "../src/parse/lex.re" { fail_if_eof(); goto loop; } -#line 2681 "src/parse/lex.cc" +#line 2680 "src/parse/lex.cc" yy445: ++YYCURSOR; yy446: -#line 524 "../src/parse/lex.re" +#line 523 "../src/parse/lex.re" { goto loop; } -#line 2687 "src/parse/lex.cc" +#line 2686 "src/parse/lex.cc" yy447: ++YYCURSOR; -#line 522 "../src/parse/lex.re" +#line 521 "../src/parse/lex.re" { next_line(); goto loop; } -#line 2692 "src/parse/lex.cc" +#line 2691 "src/parse/lex.cc" yy449: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy447; @@ -2697,11 +2696,11 @@ yy450: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy446; ++YYCURSOR; -#line 521 "../src/parse/lex.re" +#line 520 "../src/parse/lex.re" { return; } -#line 2703 "src/parse/lex.cc" +#line 2702 "src/parse/lex.cc" } -#line 525 "../src/parse/lex.re" +#line 524 "../src/parse/lex.re" } @@ -2709,7 +2708,7 @@ void Scanner::lex_cpp_comment() { loop: -#line 2713 "src/parse/lex.cc" +#line 2712 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2724,26 +2723,26 @@ loop: } yy455: ++YYCURSOR; -#line 533 "../src/parse/lex.re" +#line 532 "../src/parse/lex.re" { fail_if_eof(); goto loop; } -#line 2730 "src/parse/lex.cc" +#line 2729 "src/parse/lex.cc" yy457: ++YYCURSOR; yy458: -#line 534 "../src/parse/lex.re" +#line 533 "../src/parse/lex.re" { goto loop; } -#line 2736 "src/parse/lex.cc" +#line 2735 "src/parse/lex.cc" yy459: ++YYCURSOR; -#line 532 "../src/parse/lex.re" +#line 531 "../src/parse/lex.re" { next_line(); return; } -#line 2741 "src/parse/lex.cc" +#line 2740 "src/parse/lex.cc" yy461: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy459; goto yy458; } -#line 535 "../src/parse/lex.re" +#line 534 "../src/parse/lex.re" } @@ -2755,35 +2754,35 @@ fst: tok = cur; c = get_column(); -#line 2759 "src/parse/lex.cc" +#line 2758 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy465; -#line 547 "../src/parse/lex.re" +#line 546 "../src/parse/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2767 "src/parse/lex.cc" +#line 2766 "src/parse/lex.cc" yy465: ++YYCURSOR; -#line 546 "../src/parse/lex.re" +#line 545 "../src/parse/lex.re" { return ast_cls(get_line(), c0, cls, neg); } -#line 2772 "src/parse/lex.cc" +#line 2771 "src/parse/lex.cc" } -#line 548 "../src/parse/lex.re" +#line 547 "../src/parse/lex.re" snd: -#line 2778 "src/parse/lex.cc" +#line 2777 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy470; yy469: -#line 551 "../src/parse/lex.re" +#line 550 "../src/parse/lex.re" { u = l; goto add; } -#line 2787 "src/parse/lex.cc" +#line 2786 "src/parse/lex.cc" yy470: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy472; @@ -2792,7 +2791,7 @@ yy470: yy472: ++YYCURSOR; YYCURSOR -= 1; -#line 552 "../src/parse/lex.re" +#line 551 "../src/parse/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2801,9 +2800,9 @@ yy472: } goto add; } -#line 2805 "src/parse/lex.cc" +#line 2804 "src/parse/lex.cc" } -#line 560 "../src/parse/lex.re" +#line 559 "../src/parse/lex.re" add: cls->push_back(ASTRange(l, u, c)); @@ -2815,7 +2814,7 @@ uint32_t Scanner::lex_cls_chr() tok = cur; const uint32_t l = get_line(), c = get_column(); -#line 2819 "src/parse/lex.cc" +#line 2818 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2832,20 +2831,20 @@ uint32_t Scanner::lex_cls_chr() } yy476: ++YYCURSOR; -#line 572 "../src/parse/lex.re" +#line 571 "../src/parse/lex.re" { fail_if_eof(); return 0; } -#line 2838 "src/parse/lex.cc" +#line 2837 "src/parse/lex.cc" yy478: ++YYCURSOR; yy479: -#line 578 "../src/parse/lex.re" +#line 577 "../src/parse/lex.re" { return static_cast(tok[0]); } -#line 2844 "src/parse/lex.cc" +#line 2843 "src/parse/lex.cc" yy480: ++YYCURSOR; -#line 573 "../src/parse/lex.re" +#line 572 "../src/parse/lex.re" { fatal_lc(l, c, "newline in character class"); } -#line 2849 "src/parse/lex.cc" +#line 2848 "src/parse/lex.cc" yy482: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy480; @@ -2904,36 +2903,36 @@ yy483: } } yy484: -#line 576 "../src/parse/lex.re" +#line 575 "../src/parse/lex.re" { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 2910 "src/parse/lex.cc" +#line 2909 "src/parse/lex.cc" yy485: ++YYCURSOR; yy486: -#line 591 "../src/parse/lex.re" +#line 590 "../src/parse/lex.re" { warn.useless_escape(l, c, tok[1]); return static_cast(tok[1]); } -#line 2919 "src/parse/lex.cc" +#line 2918 "src/parse/lex.cc" yy487: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy480; goto yy486; yy488: ++YYCURSOR; -#line 589 "../src/parse/lex.re" +#line 588 "../src/parse/lex.re" { return static_cast('-'); } -#line 2928 "src/parse/lex.cc" +#line 2927 "src/parse/lex.cc" yy490: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy491; if (yych <= '7') goto yy515; yy491: -#line 575 "../src/parse/lex.re" +#line 574 "../src/parse/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2937 "src/parse/lex.cc" +#line 2936 "src/parse/lex.cc" yy492: ++YYCURSOR; goto yy491; @@ -2949,9 +2948,9 @@ yy493: if (yych <= 'f') goto yy517; } yy494: -#line 574 "../src/parse/lex.re" +#line 573 "../src/parse/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2955 "src/parse/lex.cc" +#line 2954 "src/parse/lex.cc" yy495: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2967,49 +2966,49 @@ yy495: } yy496: ++YYCURSOR; -#line 588 "../src/parse/lex.re" +#line 587 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2973 "src/parse/lex.cc" +#line 2972 "src/parse/lex.cc" yy498: ++YYCURSOR; -#line 590 "../src/parse/lex.re" +#line 589 "../src/parse/lex.re" { return static_cast(']'); } -#line 2978 "src/parse/lex.cc" +#line 2977 "src/parse/lex.cc" yy500: ++YYCURSOR; -#line 581 "../src/parse/lex.re" +#line 580 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2983 "src/parse/lex.cc" +#line 2982 "src/parse/lex.cc" yy502: ++YYCURSOR; -#line 582 "../src/parse/lex.re" +#line 581 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2988 "src/parse/lex.cc" +#line 2987 "src/parse/lex.cc" yy504: ++YYCURSOR; -#line 583 "../src/parse/lex.re" +#line 582 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2993 "src/parse/lex.cc" +#line 2992 "src/parse/lex.cc" yy506: ++YYCURSOR; -#line 584 "../src/parse/lex.re" +#line 583 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2998 "src/parse/lex.cc" +#line 2997 "src/parse/lex.cc" yy508: ++YYCURSOR; -#line 585 "../src/parse/lex.re" +#line 584 "../src/parse/lex.re" { return static_cast('\r'); } -#line 3003 "src/parse/lex.cc" +#line 3002 "src/parse/lex.cc" yy510: ++YYCURSOR; -#line 586 "../src/parse/lex.re" +#line 585 "../src/parse/lex.re" { return static_cast('\t'); } -#line 3008 "src/parse/lex.cc" +#line 3007 "src/parse/lex.cc" yy512: ++YYCURSOR; -#line 587 "../src/parse/lex.re" +#line 586 "../src/parse/lex.re" { return static_cast('\v'); } -#line 3013 "src/parse/lex.cc" +#line 3012 "src/parse/lex.cc" yy514: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3072,9 +3071,9 @@ yy519: } yy520: ++YYCURSOR; -#line 580 "../src/parse/lex.re" +#line 579 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 3078 "src/parse/lex.cc" +#line 3077 "src/parse/lex.cc" yy522: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3101,9 +3100,9 @@ yy523: } yy524: ++YYCURSOR; -#line 579 "../src/parse/lex.re" +#line 578 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 3107 "src/parse/lex.cc" +#line 3106 "src/parse/lex.cc" yy526: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3127,7 +3126,7 @@ yy527: goto yy516; } } -#line 595 "../src/parse/lex.re" +#line 594 "../src/parse/lex.re" } @@ -3137,7 +3136,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) tok = cur; const uint32_t l = get_line(), c = get_column(); -#line 3141 "src/parse/lex.cc" +#line 3140 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -3154,23 +3153,23 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) } yy530: ++YYCURSOR; -#line 605 "../src/parse/lex.re" +#line 604 "../src/parse/lex.re" { fail_if_eof(); return 0; } -#line 3160 "src/parse/lex.cc" +#line 3159 "src/parse/lex.cc" yy532: ++YYCURSOR; yy533: -#line 611 "../src/parse/lex.re" +#line 610 "../src/parse/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 3169 "src/parse/lex.cc" +#line 3168 "src/parse/lex.cc" yy534: ++YYCURSOR; -#line 606 "../src/parse/lex.re" +#line 605 "../src/parse/lex.re" { fatal_lc(l, c, "newline in character string"); } -#line 3174 "src/parse/lex.cc" +#line 3173 "src/parse/lex.cc" yy536: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy534; @@ -3224,20 +3223,20 @@ yy537: } } yy538: -#line 609 "../src/parse/lex.re" +#line 608 "../src/parse/lex.re" { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 3230 "src/parse/lex.cc" +#line 3229 "src/parse/lex.cc" yy539: ++YYCURSOR; yy540: -#line 625 "../src/parse/lex.re" +#line 624 "../src/parse/lex.re" { if (tok[1] != quote) { warn.useless_escape(l, c, tok[1]); } return static_cast(tok[1]); } -#line 3241 "src/parse/lex.cc" +#line 3240 "src/parse/lex.cc" yy541: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy534; @@ -3248,9 +3247,9 @@ yy542: if (yych <= '/') goto yy543; if (yych <= '7') goto yy565; yy543: -#line 608 "../src/parse/lex.re" +#line 607 "../src/parse/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 3254 "src/parse/lex.cc" +#line 3253 "src/parse/lex.cc" yy544: ++YYCURSOR; goto yy543; @@ -3266,9 +3265,9 @@ yy545: if (yych <= 'f') goto yy567; } yy546: -#line 607 "../src/parse/lex.re" +#line 606 "../src/parse/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 3272 "src/parse/lex.cc" +#line 3271 "src/parse/lex.cc" yy547: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3284,44 +3283,44 @@ yy547: } yy548: ++YYCURSOR; -#line 624 "../src/parse/lex.re" +#line 623 "../src/parse/lex.re" { return static_cast('\\'); } -#line 3290 "src/parse/lex.cc" +#line 3289 "src/parse/lex.cc" yy550: ++YYCURSOR; -#line 617 "../src/parse/lex.re" +#line 616 "../src/parse/lex.re" { return static_cast('\a'); } -#line 3295 "src/parse/lex.cc" +#line 3294 "src/parse/lex.cc" yy552: ++YYCURSOR; -#line 618 "../src/parse/lex.re" +#line 617 "../src/parse/lex.re" { return static_cast('\b'); } -#line 3300 "src/parse/lex.cc" +#line 3299 "src/parse/lex.cc" yy554: ++YYCURSOR; -#line 619 "../src/parse/lex.re" +#line 618 "../src/parse/lex.re" { return static_cast('\f'); } -#line 3305 "src/parse/lex.cc" +#line 3304 "src/parse/lex.cc" yy556: ++YYCURSOR; -#line 620 "../src/parse/lex.re" +#line 619 "../src/parse/lex.re" { return static_cast('\n'); } -#line 3310 "src/parse/lex.cc" +#line 3309 "src/parse/lex.cc" yy558: ++YYCURSOR; -#line 621 "../src/parse/lex.re" +#line 620 "../src/parse/lex.re" { return static_cast('\r'); } -#line 3315 "src/parse/lex.cc" +#line 3314 "src/parse/lex.cc" yy560: ++YYCURSOR; -#line 622 "../src/parse/lex.re" +#line 621 "../src/parse/lex.re" { return static_cast('\t'); } -#line 3320 "src/parse/lex.cc" +#line 3319 "src/parse/lex.cc" yy562: ++YYCURSOR; -#line 623 "../src/parse/lex.re" +#line 622 "../src/parse/lex.re" { return static_cast('\v'); } -#line 3325 "src/parse/lex.cc" +#line 3324 "src/parse/lex.cc" yy564: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -3384,9 +3383,9 @@ yy569: } yy570: ++YYCURSOR; -#line 616 "../src/parse/lex.re" +#line 615 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 3390 "src/parse/lex.cc" +#line 3389 "src/parse/lex.cc" yy572: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3413,9 +3412,9 @@ yy573: } yy574: ++YYCURSOR; -#line 615 "../src/parse/lex.re" +#line 614 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 3419 "src/parse/lex.cc" +#line 3418 "src/parse/lex.cc" yy576: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -3439,7 +3438,7 @@ yy577: goto yy566; } } -#line 631 "../src/parse/lex.re" +#line 630 "../src/parse/lex.re" } @@ -3459,7 +3458,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 3463 "src/parse/lex.cc" +#line 3462 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -3517,20 +3516,20 @@ sourceline: } } ++YYCURSOR; -#line 667 "../src/parse/lex.re" +#line 666 "../src/parse/lex.re" { --cur; return; } -#line 3523 "src/parse/lex.cc" +#line 3522 "src/parse/lex.cc" yy582: ++YYCURSOR; yy583: -#line 668 "../src/parse/lex.re" +#line 667 "../src/parse/lex.re" { goto sourceline; } -#line 3529 "src/parse/lex.cc" +#line 3528 "src/parse/lex.cc" yy584: ++YYCURSOR; -#line 666 "../src/parse/lex.re" +#line 665 "../src/parse/lex.re" { tok = cur; return; } -#line 3534 "src/parse/lex.cc" +#line 3533 "src/parse/lex.cc" yy586: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy584; @@ -3547,7 +3546,7 @@ yy588: if (yybm[0+yych] & 64) { goto yy588; } -#line 650 "../src/parse/lex.re" +#line 649 "../src/parse/lex.re" { uint32_t l; if (!s_to_u32_unsafe (tok, cur, l)) { @@ -3556,7 +3555,7 @@ yy588: set_line(l); goto sourceline; } -#line 3560 "src/parse/lex.cc" +#line 3559 "src/parse/lex.cc" yy591: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3573,14 +3572,14 @@ yy593: goto yy583; yy594: ++YYCURSOR; -#line 659 "../src/parse/lex.re" +#line 658 "../src/parse/lex.re" { std::string &name = get_input().escaped_name; name = getstr(tok + 1, cur - 1); strrreplace(name, "\\", "\\\\"); goto sourceline; } -#line 3584 "src/parse/lex.cc" +#line 3583 "src/parse/lex.cc" yy596: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3589,7 +3588,7 @@ yy596: if (yych == '\n') goto yy593; goto yy591; } -#line 669 "../src/parse/lex.re" +#line 668 "../src/parse/lex.re" } diff --git a/re2c/bootstrap/src/parse/lex.h b/re2c/bootstrap/src/parse/lex.h index 8a16bf7b..a94c45e1 100644 --- a/re2c/bootstrap/src/parse/lex.h +++ b/re2c/bootstrap/src/parse/lex.h @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Thu Jan 10 23:17:36 2019 */ +/* Generated by re2c 1.1.1 on Thu Jan 17 22:27:03 2019 */ #include #include "src/util/forbid_copy.h" diff --git a/re2c/src/parse/lex.re b/re2c/src/parse/lex.re index f8bc2ea4..0c0c06aa 100644 --- a/re2c/src/parse/lex.re +++ b/re2c/src/parse/lex.re @@ -365,13 +365,12 @@ scan: return TOKEN_FID; } else { + // consume one character, otherwise we risk breaking operator + // precedence in cases like ab*: it should be a(b)*, not (ab)* + cur = tok + 1; + std::vector *str = new std::vector; - for (const char *s = tok; s < cur; ++s) { - const uint32_t - chr = static_cast(*s), - col = static_cast(s - tok); - str->push_back(ASTChar(chr, col)); - } + str->push_back(ASTChar(static_cast(tok[0]), 0)); yylval.regexp = ast_str(get_line(), get_column(), str, false); return TOKEN_REGEXP; } diff --git a/re2c/test/posix_captures/.dat/other.dat b/re2c/test/posix_captures/.dat/other.dat index 261682b2..e7c2ecfa 100644 --- a/re2c/test/posix_captures/.dat/other.dat +++ b/re2c/test/posix_captures/.dat/other.dat @@ -12,7 +12,7 @@ a*|(a|aa)* aa (0,2)(?,?) (a|aa)*|a* aa (0,2)(0,2) (aa*|aaa*)* aaaaaa (0,6)(0,6) -(aa*|aaa*)(aa*|aaa*) aaaaaa (0,6)(0,6)(6,6) +(aa*|aaa*)(aa*|aaa*) aaaaaa (0,6)(0,5)(5,6) (aa)*|(aaa)* aaaaaa (0,6)(4,6)(?,?) (X|Xa|Xab|Xaba|abab|baba|bY|Y)* XY (0,2)(1,2) @@ -67,3 +67,8 @@ SAME yyy (0,3)(2,3) (y|(x?)){1,3} y (0,1)(0,1)(?,?) (y[y]?){3} yyyy (0,4)(3,4) + +(aa*|aaa*){2} aaaaaa (0,6)(5,6) +((aa)*|(aaa)*)((aa)*|(aaa)*) aaaaaa (0,6)(0,6)(4,6)(?,?)(6,6)(?,?)(?,?) +((aa)*|(aaa)*){2} aaaaaa (0,6)(6,6)(?,?)(?,?) + diff --git a/re2c/test/posix_captures/glennfowler/21.i--flex-syntax.c b/re2c/test/posix_captures/glennfowler/21.i--flex-syntax.c index 10190d56..553e96c3 100644 --- a/re2c/test/posix_captures/glennfowler/21.i--flex-syntax.c +++ b/re2c/test/posix_captures/glennfowler/21.i--flex-syntax.c @@ -2,16 +2,12 @@ { YYCTYPE yych; - unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *(YYMARKER = YYCURSOR); switch (yych) { case 'a': - yyt1 = yyt3 = YYCURSOR; + yyt1 = YYCURSOR; goto yy3; - case 'b': - yyt1 = yyt3 = YYCURSOR; - goto yy5; default: goto yy2; } yy2: @@ -20,14 +16,19 @@ yy2: yypmatch[1] = YYCURSOR; {} yy3: - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - yyt2 = yyt3; + yych = *++YYCURSOR; switch (yych) { + case 'a': + yyt2 = YYCURSOR; + goto yy5; case 'b': goto yy7; default: goto yy4; } yy4: + YYCURSOR = YYMARKER; + goto yy2; +yy5: + ++YYCURSOR; yynmatch = 3; yypmatch[2] = yyt1; yypmatch[4] = yyt2; @@ -36,34 +37,23 @@ yy4: yypmatch[3] = yyt2; yypmatch[5] = YYCURSOR; {} -yy5: - yych = *++YYCURSOR; - switch (yych) { - case 'a': goto yy8; - default: goto yy6; - } -yy6: - YYCURSOR = YYMARKER; - if (yyaccept == 0) { - goto yy2; - } else { - goto yy4; - } yy7: yych = *++YYCURSOR; switch (yych) { case 'a': - yyt3 = YYCURSOR; - goto yy8; - case 'b': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; - default: goto yy6; + case 'b': + yyt2 = YYCURSOR; + goto yy8; + default: goto yy4; } yy8: - ++YYCURSOR; - yyt2 = yyt3; - goto yy4; + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: goto yy4; + } } re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] diff --git a/re2c/test/posix_captures/other/09.i--flex-syntax--posix-closure(gtop).c b/re2c/test/posix_captures/other/09.i--flex-syntax--posix-closure(gtop).c index e7f0902d..73cabb86 100644 --- a/re2c/test/posix_captures/other/09.i--flex-syntax--posix-closure(gtop).c +++ b/re2c/test/posix_captures/other/09.i--flex-syntax--posix-closure(gtop).c @@ -2,14 +2,15 @@ { YYCTYPE yych; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *(YYMARKER = YYCURSOR); + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; switch (yych) { case 'a': yyt1 = yyt2 = YYCURSOR; goto yy3; default: - yyt1 = yyt2 = yyt3 = YYCURSOR; + yyt2 = yyt3 = NULL; + yyt1 = YYCURSOR; goto yy2; } yy2: @@ -20,75 +21,12 @@ yy2: yypmatch[1] = YYCURSOR; {} yy3: - yych = *++YYCURSOR; - switch (yych) { - case 'a': goto yy5; - default: goto yy4; - } -yy4: - YYCURSOR = YYMARKER; - yyt1 = yyt2 = yyt3 = YYCURSOR; - goto yy2; -yy5: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy6; - default: - yyt3 = YYCURSOR; - goto yy2; - } -yy6: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - yyt3 = YYCURSOR; - switch (yych) { - case 'a': goto yy7; - default: goto yy2; - } -yy7: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': - yyt4 = YYCURSOR; - goto yy8; - default: - yyt3 = YYCURSOR; - goto yy2; - } -yy8: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy9; - default: - yyt2 = yyt3; - yyt3 = YYCURSOR; - goto yy2; - } -yy9: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy10; - default: - yyt3 = YYCURSOR; - goto yy2; - } -yy10: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { - case 'a': goto yy5; + case 'a': goto yy3; default: - yyt2 = yyt4; yyt3 = YYCURSOR; goto yy2; } diff --git a/re2c/test/posix_captures/other/09.i--flex-syntax.c b/re2c/test/posix_captures/other/09.i--flex-syntax.c index e7f0902d..73cabb86 100644 --- a/re2c/test/posix_captures/other/09.i--flex-syntax.c +++ b/re2c/test/posix_captures/other/09.i--flex-syntax.c @@ -2,14 +2,15 @@ { YYCTYPE yych; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *(YYMARKER = YYCURSOR); + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; switch (yych) { case 'a': yyt1 = yyt2 = YYCURSOR; goto yy3; default: - yyt1 = yyt2 = yyt3 = YYCURSOR; + yyt2 = yyt3 = NULL; + yyt1 = YYCURSOR; goto yy2; } yy2: @@ -20,75 +21,12 @@ yy2: yypmatch[1] = YYCURSOR; {} yy3: - yych = *++YYCURSOR; - switch (yych) { - case 'a': goto yy5; - default: goto yy4; - } -yy4: - YYCURSOR = YYMARKER; - yyt1 = yyt2 = yyt3 = YYCURSOR; - goto yy2; -yy5: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy6; - default: - yyt3 = YYCURSOR; - goto yy2; - } -yy6: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - yyt3 = YYCURSOR; - switch (yych) { - case 'a': goto yy7; - default: goto yy2; - } -yy7: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': - yyt4 = YYCURSOR; - goto yy8; - default: - yyt3 = YYCURSOR; - goto yy2; - } -yy8: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy9; - default: - yyt2 = yyt3; - yyt3 = YYCURSOR; - goto yy2; - } -yy9: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy10; - default: - yyt3 = YYCURSOR; - goto yy2; - } -yy10: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { - case 'a': goto yy5; + case 'a': goto yy3; default: - yyt2 = yyt4; yyt3 = YYCURSOR; goto yy2; } diff --git a/re2c/test/posix_captures/other/10.i--flex-syntax--posix-closure(gtop).c b/re2c/test/posix_captures/other/10.i--flex-syntax--posix-closure(gtop).c index 25e6925b..f649c238 100644 --- a/re2c/test/posix_captures/other/10.i--flex-syntax--posix-closure(gtop).c +++ b/re2c/test/posix_captures/other/10.i--flex-syntax--posix-closure(gtop).c @@ -8,90 +8,43 @@ case 'a': yyt1 = YYCURSOR; goto yy3; - default: - yyt1 = yyt2 = YYCURSOR; - goto yy2; + default: goto yy2; } yy2: - yynmatch = 3; - yypmatch[2] = yyt1; - yypmatch[4] = yyt2; - yypmatch[0] = yyt1; + yynmatch = 1; + yypmatch[0] = YYCURSOR; yypmatch[1] = YYCURSOR; - yypmatch[3] = yyt2; - yypmatch[5] = YYCURSOR; {} yy3: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy5; + case 'a': + yyt2 = YYCURSOR; + goto yy5; default: goto yy4; } yy4: YYCURSOR = YYMARKER; - yyt1 = yyt2 = YYCURSOR; goto yy2; yy5: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy6; - default: - yyt2 = YYCURSOR; - goto yy2; - } -yy6: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - yyt2 = YYCURSOR; - switch (yych) { - case 'a': goto yy7; - default: goto yy2; - } -yy7: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case 'a': - yyt3 = YYCURSOR; - goto yy8; - default: - yyt2 = YYCURSOR; - goto yy2; - } -yy8: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy9; - default: goto yy2; - } -yy9: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy10; - default: yyt2 = YYCURSOR; - goto yy2; - } -yy10: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy5; - default: - yyt2 = yyt3; - goto yy2; + goto yy5; + default: goto yy7; } +yy7: + yynmatch = 3; + yypmatch[2] = yyt1; + yypmatch[4] = yyt2; + yypmatch[0] = yyt1; + yypmatch[1] = YYCURSOR; + yypmatch[3] = yyt2; + yypmatch[5] = YYCURSOR; + {} } -re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string] re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] -re2c: warning: line 6: unreachable rule (shadowed by rule at line 5) [-Wunreachable-rules] diff --git a/re2c/test/posix_captures/other/10.i--flex-syntax.c b/re2c/test/posix_captures/other/10.i--flex-syntax.c index 25e6925b..f649c238 100644 --- a/re2c/test/posix_captures/other/10.i--flex-syntax.c +++ b/re2c/test/posix_captures/other/10.i--flex-syntax.c @@ -8,90 +8,43 @@ case 'a': yyt1 = YYCURSOR; goto yy3; - default: - yyt1 = yyt2 = YYCURSOR; - goto yy2; + default: goto yy2; } yy2: - yynmatch = 3; - yypmatch[2] = yyt1; - yypmatch[4] = yyt2; - yypmatch[0] = yyt1; + yynmatch = 1; + yypmatch[0] = YYCURSOR; yypmatch[1] = YYCURSOR; - yypmatch[3] = yyt2; - yypmatch[5] = YYCURSOR; {} yy3: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy5; + case 'a': + yyt2 = YYCURSOR; + goto yy5; default: goto yy4; } yy4: YYCURSOR = YYMARKER; - yyt1 = yyt2 = YYCURSOR; goto yy2; yy5: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy6; - default: - yyt2 = YYCURSOR; - goto yy2; - } -yy6: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - yyt2 = YYCURSOR; - switch (yych) { - case 'a': goto yy7; - default: goto yy2; - } -yy7: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case 'a': - yyt3 = YYCURSOR; - goto yy8; - default: - yyt2 = YYCURSOR; - goto yy2; - } -yy8: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy9; - default: goto yy2; - } -yy9: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy10; - default: yyt2 = YYCURSOR; - goto yy2; - } -yy10: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - switch (yych) { - case 'a': goto yy5; - default: - yyt2 = yyt3; - goto yy2; + goto yy5; + default: goto yy7; } +yy7: + yynmatch = 3; + yypmatch[2] = yyt1; + yypmatch[4] = yyt2; + yypmatch[0] = yyt1; + yypmatch[1] = YYCURSOR; + yypmatch[3] = yyt2; + yypmatch[5] = YYCURSOR; + {} } -re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string] re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] -re2c: warning: line 6: unreachable rule (shadowed by rule at line 5) [-Wunreachable-rules] diff --git a/re2c/test/posix_captures/other/27.i--flex-syntax--posix-closure(gtop).c b/re2c/test/posix_captures/other/27.i--flex-syntax--posix-closure(gtop).c new file mode 100644 index 00000000..b5ed4c7d --- /dev/null +++ b/re2c/test/posix_captures/other/27.i--flex-syntax--posix-closure(gtop).c @@ -0,0 +1,50 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *(YYMARKER = YYCURSOR); + switch (yych) { + case 'a': + yyt1 = YYCURSOR; + goto yy3; + default: goto yy2; + } +yy2: + yynmatch = 1; + yypmatch[0] = YYCURSOR; + yypmatch[1] = YYCURSOR; + {} +yy3: + yych = *++YYCURSOR; + switch (yych) { + case 'a': + yyt2 = YYCURSOR; + goto yy5; + default: goto yy4; + } +yy4: + YYCURSOR = YYMARKER; + goto yy2; +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt2 = YYCURSOR; + goto yy5; + default: + yyt3 = YYCURSOR; + goto yy7; + } +yy7: + yynmatch = 2; + yypmatch[0] = yyt1; + yypmatch[2] = yyt2; + yypmatch[3] = yyt3; + yypmatch[1] = YYCURSOR; + {} +} + +re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] diff --git a/re2c/test/posix_captures/other/27.i--flex-syntax--posix-closure(gtop).re b/re2c/test/posix_captures/other/27.i--flex-syntax--posix-closure(gtop).re new file mode 100644 index 00000000..d95a56b9 --- /dev/null +++ b/re2c/test/posix_captures/other/27.i--flex-syntax--posix-closure(gtop).re @@ -0,0 +1,7 @@ +/*!re2c + re2c:flags:posix-captures = 1; + + (aa*|aaa*){2} + {} + "" {} +*/ diff --git a/re2c/test/posix_captures/other/27.i--flex-syntax.c b/re2c/test/posix_captures/other/27.i--flex-syntax.c new file mode 100644 index 00000000..b5ed4c7d --- /dev/null +++ b/re2c/test/posix_captures/other/27.i--flex-syntax.c @@ -0,0 +1,50 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *(YYMARKER = YYCURSOR); + switch (yych) { + case 'a': + yyt1 = YYCURSOR; + goto yy3; + default: goto yy2; + } +yy2: + yynmatch = 1; + yypmatch[0] = YYCURSOR; + yypmatch[1] = YYCURSOR; + {} +yy3: + yych = *++YYCURSOR; + switch (yych) { + case 'a': + yyt2 = YYCURSOR; + goto yy5; + default: goto yy4; + } +yy4: + YYCURSOR = YYMARKER; + goto yy2; +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt2 = YYCURSOR; + goto yy5; + default: + yyt3 = YYCURSOR; + goto yy7; + } +yy7: + yynmatch = 2; + yypmatch[0] = yyt1; + yypmatch[2] = yyt2; + yypmatch[3] = yyt3; + yypmatch[1] = YYCURSOR; + {} +} + +re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] diff --git a/re2c/test/posix_captures/other/27.i--flex-syntax.re b/re2c/test/posix_captures/other/27.i--flex-syntax.re new file mode 100644 index 00000000..d95a56b9 --- /dev/null +++ b/re2c/test/posix_captures/other/27.i--flex-syntax.re @@ -0,0 +1,7 @@ +/*!re2c + re2c:flags:posix-captures = 1; + + (aa*|aaa*){2} + {} + "" {} +*/ diff --git a/re2c/test/posix_captures/other/28.i--flex-syntax--posix-closure(gtop).c b/re2c/test/posix_captures/other/28.i--flex-syntax--posix-closure(gtop).c new file mode 100644 index 00000000..749cf238 --- /dev/null +++ b/re2c/test/posix_captures/other/28.i--flex-syntax--posix-closure(gtop).c @@ -0,0 +1,132 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *(YYMARKER = YYCURSOR); + switch (yych) { + case 'a': + yyt3 = NULL; + yyt1 = yyt2 = yyt9 = YYCURSOR; + goto yy3; + default: + yyt2 = yyt3 = yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt1 = yyt5 = YYCURSOR; + goto yy2; + } +yy2: + yynmatch = 7; + yypmatch[2] = yyt1; + yypmatch[4] = yyt2; + yypmatch[5] = yyt3; + yypmatch[6] = yyt9; + yypmatch[7] = yyt4; + yypmatch[8] = yyt5; + yypmatch[10] = yyt6; + yypmatch[11] = yyt7; + yypmatch[12] = yyt8; + yypmatch[13] = yyt10; + yypmatch[0] = yyt1; + yypmatch[1] = YYCURSOR; + yypmatch[3] = yyt5; + yypmatch[9] = YYCURSOR; + {} +yy3: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: goto yy4; + } +yy4: + YYCURSOR = YYMARKER; + yyt2 = yyt3 = yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt1 = yyt5 = YYCURSOR; + goto yy2; +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt10 = YYCURSOR; + goto yy6; + default: + yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy6: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt4 = yyt5 = yyt6 = YYCURSOR; + goto yy7; + default: + yyt2 = yyt3; + yyt6 = yyt7 = yyt8 = yyt10 = NULL; + yyt4 = yyt5 = YYCURSOR; + goto yy2; + } +yy7: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt7 = NULL; + yyt2 = yyt8 = YYCURSOR; + goto yy8; + default: + yyt2 = yyt10; + yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy8: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy9; + default: + yyt2 = yyt3; + yyt8 = yyt10 = NULL; + yyt7 = YYCURSOR; + goto yy2; + } +yy9: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt2 = yyt9 = YYCURSOR; + goto yy10; + default: + yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy10: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: + yyt2 = yyt10; + yyt3 = yyt8; + yyt4 = yyt7; + yyt5 = yyt8; + yyt6 = yyt7; + yyt9 = yyt7; + yyt10 = YYCURSOR; + goto yy2; + } +} + +re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: unreachable rule (shadowed by rule at line 5) [-Wunreachable-rules] diff --git a/re2c/test/posix_captures/other/28.i--flex-syntax--posix-closure(gtop).re b/re2c/test/posix_captures/other/28.i--flex-syntax--posix-closure(gtop).re new file mode 100644 index 00000000..99ead951 --- /dev/null +++ b/re2c/test/posix_captures/other/28.i--flex-syntax--posix-closure(gtop).re @@ -0,0 +1,7 @@ +/*!re2c + re2c:flags:posix-captures = 1; + + ((aa)*|(aaa)*)((aa)*|(aaa)*) + {} + "" {} +*/ diff --git a/re2c/test/posix_captures/other/28.i--flex-syntax.c b/re2c/test/posix_captures/other/28.i--flex-syntax.c new file mode 100644 index 00000000..749cf238 --- /dev/null +++ b/re2c/test/posix_captures/other/28.i--flex-syntax.c @@ -0,0 +1,132 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *(YYMARKER = YYCURSOR); + switch (yych) { + case 'a': + yyt3 = NULL; + yyt1 = yyt2 = yyt9 = YYCURSOR; + goto yy3; + default: + yyt2 = yyt3 = yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt1 = yyt5 = YYCURSOR; + goto yy2; + } +yy2: + yynmatch = 7; + yypmatch[2] = yyt1; + yypmatch[4] = yyt2; + yypmatch[5] = yyt3; + yypmatch[6] = yyt9; + yypmatch[7] = yyt4; + yypmatch[8] = yyt5; + yypmatch[10] = yyt6; + yypmatch[11] = yyt7; + yypmatch[12] = yyt8; + yypmatch[13] = yyt10; + yypmatch[0] = yyt1; + yypmatch[1] = YYCURSOR; + yypmatch[3] = yyt5; + yypmatch[9] = YYCURSOR; + {} +yy3: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: goto yy4; + } +yy4: + YYCURSOR = YYMARKER; + yyt2 = yyt3 = yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt1 = yyt5 = YYCURSOR; + goto yy2; +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt10 = YYCURSOR; + goto yy6; + default: + yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy6: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt4 = yyt5 = yyt6 = YYCURSOR; + goto yy7; + default: + yyt2 = yyt3; + yyt6 = yyt7 = yyt8 = yyt10 = NULL; + yyt4 = yyt5 = YYCURSOR; + goto yy2; + } +yy7: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt7 = NULL; + yyt2 = yyt8 = YYCURSOR; + goto yy8; + default: + yyt2 = yyt10; + yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy8: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy9; + default: + yyt2 = yyt3; + yyt8 = yyt10 = NULL; + yyt7 = YYCURSOR; + goto yy2; + } +yy9: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt2 = yyt9 = YYCURSOR; + goto yy10; + default: + yyt4 = yyt6 = yyt7 = yyt8 = yyt9 = yyt10 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy10: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: + yyt2 = yyt10; + yyt3 = yyt8; + yyt4 = yyt7; + yyt5 = yyt8; + yyt6 = yyt7; + yyt9 = yyt7; + yyt10 = YYCURSOR; + goto yy2; + } +} + +re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: unreachable rule (shadowed by rule at line 5) [-Wunreachable-rules] diff --git a/re2c/test/posix_captures/other/28.i--flex-syntax.re b/re2c/test/posix_captures/other/28.i--flex-syntax.re new file mode 100644 index 00000000..99ead951 --- /dev/null +++ b/re2c/test/posix_captures/other/28.i--flex-syntax.re @@ -0,0 +1,7 @@ +/*!re2c + re2c:flags:posix-captures = 1; + + ((aa)*|(aaa)*)((aa)*|(aaa)*) + {} + "" {} +*/ diff --git a/re2c/test/posix_captures/other/29.i--flex-syntax--posix-closure(gtop).c b/re2c/test/posix_captures/other/29.i--flex-syntax--posix-closure(gtop).c new file mode 100644 index 00000000..e7d20593 --- /dev/null +++ b/re2c/test/posix_captures/other/29.i--flex-syntax--posix-closure(gtop).c @@ -0,0 +1,114 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *(YYMARKER = YYCURSOR); + switch (yych) { + case 'a': + yyt1 = YYCURSOR; + goto yy3; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt1 = yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy2: + yynmatch = 4; + yypmatch[0] = yyt1; + yypmatch[2] = yyt2; + yypmatch[3] = yyt3; + yypmatch[4] = yyt4; + yypmatch[5] = yyt5; + yypmatch[6] = yyt6; + yypmatch[7] = yyt7; + yypmatch[1] = YYCURSOR; + {} +yy3: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: goto yy4; + } +yy4: + YYCURSOR = YYMARKER; + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt1 = yyt2 = yyt3 = YYCURSOR; + goto yy2; +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy6; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy6: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt2 = yyt4 = YYCURSOR; + goto yy7; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy7: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt5 = yyt7 = NULL; + yyt3 = yyt6 = YYCURSOR; + goto yy8; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy8: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy9; + default: + yyt6 = yyt7 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy9: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy10; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy10: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: + yyt2 = yyt3; + yyt4 = yyt7; + yyt3 = yyt7 = YYCURSOR; + goto yy2; + } +} + +re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: unreachable rule (shadowed by rule at line 5) [-Wunreachable-rules] diff --git a/re2c/test/posix_captures/other/29.i--flex-syntax--posix-closure(gtop).re b/re2c/test/posix_captures/other/29.i--flex-syntax--posix-closure(gtop).re new file mode 100644 index 00000000..93744626 --- /dev/null +++ b/re2c/test/posix_captures/other/29.i--flex-syntax--posix-closure(gtop).re @@ -0,0 +1,7 @@ +/*!re2c + re2c:flags:posix-captures = 1; + + ((aa)*|(aaa)*){2} + {} + "" {} +*/ diff --git a/re2c/test/posix_captures/other/29.i--flex-syntax.c b/re2c/test/posix_captures/other/29.i--flex-syntax.c new file mode 100644 index 00000000..e7d20593 --- /dev/null +++ b/re2c/test/posix_captures/other/29.i--flex-syntax.c @@ -0,0 +1,114 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *(YYMARKER = YYCURSOR); + switch (yych) { + case 'a': + yyt1 = YYCURSOR; + goto yy3; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt1 = yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy2: + yynmatch = 4; + yypmatch[0] = yyt1; + yypmatch[2] = yyt2; + yypmatch[3] = yyt3; + yypmatch[4] = yyt4; + yypmatch[5] = yyt5; + yypmatch[6] = yyt6; + yypmatch[7] = yyt7; + yypmatch[1] = YYCURSOR; + {} +yy3: + yych = *++YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: goto yy4; + } +yy4: + YYCURSOR = YYMARKER; + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt1 = yyt2 = yyt3 = YYCURSOR; + goto yy2; +yy5: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy6; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy6: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt2 = yyt4 = YYCURSOR; + goto yy7; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy7: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': + yyt5 = yyt7 = NULL; + yyt3 = yyt6 = YYCURSOR; + goto yy8; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy8: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy9; + default: + yyt6 = yyt7 = NULL; + yyt3 = yyt5 = YYCURSOR; + goto yy2; + } +yy9: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy10; + default: + yyt4 = yyt5 = yyt6 = yyt7 = NULL; + yyt2 = yyt3 = YYCURSOR; + goto yy2; + } +yy10: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy5; + default: + yyt2 = yyt3; + yyt4 = yyt7; + yyt3 = yyt7 = YYCURSOR; + goto yy2; + } +} + +re2c: warning: line 5: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: rule matches empty string [-Wmatch-empty-string] +re2c: warning: line 6: unreachable rule (shadowed by rule at line 5) [-Wunreachable-rules] diff --git a/re2c/test/posix_captures/other/29.i--flex-syntax.re b/re2c/test/posix_captures/other/29.i--flex-syntax.re new file mode 100644 index 00000000..93744626 --- /dev/null +++ b/re2c/test/posix_captures/other/29.i--flex-syntax.re @@ -0,0 +1,7 @@ +/*!re2c + re2c:flags:posix-captures = 1; + + ((aa)*|(aaa)*){2} + {} + "" {} +*/