From 70e51a94d586dcf4ea9dcf760efe8437a4796c14 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 12 Oct 2015 14:12:11 +0100 Subject: [PATCH] Factored out some common lexing pieces into separate routines. re2c lacks submatch extraction; it would be much more convenient to memorize input positions for some parts of regular expressions than break each regexp in the middle and move parts to separate blocks. Submatch extraction is dificult to implement in general, but supporting submatch in some simple cases (like the case where trailing context is allowed) would be not so difficult and most helpful. --- re2c/bootstrap/src/parse/scanner_lex.cc | 727 +++++++++--------------- re2c/src/parse/scanner.h | 2 + re2c/src/parse/scanner_lex.re | 50 +- 3 files changed, 306 insertions(+), 473 deletions(-) diff --git a/re2c/bootstrap/src/parse/scanner_lex.cc b/re2c/bootstrap/src/parse/scanner_lex.cc index 4aaa0b8d..c9fea4f6 100644 --- a/re2c/bootstrap/src/parse/scanner_lex.cc +++ b/re2c/bootstrap/src/parse/scanner_lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.14.3 on Mon Oct 12 13:53:59 2015 */ +/* Generated by re2c 0.14.3 on Mon Oct 12 14:08:24 2015 */ #line 1 "../src/parse/scanner_lex.re" #include #include @@ -3306,11 +3306,10 @@ yy757: } -int32_t Scanner::lex_conf_number () +void Scanner::lex_conf_assign () { - int32_t num = 0; -#line 3314 "src/parse/scanner_lex.cc" +#line 3313 "src/parse/scanner_lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -3357,9 +3356,9 @@ int32_t Scanner::lex_conf_number () } ++YYCURSOR; yy774: -#line 677 "../src/parse/scanner_lex.re" +#line 676 "../src/parse/scanner_lex.re" { fatal ("missing '=' in configuration"); } -#line 3363 "src/parse/scanner_lex.cc" +#line 3362 "src/parse/scanner_lex.cc" yy775: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= 0x1F) { @@ -3375,9 +3374,9 @@ yy776: yych = (YYCTYPE)*YYCURSOR; goto yy779; yy777: -#line 678 "../src/parse/scanner_lex.re" - { goto conf_val; } -#line 3381 "src/parse/scanner_lex.cc" +#line 677 "../src/parse/scanner_lex.re" + { return; } +#line 3380 "src/parse/scanner_lex.cc" yy778: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -3400,87 +3399,14 @@ yy780: YYCURSOR = YYMARKER; goto yy774; } -#line 679 "../src/parse/scanner_lex.re" - -conf_val: - tok = cur; +#line 678 "../src/parse/scanner_lex.re" -#line 3409 "src/parse/scanner_lex.cc" -{ - YYCTYPE yych; - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = (YYCTYPE)*YYCURSOR; - if (yych <= '/') { - if (yych == '-') goto yy788; - } else { - if (yych <= '0') goto yy786; - if (yych <= '9') goto yy789; - } -yy785: -yy786: - ++YYCURSOR; -yy787: -#line 684 "../src/parse/scanner_lex.re" - { - if (!s_to_i32_unsafe (tok, cur, num)) - { - fatal ("configuration value overflow"); - } - goto conf_semicolon; - } -#line 3466 "src/parse/scanner_lex.cc" -yy788: - yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '0') goto yy785; - if (yych >= ':') goto yy785; -yy789: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy789; - } - goto yy787; } -#line 691 "../src/parse/scanner_lex.re" -conf_semicolon: +void Scanner::lex_conf_semicolon () +{ -#line 3484 "src/parse/scanner_lex.cc" +#line 3410 "src/parse/scanner_lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -3520,64 +3446,64 @@ conf_semicolon: if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; if (yych <= 0x1F) { - if (yych == '\t') goto yy795; + if (yych == '\t') goto yy787; } else { - if (yych <= ' ') goto yy795; - if (yych == ';') goto yy796; + if (yych <= ' ') goto yy787; + if (yych == ';') goto yy788; } ++YYCURSOR; -yy794: -#line 694 "../src/parse/scanner_lex.re" +yy786: +#line 684 "../src/parse/scanner_lex.re" { fatal ("missing ending ';' in configuration"); } -#line 3533 "src/parse/scanner_lex.cc" -yy795: +#line 3459 "src/parse/scanner_lex.cc" +yy787: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 128) { - goto yy799; + goto yy791; } - if (yych == ';') goto yy798; - goto yy794; -yy796: + if (yych == ';') goto yy790; + goto yy786; +yy788: ++YYCURSOR; -yy797: -#line 695 "../src/parse/scanner_lex.re" - { goto end; } -#line 3546 "src/parse/scanner_lex.cc" -yy798: +yy789: +#line 685 "../src/parse/scanner_lex.re" + { return; } +#line 3472 "src/parse/scanner_lex.cc" +yy790: yych = (YYCTYPE)*++YYCURSOR; - goto yy797; -yy799: + goto yy789; +yy791: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yybm[0+yych] & 128) { - goto yy799; + goto yy791; } - if (yych == ';') goto yy798; + if (yych == ';') goto yy790; YYCURSOR = YYMARKER; - goto yy794; + goto yy786; } -#line 696 "../src/parse/scanner_lex.re" +#line 686 "../src/parse/scanner_lex.re" -end: - return num; } -std::string Scanner::lex_conf_string () +int32_t Scanner::lex_conf_number () { + lex_conf_assign (); + tok = cur; -#line 3570 "src/parse/scanner_lex.cc" +#line 3496 "src/parse/scanner_lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -3605,64 +3531,51 @@ std::string Scanner::lex_conf_string () }; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; - if (yych <= 0x1F) { - if (yych == '\t') goto yy806; + if (yych <= '/') { + if (yych == '-') goto yy799; } else { - if (yych <= ' ') goto yy806; - if (yych == '=') goto yy807; + if (yych <= '0') goto yy797; + if (yych <= '9') goto yy800; } +yy796: +yy797: ++YYCURSOR; -yy805: -#line 704 "../src/parse/scanner_lex.re" - { fatal ("missing '=' in configuration"); } -#line 3619 "src/parse/scanner_lex.cc" -yy806: - yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych <= 0x1F) { - if (yych == '\t') goto yy811; - goto yy805; - } else { - if (yych <= ' ') goto yy811; - if (yych == '=') goto yy809; - goto yy805; +yy798: +#line 695 "../src/parse/scanner_lex.re" + { + int32_t n = 0; + if (!s_to_i32_unsafe (tok, cur, n)) + { + fatal ("configuration value overflow"); + } + lex_conf_semicolon (); + return n; } -yy807: - ++YYCURSOR; - yych = (YYCTYPE)*YYCURSOR; - goto yy810; -yy808: -#line 705 "../src/parse/scanner_lex.re" - { goto conf_val; } -#line 3637 "src/parse/scanner_lex.cc" -yy809: +#line 3555 "src/parse/scanner_lex.cc" +yy799: + yych = (YYCTYPE)*++YYCURSOR; + if (yych <= '0') goto yy796; + if (yych >= ':') goto yy796; +yy800: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy810: if (yybm[0+yych] & 128) { - goto yy809; - } - goto yy808; -yy811: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yych <= 0x1F) { - if (yych == '\t') goto yy811; - } else { - if (yych <= ' ') goto yy811; - if (yych == '=') goto yy809; + goto yy800; } - YYCURSOR = YYMARKER; - goto yy805; + goto yy798; +} +#line 704 "../src/parse/scanner_lex.re" + } -#line 706 "../src/parse/scanner_lex.re" -conf_val: +std::string Scanner::lex_conf_string () +{ + lex_conf_assign (); std::string s; tok = cur; -#line 3666 "src/parse/scanner_lex.cc" +#line 3579 "src/parse/scanner_lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -3703,129 +3616,49 @@ conf_val: yych = (YYCTYPE)*YYCURSOR; if (yych <= '!') { if (yych <= '\n') { - if (yych <= 0x08) goto yy819; + if (yych <= 0x08) goto yy807; } else { - if (yych != ' ') goto yy819; + if (yych != ' ') goto yy807; } } else { if (yych <= '\'') { - if (yych <= '"') goto yy817; - if (yych <= '&') goto yy819; - goto yy817; + if (yych <= '"') goto yy805; + if (yych <= '&') goto yy807; + goto yy805; } else { - if (yych != ';') goto yy819; + if (yych != ';') goto yy807; } } -yy816: -#line 719 "../src/parse/scanner_lex.re" +yy804: +#line 721 "../src/parse/scanner_lex.re" { s = std::string (tok, tok_len ()); - goto conf_semicolon; + goto end; } -#line 3726 "src/parse/scanner_lex.cc" -yy817: +#line 3639 "src/parse/scanner_lex.cc" +yy805: ++YYCURSOR; -#line 712 "../src/parse/scanner_lex.re" +#line 714 "../src/parse/scanner_lex.re" { std::vector cpoints; lex_cpoints (tok[0], cpoints); s = cpoint_conf (cpoints); - goto conf_semicolon; - } -#line 3736 "src/parse/scanner_lex.cc" -yy819: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy819; - } - goto yy816; -} -#line 723 "../src/parse/scanner_lex.re" - -conf_semicolon: - -#line 3750 "src/parse/scanner_lex.cc" -{ - YYCTYPE yych; - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 128, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = (YYCTYPE)*YYCURSOR; - if (yych <= 0x1F) { - if (yych == '\t') goto yy825; - } else { - if (yych <= ' ') goto yy825; - if (yych == ';') goto yy826; - } - ++YYCURSOR; -yy824: -#line 726 "../src/parse/scanner_lex.re" - { fatal ("missing ending ';' in configuration"); } -#line 3799 "src/parse/scanner_lex.cc" -yy825: - yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy829; + goto end; } - if (yych == ';') goto yy828; - goto yy824; -yy826: - ++YYCURSOR; -yy827: -#line 727 "../src/parse/scanner_lex.re" - { goto end; } -#line 3812 "src/parse/scanner_lex.cc" -yy828: - yych = (YYCTYPE)*++YYCURSOR; - goto yy827; -yy829: +#line 3649 "src/parse/scanner_lex.cc" +yy807: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yybm[0+yych] & 128) { - goto yy829; + goto yy807; } - if (yych == ';') goto yy828; - YYCURSOR = YYMARKER; - goto yy824; + goto yy804; } -#line 728 "../src/parse/scanner_lex.re" +#line 725 "../src/parse/scanner_lex.re" end: + lex_conf_semicolon (); return s; } @@ -3868,16 +3701,16 @@ void Scanner::lex_cpoints (char quote, std::vector & cs) { tok = cur; -#line 3872 "src/parse/scanner_lex.cc" +#line 3705 "src/parse/scanner_lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 10) YYFILL(10); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy836; - if (yych == '\\') goto yy838; + if (yych == '\n') goto yy813; + if (yych == '\\') goto yy815; ++YYCURSOR; -#line 791 "../src/parse/scanner_lex.re" +#line 789 "../src/parse/scanner_lex.re" { const char c = tok[0]; if (c == quote) @@ -3890,62 +3723,62 @@ void Scanner::lex_cpoints (char quote, std::vector & cs) continue; } } -#line 3894 "src/parse/scanner_lex.cc" -yy836: +#line 3727 "src/parse/scanner_lex.cc" +yy813: ++YYCURSOR; -#line 772 "../src/parse/scanner_lex.re" +#line 770 "../src/parse/scanner_lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 3899 "src/parse/scanner_lex.cc" -yy838: +#line 3732 "src/parse/scanner_lex.cc" +yy815: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) <= 'b') { if (yych <= 'T') { if (yych <= '/') { - if (yych != '\n') goto yy840; + if (yych != '\n') goto yy817; } else { - if (yych <= '3') goto yy842; - if (yych <= '7') goto yy844; - goto yy840; + if (yych <= '3') goto yy819; + if (yych <= '7') goto yy821; + goto yy817; } } else { if (yych <= 'X') { - if (yych <= 'U') goto yy845; - if (yych <= 'W') goto yy840; - goto yy847; + if (yych <= 'U') goto yy822; + if (yych <= 'W') goto yy817; + goto yy824; } else { - if (yych == '\\') goto yy848; - if (yych <= '`') goto yy840; - goto yy848; + if (yych == '\\') goto yy825; + if (yych <= '`') goto yy817; + goto yy825; } } } else { if (yych <= 'r') { if (yych <= 'm') { - if (yych == 'f') goto yy848; - goto yy840; + if (yych == 'f') goto yy825; + goto yy817; } else { - if (yych <= 'n') goto yy848; - if (yych <= 'q') goto yy840; - goto yy848; + if (yych <= 'n') goto yy825; + if (yych <= 'q') goto yy817; + goto yy825; } } else { if (yych <= 'u') { - if (yych <= 's') goto yy840; - if (yych <= 't') goto yy848; - goto yy847; + if (yych <= 's') goto yy817; + if (yych <= 't') goto yy825; + goto yy824; } else { - if (yych <= 'v') goto yy848; - if (yych == 'x') goto yy850; - goto yy840; + if (yych <= 'v') goto yy825; + if (yych == 'x') goto yy827; + goto yy817; } } } -#line 775 "../src/parse/scanner_lex.re" +#line 773 "../src/parse/scanner_lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 3946 "src/parse/scanner_lex.cc" -yy840: +#line 3779 "src/parse/scanner_lex.cc" +yy817: ++YYCURSOR; -#line 781 "../src/parse/scanner_lex.re" +#line 779 "../src/parse/scanner_lex.re" { const char c = tok[1]; if (c != quote) @@ -3955,199 +3788,199 @@ yy840: cs.push_back (static_cast (c)); continue; } -#line 3959 "src/parse/scanner_lex.cc" -yy842: +#line 3792 "src/parse/scanner_lex.cc" +yy819: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy843; - if (yych <= '7') goto yy865; -yy843: -#line 774 "../src/parse/scanner_lex.re" + if (yych <= '/') goto yy820; + if (yych <= '7') goto yy842; +yy820: +#line 772 "../src/parse/scanner_lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 3968 "src/parse/scanner_lex.cc" -yy844: +#line 3801 "src/parse/scanner_lex.cc" +yy821: yych = (YYCTYPE)*++YYCURSOR; - goto yy843; -yy845: + goto yy820; +yy822: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy846; - if (yych <= '9') goto yy858; + if (yych <= '/') goto yy823; + if (yych <= '9') goto yy835; } else { - if (yych <= 'F') goto yy858; - if (yych <= '`') goto yy846; - if (yych <= 'f') goto yy858; + if (yych <= 'F') goto yy835; + if (yych <= '`') goto yy823; + if (yych <= 'f') goto yy835; } -yy846: -#line 773 "../src/parse/scanner_lex.re" +yy823: +#line 771 "../src/parse/scanner_lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 3986 "src/parse/scanner_lex.cc" -yy847: +#line 3819 "src/parse/scanner_lex.cc" +yy824: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy846; - if (yych <= '9') goto yy855; - goto yy846; + if (yych <= '/') goto yy823; + if (yych <= '9') goto yy832; + goto yy823; } else { - if (yych <= 'F') goto yy855; - if (yych <= '`') goto yy846; - if (yych <= 'f') goto yy855; - goto yy846; + if (yych <= 'F') goto yy832; + if (yych <= '`') goto yy823; + if (yych <= 'f') goto yy832; + goto yy823; } -yy848: +yy825: ++YYCURSOR; -#line 779 "../src/parse/scanner_lex.re" +#line 777 "../src/parse/scanner_lex.re" { cs.push_back (unesc_simple (tok)); continue; } -#line 4004 "src/parse/scanner_lex.cc" -yy850: +#line 3837 "src/parse/scanner_lex.cc" +yy827: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy846; - if (yych >= ':') goto yy846; + if (yych <= '/') goto yy823; + if (yych >= ':') goto yy823; } else { - if (yych <= 'F') goto yy851; - if (yych <= '`') goto yy846; - if (yych >= 'g') goto yy846; + if (yych <= 'F') goto yy828; + if (yych <= '`') goto yy823; + if (yych >= 'g') goto yy823; } -yy851: +yy828: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych <= '9') goto yy853; + if (yych <= '/') goto yy829; + if (yych <= '9') goto yy830; } else { - if (yych <= 'F') goto yy853; - if (yych <= '`') goto yy852; - if (yych <= 'f') goto yy853; + if (yych <= 'F') goto yy830; + if (yych <= '`') goto yy829; + if (yych <= 'f') goto yy830; } -yy852: +yy829: YYCURSOR = YYMARKER; if (yyaccept == 0) { - goto yy843; + goto yy820; } else { - goto yy846; + goto yy823; } -yy853: +yy830: ++YYCURSOR; -#line 777 "../src/parse/scanner_lex.re" +#line 775 "../src/parse/scanner_lex.re" { cs.push_back (unesc_hex (tok, cur)); continue; } -#line 4037 "src/parse/scanner_lex.cc" -yy855: +#line 3870 "src/parse/scanner_lex.cc" +yy832: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy856; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy833; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy856: +yy833: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy857; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy834; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy857: +yy834: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych <= '9') goto yy853; - goto yy852; + if (yych <= '/') goto yy829; + if (yych <= '9') goto yy830; + goto yy829; } else { - if (yych <= 'F') goto yy853; - if (yych <= '`') goto yy852; - if (yych <= 'f') goto yy853; - goto yy852; + if (yych <= 'F') goto yy830; + if (yych <= '`') goto yy829; + if (yych <= 'f') goto yy830; + goto yy829; } -yy858: +yy835: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy859; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy836; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy859: +yy836: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy860; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy837; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy860: +yy837: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy861; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy838; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy861: +yy838: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy862; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy839; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy862: +yy839: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy863; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy840; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy863: +yy840: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych >= ':') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= ':') goto yy829; } else { - if (yych <= 'F') goto yy864; - if (yych <= '`') goto yy852; - if (yych >= 'g') goto yy852; + if (yych <= 'F') goto yy841; + if (yych <= '`') goto yy829; + if (yych >= 'g') goto yy829; } -yy864: +yy841: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy852; - if (yych <= '9') goto yy853; - goto yy852; + if (yych <= '/') goto yy829; + if (yych <= '9') goto yy830; + goto yy829; } else { - if (yych <= 'F') goto yy853; - if (yych <= '`') goto yy852; - if (yych <= 'f') goto yy853; - goto yy852; + if (yych <= 'F') goto yy830; + if (yych <= '`') goto yy829; + if (yych <= 'f') goto yy830; + goto yy829; } -yy865: +yy842: yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '/') goto yy852; - if (yych >= '8') goto yy852; + if (yych <= '/') goto yy829; + if (yych >= '8') goto yy829; ++YYCURSOR; -#line 778 "../src/parse/scanner_lex.re" +#line 776 "../src/parse/scanner_lex.re" { cs.push_back (unesc_oct (tok, cur)); continue; } -#line 4149 "src/parse/scanner_lex.cc" +#line 3982 "src/parse/scanner_lex.cc" } -#line 803 "../src/parse/scanner_lex.re" +#line 801 "../src/parse/scanner_lex.re" } } @@ -4157,7 +3990,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 4161 "src/parse/scanner_lex.cc" +#line 3994 "src/parse/scanner_lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -4197,23 +4030,23 @@ sourceline: if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; if (yych <= '!') { - if (yych == '\n') goto yy872; + if (yych == '\n') goto yy849; } else { - if (yych <= '"') goto yy874; - if (yych <= '0') goto yy870; - if (yych <= '9') goto yy875; + if (yych <= '"') goto yy851; + if (yych <= '0') goto yy847; + if (yych <= '9') goto yy852; } -yy870: +yy847: ++YYCURSOR; -yy871: -#line 835 "../src/parse/scanner_lex.re" +yy848: +#line 833 "../src/parse/scanner_lex.re" { goto sourceline; } -#line 4214 "src/parse/scanner_lex.cc" -yy872: +#line 4047 "src/parse/scanner_lex.cc" +yy849: ++YYCURSOR; -#line 823 "../src/parse/scanner_lex.re" +#line 821 "../src/parse/scanner_lex.re" { if (cur == eof) { @@ -4226,17 +4059,17 @@ yy872: tok = cur; return; } -#line 4230 "src/parse/scanner_lex.cc" -yy874: +#line 4063 "src/parse/scanner_lex.cc" +yy851: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy871; - goto yy880; -yy875: + if (yych == '\n') goto yy848; + goto yy857; +yy852: ++YYCURSOR; yych = (YYCTYPE)*YYCURSOR; - goto yy878; -yy876: -#line 812 "../src/parse/scanner_lex.re" + goto yy855; +yy853: +#line 810 "../src/parse/scanner_lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { @@ -4244,46 +4077,46 @@ yy876: } goto sourceline; } -#line 4248 "src/parse/scanner_lex.cc" -yy877: +#line 4081 "src/parse/scanner_lex.cc" +yy854: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy878: +yy855: if (yybm[0+yych] & 64) { - goto yy877; + goto yy854; } - goto yy876; -yy879: + goto yy853; +yy856: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy880: +yy857: if (yybm[0+yych] & 128) { - goto yy879; + goto yy856; } - if (yych <= '\n') goto yy881; - if (yych <= '"') goto yy883; - goto yy882; -yy881: + if (yych <= '\n') goto yy858; + if (yych <= '"') goto yy860; + goto yy859; +yy858: YYCURSOR = YYMARKER; - goto yy871; -yy882: + goto yy848; +yy859: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy881; - goto yy879; -yy883: + if (yych == '\n') goto yy858; + goto yy856; +yy860: ++YYCURSOR; -#line 819 "../src/parse/scanner_lex.re" +#line 817 "../src/parse/scanner_lex.re" { escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes goto sourceline; } -#line 4285 "src/parse/scanner_lex.cc" +#line 4118 "src/parse/scanner_lex.cc" } -#line 838 "../src/parse/scanner_lex.re" +#line 836 "../src/parse/scanner_lex.re" } diff --git a/re2c/src/parse/scanner.h b/re2c/src/parse/scanner.h index 03292837..fcf077b7 100644 --- a/re2c/src/parse/scanner.h +++ b/re2c/src/parse/scanner.h @@ -59,6 +59,8 @@ private: void fill (uint32_t); void set_sourceline (); void lex_cpoints (char quote, std::vector & cs); + void lex_conf_assign (); + void lex_conf_semicolon (); int32_t lex_conf_number (); std::string lex_conf_string (); std::string cpoint_conf (const std::vector & cs) const; diff --git a/re2c/src/parse/scanner_lex.re b/re2c/src/parse/scanner_lex.re index 98caeab8..ff49d21c 100644 --- a/re2c/src/parse/scanner_lex.re +++ b/re2c/src/parse/scanner_lex.re @@ -670,41 +670,43 @@ conf: */ } -int32_t Scanner::lex_conf_number () +void Scanner::lex_conf_assign () { - int32_t num = 0; /*!re2c - * { fatal ("missing '=' in configuration"); } - conf_assign { goto conf_val; } + * { fatal ("missing '=' in configuration"); } + conf_assign { return; } */ -conf_val: +} + +void Scanner::lex_conf_semicolon () +{ +/*!re2c + * { fatal ("missing ending ';' in configuration"); } + space* ";" { return; } +*/ +} + +int32_t Scanner::lex_conf_number () +{ + lex_conf_assign (); tok = cur; /*!re2c number { - if (!s_to_i32_unsafe (tok, cur, num)) + int32_t n = 0; + if (!s_to_i32_unsafe (tok, cur, n)) { fatal ("configuration value overflow"); } - goto conf_semicolon; + lex_conf_semicolon (); + return n; } */ -conf_semicolon: -/*!re2c - * { fatal ("missing ending ';' in configuration"); } - space* ";" { goto end; } -*/ -end: - return num; } std::string Scanner::lex_conf_string () { -/*!re2c - * { fatal ("missing '=' in configuration"); } - conf_assign { goto conf_val; } -*/ -conf_val: + lex_conf_assign (); std::string s; tok = cur; /*!re2c @@ -713,20 +715,16 @@ conf_val: std::vector cpoints; lex_cpoints (tok[0], cpoints); s = cpoint_conf (cpoints); - goto conf_semicolon; + goto end; } naked { s = std::string (tok, tok_len ()); - goto conf_semicolon; + goto end; } */ -conf_semicolon: -/*!re2c - * { fatal ("missing ending ';' in configuration"); } - space* ";" { goto end; } -*/ end: + lex_conf_semicolon (); return s; } -- 2.40.0