From d6f9f21e441f402be6fac0071798d505c82829b6 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 29 Oct 2018 23:32:22 +0000 Subject: [PATCH] Adjusted formatting in the lexer (cosmetic). --- re2c/bootstrap/src/ast/lex.cc | 529 +++++++++++++++++----------------- re2c/src/ast/lex.re | 182 ++++++------ 2 files changed, 348 insertions(+), 363 deletions(-) diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 5d3e349f..bf86f93e 100644 --- a/re2c/bootstrap/src/ast/lex.cc +++ b/re2c/bootstrap/src/ast/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Mon Oct 29 22:56:51 2018 */ +/* Generated by re2c 1.1.1 on Mon Oct 29 23:15:19 2018 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include @@ -1048,11 +1048,11 @@ scan: yy183: ++YYCURSOR; yy184: -#line 334 "../src/ast/lex.re" +#line 326 "../src/ast/lex.re" { - fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); - goto scan; - } + fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); + goto scan; + } #line 1057 "src/ast/lex.cc" yy185: ++YYCURSOR; @@ -1061,11 +1061,9 @@ yy185: if (yybm[0+yych] & 16) { goto yy185; } -#line 313 "../src/ast/lex.re" - { - goto scan; - } -#line 1069 "src/ast/lex.cc" +#line 306 "../src/ast/lex.re" + { goto scan; } +#line 1067 "src/ast/lex.cc" yy188: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1076,7 +1074,7 @@ yy188: if (yych == '#') goto yy214; } yy189: -#line 322 "../src/ast/lex.re" +#line 313 "../src/ast/lex.re" { if (cur == eof) return 0; pos = cur; @@ -1084,11 +1082,12 @@ yy189: if (lexer_state == LEX_FLEX_NAME) { lexer_state = LEX_NORMAL; return TOKEN_FID_END; - } else { + } + else { goto scan; } } -#line 1092 "src/ast/lex.cc" +#line 1091 "src/ast/lex.cc" yy190: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy188; @@ -1096,14 +1095,14 @@ yy190: yy191: ++YYCURSOR; yy192: -#line 226 "../src/ast/lex.re" +#line 222 "../src/ast/lex.re" { return *tok; } -#line 1102 "src/ast/lex.cc" +#line 1101 "src/ast/lex.cc" yy193: ++YYCURSOR; -#line 216 "../src/ast/lex.re" +#line 212 "../src/ast/lex.re" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; } -#line 1107 "src/ast/lex.cc" +#line 1106 "src/ast/lex.cc" yy195: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '^') { @@ -1121,21 +1120,21 @@ yy196: goto yy184; yy197: ++YYCURSOR; -#line 215 "../src/ast/lex.re" +#line 211 "../src/ast/lex.re" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; } -#line 1127 "src/ast/lex.cc" +#line 1126 "src/ast/lex.cc" yy199: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy219; goto yy192; yy200: ++YYCURSOR; -#line 308 "../src/ast/lex.re" +#line 301 "../src/ast/lex.re" { - yylval.regexp = ast_dot(cline, get_column()); - return TOKEN_REGEXP; - } -#line 1139 "src/ast/lex.cc" + yylval.regexp = ast_dot(cline, get_column()); + return TOKEN_REGEXP; + } +#line 1138 "src/ast/lex.cc" yy202: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy221; @@ -1178,9 +1177,9 @@ yy205: yy206: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy233; -#line 217 "../src/ast/lex.re" +#line 213 "../src/ast/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } -#line 1184 "src/ast/lex.cc" +#line 1183 "src/ast/lex.cc" yy208: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy235; @@ -1205,7 +1204,7 @@ yy209: yy210: #line 202 "../src/ast/lex.re" { lex_code(1); return TOKEN_CODE; } -#line 1209 "src/ast/lex.cc" +#line 1208 "src/ast/lex.cc" yy211: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1256,58 +1255,56 @@ yy216: } } yy218: -#line 220 "../src/ast/lex.re" +#line 216 "../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 1266 "src/ast/lex.cc" +#line 1265 "src/ast/lex.cc" yy219: ++YYCURSOR; -#line 210 "../src/ast/lex.re" - { - tok = cur; - return 0; - } -#line 1274 "src/ast/lex.cc" +#line 209 "../src/ast/lex.re" + { tok = cur; return 0; } +#line 1270 "src/ast/lex.cc" yy221: ++YYCURSOR; #line 207 "../src/ast/lex.re" { lex_c_comment(); goto scan; } -#line 1279 "src/ast/lex.cc" +#line 1275 "src/ast/lex.cc" yy223: ++YYCURSOR; #line 206 "../src/ast/lex.re" { lex_cpp_comment(); goto scan; } -#line 1284 "src/ast/lex.cc" +#line 1280 "src/ast/lex.cc" yy225: yych = (YYCTYPE)*++YYCURSOR; if (yych == '>') goto yy243; #line 203 "../src/ast/lex.re" { tok += 2; lex_code(0); return TOKEN_CODE; } -#line 1290 "src/ast/lex.cc" +#line 1286 "src/ast/lex.cc" yy227: ++YYCURSOR; YYCURSOR -= 1; -#line 291 "../src/ast/lex.re" +#line 283 "../src/ast/lex.re" { - if (!globopts->FFlag) { - yylval.str = new std::string (tok, tok_len()); - return TOKEN_ID; - } else { - std::vector *str = new std::vector; - for (char *s = tok; s < cur; ++s) { - const uint32_t - chr = static_cast(*s), - col = static_cast(s - tok); - str->push_back(ASTChar(chr, col)); - } - yylval.regexp = ast_str(cline, get_column(), str, false); - return TOKEN_REGEXP; - } - } -#line 1311 "src/ast/lex.cc" + if (!globopts->FFlag) { + yylval.str = new std::string (tok, tok_len()); + return TOKEN_ID; + } + else { + std::vector *str = new std::vector; + for (char *s = tok; s < cur; ++s) { + const uint32_t + chr = static_cast(*s), + col = static_cast(s - tok); + str->push_back(ASTChar(chr, col)); + } + yylval.regexp = ast_str(cline, get_column(), str, false); + return TOKEN_REGEXP; + } + } +#line 1308 "src/ast/lex.cc" yy229: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1327,17 +1324,17 @@ yy229: yy231: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 286 "../src/ast/lex.re" +#line 278 "../src/ast/lex.re" { - yylval.str = new std::string (tok, tok_len ()); - return TOKEN_ID; - } -#line 1336 "src/ast/lex.cc" + yylval.str = new std::string (tok, tok_len ()); + return TOKEN_ID; + } +#line 1333 "src/ast/lex.cc" yy233: ++YYCURSOR; -#line 218 "../src/ast/lex.re" +#line 214 "../src/ast/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1341 "src/ast/lex.cc" +#line 1338 "src/ast/lex.cc" yy235: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy247; @@ -1345,11 +1342,12 @@ yy235: yy236: ++YYCURSOR; yy237: -#line 259 "../src/ast/lex.re" +#line 251 "../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 1353 "src/ast/lex.cc" + fatal_lc(get_cline(), get_column(), + "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); + } +#line 1351 "src/ast/lex.cc" yy238: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1391,24 +1389,22 @@ yy243: YYCURSOR -= 2; #line 204 "../src/ast/lex.re" { return *tok; } -#line 1395 "src/ast/lex.cc" +#line 1393 "src/ast/lex.cc" yy245: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 273 "../src/ast/lex.re" +#line 267 "../src/ast/lex.re" { - yylval.str = new std::string (tok, tok_len ()); - if (globopts->FFlag) - { - lexer_state = LEX_FLEX_NAME; - return TOKEN_FID; - } - else - { - return TOKEN_ID; - } - } -#line 1412 "src/ast/lex.cc" + yylval.str = new std::string (tok, tok_len ()); + if (globopts->FFlag) { + lexer_state = LEX_FLEX_NAME; + return TOKEN_FID; + } + else { + return TOKEN_ID; + } + } +#line 1408 "src/ast/lex.cc" yy247: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy254; @@ -1422,27 +1418,27 @@ yy248: goto yy237; yy249: ++YYCURSOR; -#line 228 "../src/ast/lex.re" +#line 224 "../src/ast/lex.re" { - if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) - { - fatal_lc(get_cline(), get_column(), "repetition count overflow"); - } - yylval.bounds.max = yylval.bounds.min; - return TOKEN_CLOSESIZE; - } -#line 1435 "src/ast/lex.cc" + if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { + fatal_lc(get_cline(), get_column(), "repetition count overflow"); + } + yylval.bounds.max = yylval.bounds.min; + return TOKEN_CLOSESIZE; + } +#line 1430 "src/ast/lex.cc" yy251: ++YYCURSOR; -#line 263 "../src/ast/lex.re" +#line 256 "../src/ast/lex.re" { - if (!globopts->FFlag) { - fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch"); - } - yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces - return TOKEN_ID; - } -#line 1446 "src/ast/lex.cc" + if (!globopts->FFlag) { + fatal_lc(get_cline(), get_column(), + "curly braces for names only allowed with -F switch"); + } + yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces + return TOKEN_ID; + } +#line 1442 "src/ast/lex.cc" yy253: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy259; @@ -1461,41 +1457,38 @@ yy255: goto yy213; yy257: ++YYCURSOR; -#line 250 "../src/ast/lex.re" +#line 243 "../src/ast/lex.re" { - if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) - { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); - } - yylval.bounds.max = std::numeric_limits::max(); - return TOKEN_CLOSESIZE; - } -#line 1474 "src/ast/lex.cc" + if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { + fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + } + yylval.bounds.max = std::numeric_limits::max(); + return TOKEN_CLOSESIZE; + } +#line 1469 "src/ast/lex.cc" yy259: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy264; goto yy213; yy260: ++YYCURSOR; -#line 271 "../src/ast/lex.re" +#line 265 "../src/ast/lex.re" { return TOKEN_CONF; } -#line 1483 "src/ast/lex.cc" +#line 1478 "src/ast/lex.cc" yy262: ++YYCURSOR; -#line 237 "../src/ast/lex.re" +#line 232 "../src/ast/lex.re" { - const char * p = strchr (tok, ','); - if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) - { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); - } - if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max)) - { - fatal_lc(get_cline(), get_column(), "repetition upper bound overflow"); - } - return TOKEN_CLOSESIZE; - } -#line 1499 "src/ast/lex.cc" + const char * p = strchr (tok, ','); + if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) { + fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + } + if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max)) { + fatal_lc(get_cline(), get_column(), "repetition upper bound overflow"); + } + return TOKEN_CLOSESIZE; + } +#line 1492 "src/ast/lex.cc" yy264: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy266; @@ -1551,12 +1544,12 @@ yy269: yy271: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 317 "../src/ast/lex.re" +#line 308 "../src/ast/lex.re" { set_sourceline (); return TOKEN_LINE_INFO; } -#line 1560 "src/ast/lex.cc" +#line 1553 "src/ast/lex.cc" yy273: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy271; @@ -1582,7 +1575,7 @@ yy277: if (yych == '\n') goto yy213; goto yy274; } -#line 338 "../src/ast/lex.re" +#line 330 "../src/ast/lex.re" } @@ -1591,7 +1584,7 @@ void Scanner::lex_code(uint32_t depth) const uint32_t line = cline; code: -#line 1595 "src/ast/lex.cc" +#line 1588 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1654,20 +1647,20 @@ code: } yy280: ++YYCURSOR; -#line 395 "../src/ast/lex.re" +#line 387 "../src/ast/lex.re" { if (cur == eof) { if (depth) fatal_l(get_cline(), "missing '}'"); } goto code; } -#line 1665 "src/ast/lex.cc" +#line 1658 "src/ast/lex.cc" yy282: ++YYCURSOR; yy283: -#line 405 "../src/ast/lex.re" +#line 397 "../src/ast/lex.re" { goto code; } -#line 1671 "src/ast/lex.cc" +#line 1664 "src/ast/lex.cc" yy284: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1686,7 +1679,7 @@ yy284: } } yy285: -#line 380 "../src/ast/lex.re" +#line 372 "../src/ast/lex.re" { if (depth == 0) { tok += strspn(tok, " \t\r\n"); @@ -1701,16 +1694,16 @@ yy285: cline++; goto code; } -#line 1705 "src/ast/lex.cc" +#line 1698 "src/ast/lex.cc" yy286: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy284; goto yy283; yy287: ++YYCURSOR; -#line 404 "../src/ast/lex.re" +#line 396 "../src/ast/lex.re" { lex_string(cur[-1]); goto code; } -#line 1714 "src/ast/lex.cc" +#line 1707 "src/ast/lex.cc" yy289: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy300; @@ -1718,7 +1711,7 @@ yy289: goto yy283; yy290: ++YYCURSOR; -#line 357 "../src/ast/lex.re" +#line 349 "../src/ast/lex.re" { if (depth == 0) { fatal_l(get_cline(), "Curly braces are not allowed after ':='"); @@ -1728,10 +1721,10 @@ yy290: } goto code; } -#line 1732 "src/ast/lex.cc" +#line 1725 "src/ast/lex.cc" yy292: ++YYCURSOR; -#line 346 "../src/ast/lex.re" +#line 338 "../src/ast/lex.re" { if (depth == 0) { fatal_l(get_cline(), "Curly braces are not allowed after ':='"); @@ -1742,7 +1735,7 @@ yy292: } goto code; } -#line 1746 "src/ast/lex.cc" +#line 1739 "src/ast/lex.cc" yy294: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1754,7 +1747,7 @@ yy294: } yy295: YYCURSOR -= 1; -#line 372 "../src/ast/lex.re" +#line 364 "../src/ast/lex.re" { if (depth == 0) goto code; else if (cur == eof) fatal_l(get_cline(), "missing '}'"); @@ -1762,7 +1755,7 @@ yy295: cline++; goto code; } -#line 1766 "src/ast/lex.cc" +#line 1759 "src/ast/lex.cc" yy296: ++YYCURSOR; goto yy295; @@ -1783,14 +1776,14 @@ yy299: } yy300: ++YYCURSOR; -#line 402 "../src/ast/lex.re" +#line 394 "../src/ast/lex.re" { lex_c_comment(); goto code; } -#line 1789 "src/ast/lex.cc" +#line 1782 "src/ast/lex.cc" yy302: ++YYCURSOR; -#line 403 "../src/ast/lex.re" +#line 395 "../src/ast/lex.re" { lex_cpp_comment(); goto code; } -#line 1794 "src/ast/lex.cc" +#line 1787 "src/ast/lex.cc" yy304: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1859,12 +1852,12 @@ yy314: yy316: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 367 "../src/ast/lex.re" +#line 359 "../src/ast/lex.re" { set_sourceline (); goto code; } -#line 1868 "src/ast/lex.cc" +#line 1861 "src/ast/lex.cc" yy318: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy316; @@ -1890,7 +1883,7 @@ yy322: if (yych == '\n') goto yy299; goto yy319; } -#line 406 "../src/ast/lex.re" +#line 398 "../src/ast/lex.re" } @@ -1898,7 +1891,7 @@ void Scanner::lex_string(char delim) { loop: -#line 1902 "src/ast/lex.cc" +#line 1895 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1924,29 +1917,29 @@ loop: } yy325: ++YYCURSOR; -#line 416 "../src/ast/lex.re" +#line 408 "../src/ast/lex.re" { if (cur == eof) fatal_l(get_cline(), "unexpected end of input"); else goto loop; } -#line 1930 "src/ast/lex.cc" +#line 1923 "src/ast/lex.cc" yy327: ++YYCURSOR; yy328: -#line 417 "../src/ast/lex.re" +#line 409 "../src/ast/lex.re" { goto loop; } -#line 1936 "src/ast/lex.cc" +#line 1929 "src/ast/lex.cc" yy329: ++YYCURSOR; -#line 415 "../src/ast/lex.re" +#line 407 "../src/ast/lex.re" { pos = cur; ++cline; goto loop; } -#line 1941 "src/ast/lex.cc" +#line 1934 "src/ast/lex.cc" yy331: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy329; goto yy328; yy332: ++YYCURSOR; -#line 413 "../src/ast/lex.re" +#line 405 "../src/ast/lex.re" { if (cur[-1] == delim) return; else goto loop; } -#line 1950 "src/ast/lex.cc" +#line 1943 "src/ast/lex.cc" yy334: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '&') { @@ -1957,11 +1950,11 @@ yy334: } yy335: ++YYCURSOR; -#line 414 "../src/ast/lex.re" +#line 406 "../src/ast/lex.re" { goto loop; } -#line 1963 "src/ast/lex.cc" +#line 1956 "src/ast/lex.cc" } -#line 418 "../src/ast/lex.re" +#line 410 "../src/ast/lex.re" } @@ -1969,7 +1962,7 @@ void Scanner::lex_c_comment() { loop: -#line 1973 "src/ast/lex.cc" +#line 1966 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1985,20 +1978,20 @@ loop: } yy339: ++YYCURSOR; -#line 427 "../src/ast/lex.re" +#line 419 "../src/ast/lex.re" { if (cur == eof) fatal_l(get_cline(), "end of input in comment"); else goto loop; } -#line 1991 "src/ast/lex.cc" +#line 1984 "src/ast/lex.cc" yy341: ++YYCURSOR; yy342: -#line 428 "../src/ast/lex.re" +#line 420 "../src/ast/lex.re" { goto loop; } -#line 1997 "src/ast/lex.cc" +#line 1990 "src/ast/lex.cc" yy343: ++YYCURSOR; -#line 426 "../src/ast/lex.re" +#line 418 "../src/ast/lex.re" { pos = cur; ++cline; goto loop; } -#line 2002 "src/ast/lex.cc" +#line 1995 "src/ast/lex.cc" yy345: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy343; @@ -2007,11 +2000,11 @@ yy346: yych = (YYCTYPE)*++YYCURSOR; if (yych != '/') goto yy342; ++YYCURSOR; -#line 425 "../src/ast/lex.re" +#line 417 "../src/ast/lex.re" { return; } -#line 2013 "src/ast/lex.cc" +#line 2006 "src/ast/lex.cc" } -#line 429 "../src/ast/lex.re" +#line 421 "../src/ast/lex.re" } @@ -2019,7 +2012,7 @@ void Scanner::lex_cpp_comment() { loop: -#line 2023 "src/ast/lex.cc" +#line 2016 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -2034,26 +2027,26 @@ loop: } yy351: ++YYCURSOR; -#line 437 "../src/ast/lex.re" +#line 429 "../src/ast/lex.re" { if (cur == eof) fatal_l(get_cline(), "end of input in comment"); else goto loop; } -#line 2040 "src/ast/lex.cc" +#line 2033 "src/ast/lex.cc" yy353: ++YYCURSOR; yy354: -#line 438 "../src/ast/lex.re" +#line 430 "../src/ast/lex.re" { goto loop; } -#line 2046 "src/ast/lex.cc" +#line 2039 "src/ast/lex.cc" yy355: ++YYCURSOR; -#line 436 "../src/ast/lex.re" +#line 428 "../src/ast/lex.re" { pos = cur; ++cline; return; } -#line 2051 "src/ast/lex.cc" +#line 2044 "src/ast/lex.cc" yy357: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy355; goto yy354; } -#line 439 "../src/ast/lex.re" +#line 431 "../src/ast/lex.re" } @@ -2065,35 +2058,35 @@ fst: tok = cur; c = get_column(); -#line 2069 "src/ast/lex.cc" +#line 2062 "src/ast/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy361; -#line 451 "../src/ast/lex.re" +#line 443 "../src/ast/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2077 "src/ast/lex.cc" +#line 2070 "src/ast/lex.cc" yy361: ++YYCURSOR; -#line 450 "../src/ast/lex.re" +#line 442 "../src/ast/lex.re" { return ast_cls(cline, c0, cls, neg); } -#line 2082 "src/ast/lex.cc" +#line 2075 "src/ast/lex.cc" } -#line 452 "../src/ast/lex.re" +#line 444 "../src/ast/lex.re" snd: -#line 2088 "src/ast/lex.cc" +#line 2081 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy366; yy365: -#line 455 "../src/ast/lex.re" +#line 447 "../src/ast/lex.re" { u = l; goto add; } -#line 2097 "src/ast/lex.cc" +#line 2090 "src/ast/lex.cc" yy366: yych = (YYCTYPE)*++YYCURSOR; if (yych != ']') goto yy368; @@ -2102,7 +2095,7 @@ yy366: yy368: ++YYCURSOR; YYCURSOR -= 1; -#line 456 "../src/ast/lex.re" +#line 448 "../src/ast/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2111,9 +2104,9 @@ yy368: } goto add; } -#line 2115 "src/ast/lex.cc" +#line 2108 "src/ast/lex.cc" } -#line 464 "../src/ast/lex.re" +#line 456 "../src/ast/lex.re" add: cls->push_back(ASTRange(l, u, c)); @@ -2125,7 +2118,7 @@ uint32_t Scanner::lex_cls_chr() tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2129 "src/ast/lex.cc" +#line 2122 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2139,14 +2132,14 @@ uint32_t Scanner::lex_cls_chr() } ++YYCURSOR; yy373: -#line 481 "../src/ast/lex.re" +#line 473 "../src/ast/lex.re" { return static_cast(tok[0]); } -#line 2145 "src/ast/lex.cc" +#line 2138 "src/ast/lex.cc" yy374: ++YYCURSOR; -#line 476 "../src/ast/lex.re" +#line 468 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character class"); } -#line 2150 "src/ast/lex.cc" +#line 2143 "src/ast/lex.cc" yy376: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy374; @@ -2198,30 +2191,30 @@ yy377: yy378: ++YYCURSOR; yy379: -#line 494 "../src/ast/lex.re" +#line 486 "../src/ast/lex.re" { warn.useless_escape(cline, get_column(), tok[1]); return static_cast(tok[1]); } -#line 2207 "src/ast/lex.cc" +#line 2200 "src/ast/lex.cc" yy380: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy374; goto yy379; yy381: ++YYCURSOR; -#line 492 "../src/ast/lex.re" +#line 484 "../src/ast/lex.re" { return static_cast('-'); } -#line 2216 "src/ast/lex.cc" +#line 2209 "src/ast/lex.cc" yy383: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy384; if (yych <= '7') goto yy408; yy384: -#line 478 "../src/ast/lex.re" +#line 470 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2225 "src/ast/lex.cc" +#line 2218 "src/ast/lex.cc" yy385: ++YYCURSOR; goto yy384; @@ -2237,9 +2230,9 @@ yy386: if (yych <= 'f') goto yy410; } yy387: -#line 477 "../src/ast/lex.re" +#line 469 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2243 "src/ast/lex.cc" +#line 2236 "src/ast/lex.cc" yy388: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2255,49 +2248,49 @@ yy388: } yy389: ++YYCURSOR; -#line 491 "../src/ast/lex.re" +#line 483 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2261 "src/ast/lex.cc" +#line 2254 "src/ast/lex.cc" yy391: ++YYCURSOR; -#line 493 "../src/ast/lex.re" +#line 485 "../src/ast/lex.re" { return static_cast(']'); } -#line 2266 "src/ast/lex.cc" +#line 2259 "src/ast/lex.cc" yy393: ++YYCURSOR; -#line 484 "../src/ast/lex.re" +#line 476 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2271 "src/ast/lex.cc" +#line 2264 "src/ast/lex.cc" yy395: ++YYCURSOR; -#line 485 "../src/ast/lex.re" +#line 477 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2276 "src/ast/lex.cc" +#line 2269 "src/ast/lex.cc" yy397: ++YYCURSOR; -#line 486 "../src/ast/lex.re" +#line 478 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2281 "src/ast/lex.cc" +#line 2274 "src/ast/lex.cc" yy399: ++YYCURSOR; -#line 487 "../src/ast/lex.re" +#line 479 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2286 "src/ast/lex.cc" +#line 2279 "src/ast/lex.cc" yy401: ++YYCURSOR; -#line 488 "../src/ast/lex.re" +#line 480 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2291 "src/ast/lex.cc" +#line 2284 "src/ast/lex.cc" yy403: ++YYCURSOR; -#line 489 "../src/ast/lex.re" +#line 481 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2296 "src/ast/lex.cc" +#line 2289 "src/ast/lex.cc" yy405: ++YYCURSOR; -#line 490 "../src/ast/lex.re" +#line 482 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2301 "src/ast/lex.cc" +#line 2294 "src/ast/lex.cc" yy407: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2360,9 +2353,9 @@ yy412: } yy413: ++YYCURSOR; -#line 483 "../src/ast/lex.re" +#line 475 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2366 "src/ast/lex.cc" +#line 2359 "src/ast/lex.cc" yy415: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2389,9 +2382,9 @@ yy416: } yy417: ++YYCURSOR; -#line 482 "../src/ast/lex.re" +#line 474 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2395 "src/ast/lex.cc" +#line 2388 "src/ast/lex.cc" yy419: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2415,7 +2408,7 @@ yy420: goto yy409; } } -#line 498 "../src/ast/lex.re" +#line 490 "../src/ast/lex.re" } @@ -2425,7 +2418,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2429 "src/ast/lex.cc" +#line 2422 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2439,17 +2432,17 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) } ++YYCURSOR; yy424: -#line 513 "../src/ast/lex.re" +#line 505 "../src/ast/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2448 "src/ast/lex.cc" +#line 2441 "src/ast/lex.cc" yy425: ++YYCURSOR; -#line 508 "../src/ast/lex.re" +#line 500 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character string"); } -#line 2453 "src/ast/lex.cc" +#line 2446 "src/ast/lex.cc" yy427: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy425; @@ -2498,14 +2491,14 @@ yy428: yy429: ++YYCURSOR; yy430: -#line 527 "../src/ast/lex.re" +#line 519 "../src/ast/lex.re" { if (tok[1] != quote) { warn.useless_escape(cline, get_column(), tok[1]); } return static_cast(tok[1]); } -#line 2509 "src/ast/lex.cc" +#line 2502 "src/ast/lex.cc" yy431: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy425; @@ -2516,9 +2509,9 @@ yy432: if (yych <= '/') goto yy433; if (yych <= '7') goto yy455; yy433: -#line 510 "../src/ast/lex.re" +#line 502 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2522 "src/ast/lex.cc" +#line 2515 "src/ast/lex.cc" yy434: ++YYCURSOR; goto yy433; @@ -2534,9 +2527,9 @@ yy435: if (yych <= 'f') goto yy457; } yy436: -#line 509 "../src/ast/lex.re" +#line 501 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2540 "src/ast/lex.cc" +#line 2533 "src/ast/lex.cc" yy437: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2552,44 +2545,44 @@ yy437: } yy438: ++YYCURSOR; -#line 526 "../src/ast/lex.re" +#line 518 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2558 "src/ast/lex.cc" +#line 2551 "src/ast/lex.cc" yy440: ++YYCURSOR; -#line 519 "../src/ast/lex.re" +#line 511 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2563 "src/ast/lex.cc" +#line 2556 "src/ast/lex.cc" yy442: ++YYCURSOR; -#line 520 "../src/ast/lex.re" +#line 512 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2568 "src/ast/lex.cc" +#line 2561 "src/ast/lex.cc" yy444: ++YYCURSOR; -#line 521 "../src/ast/lex.re" +#line 513 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2573 "src/ast/lex.cc" +#line 2566 "src/ast/lex.cc" yy446: ++YYCURSOR; -#line 522 "../src/ast/lex.re" +#line 514 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2578 "src/ast/lex.cc" +#line 2571 "src/ast/lex.cc" yy448: ++YYCURSOR; -#line 523 "../src/ast/lex.re" +#line 515 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2583 "src/ast/lex.cc" +#line 2576 "src/ast/lex.cc" yy450: ++YYCURSOR; -#line 524 "../src/ast/lex.re" +#line 516 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2588 "src/ast/lex.cc" +#line 2581 "src/ast/lex.cc" yy452: ++YYCURSOR; -#line 525 "../src/ast/lex.re" +#line 517 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2593 "src/ast/lex.cc" +#line 2586 "src/ast/lex.cc" yy454: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2652,9 +2645,9 @@ yy459: } yy460: ++YYCURSOR; -#line 518 "../src/ast/lex.re" +#line 510 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2658 "src/ast/lex.cc" +#line 2651 "src/ast/lex.cc" yy462: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2681,9 +2674,9 @@ yy463: } yy464: ++YYCURSOR; -#line 517 "../src/ast/lex.re" +#line 509 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2687 "src/ast/lex.cc" +#line 2680 "src/ast/lex.cc" yy466: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2707,7 +2700,7 @@ yy467: goto yy456; } } -#line 533 "../src/ast/lex.re" +#line 525 "../src/ast/lex.re" } @@ -2727,7 +2720,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2731 "src/ast/lex.cc" +#line 2724 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2785,27 +2778,27 @@ sourceline: } } ++YYCURSOR; -#line 570 "../src/ast/lex.re" +#line 562 "../src/ast/lex.re" { --cur; tok = cur; return; } -#line 2795 "src/ast/lex.cc" +#line 2788 "src/ast/lex.cc" yy472: ++YYCURSOR; yy473: -#line 576 "../src/ast/lex.re" +#line 568 "../src/ast/lex.re" { goto sourceline; } -#line 2801 "src/ast/lex.cc" +#line 2794 "src/ast/lex.cc" yy474: ++YYCURSOR; -#line 565 "../src/ast/lex.re" +#line 557 "../src/ast/lex.re" { tok = cur; return; } -#line 2809 "src/ast/lex.cc" +#line 2802 "src/ast/lex.cc" yy476: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy474; @@ -2822,14 +2815,14 @@ yy478: if (yybm[0+yych] & 64) { goto yy478; } -#line 552 "../src/ast/lex.re" +#line 544 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { fatal_lc(get_cline(), get_column(), "line number overflow"); } goto sourceline; } -#line 2833 "src/ast/lex.cc" +#line 2826 "src/ast/lex.cc" yy481: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2846,13 +2839,13 @@ yy483: goto yy473; yy484: ++YYCURSOR; -#line 559 "../src/ast/lex.re" +#line 551 "../src/ast/lex.re" { in.escaped_file_name = std::string (tok + 1, tok_len () - 2); // strip quotes strrreplace (in.escaped_file_name, "\\", "\\\\"); goto sourceline; } -#line 2856 "src/ast/lex.cc" +#line 2849 "src/ast/lex.cc" yy486: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2861,7 +2854,7 @@ yy486: if (yych == '\n') goto yy483; goto yy481; } -#line 577 "../src/ast/lex.re" +#line 569 "../src/ast/lex.re" } diff --git a/re2c/src/ast/lex.re b/re2c/src/ast/lex.re index 72439ba3..3fac34cd 100644 --- a/re2c/src/ast/lex.re +++ b/re2c/src/ast/lex.re @@ -206,11 +206,7 @@ scan: "//" { lex_cpp_comment(); goto scan; } "/*" { lex_c_comment(); goto scan; } - endRE = "%}" | "*/"; - endRE { - tok = cur; - return 0; - } + "%}" | "*""/" { tok = cur; return 0; } "'" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; } "\"" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; } @@ -225,94 +221,89 @@ scan: [*+?<>!,()|=;/\\] { return *tok; } - "{" [0-9]+ "}" { - if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) - { - fatal_lc(get_cline(), get_column(), "repetition count overflow"); - } - yylval.bounds.max = yylval.bounds.min; - return TOKEN_CLOSESIZE; - } - - "{" [0-9]+ "," [0-9]+ "}" { - const char * p = strchr (tok, ','); - if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) - { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); - } - if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max)) - { - fatal_lc(get_cline(), get_column(), "repetition upper bound overflow"); - } - return TOKEN_CLOSESIZE; - } - - "{" [0-9]+ ",}" { - if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) - { - fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); - } - yylval.bounds.max = std::numeric_limits::max(); - return TOKEN_CLOSESIZE; - } - - "{" [0-9]* "," { - fatal_lc(get_cline(), get_column(), "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); - } - - "{" name "}" { - if (!globopts->FFlag) { - fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch"); - } - yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces - return TOKEN_ID; - } + "{" [0-9]+ "}" { + if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { + fatal_lc(get_cline(), get_column(), "repetition count overflow"); + } + yylval.bounds.max = yylval.bounds.min; + return TOKEN_CLOSESIZE; + } + + "{" [0-9]+ "," [0-9]+ "}" { + const char * p = strchr (tok, ','); + if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) { + fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + } + if (!s_to_u32_unsafe (p + 1, cur - 1, yylval.bounds.max)) { + fatal_lc(get_cline(), get_column(), "repetition upper bound overflow"); + } + return TOKEN_CLOSESIZE; + } + + "{" [0-9]+ ",}" { + if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { + fatal_lc(get_cline(), get_column(), "repetition lower bound overflow"); + } + yylval.bounds.max = std::numeric_limits::max(); + return TOKEN_CLOSESIZE; + } + + "{" [0-9]* "," { + fatal_lc(get_cline(), get_column(), + "illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); + } + + "{" name "}" { + if (!globopts->FFlag) { + fatal_lc(get_cline(), get_column(), + "curly braces for names only allowed with -F switch"); + } + yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces + return TOKEN_ID; + } "re2c:" { return TOKEN_CONF; } - name / (space+ [^=>,]) { - yylval.str = new std::string (tok, tok_len ()); - if (globopts->FFlag) - { - lexer_state = LEX_FLEX_NAME; - return TOKEN_FID; - } - else - { - return TOKEN_ID; - } - } - - name / (space* [=>,]) { - yylval.str = new std::string (tok, tok_len ()); - return TOKEN_ID; - } - - name / [^] { - if (!globopts->FFlag) { - yylval.str = new std::string (tok, tok_len()); - return TOKEN_ID; - } else { - std::vector *str = new std::vector; - for (char *s = tok; s < cur; ++s) { - const uint32_t - chr = static_cast(*s), - col = static_cast(s - tok); - str->push_back(ASTChar(chr, col)); - } - yylval.regexp = ast_str(cline, get_column(), str, false); - return TOKEN_REGEXP; - } - } - - "." { - yylval.regexp = ast_dot(cline, get_column()); - return TOKEN_REGEXP; - } - - space+ { - goto scan; - } + name / (space+ [^=>,]) { + yylval.str = new std::string (tok, tok_len ()); + if (globopts->FFlag) { + lexer_state = LEX_FLEX_NAME; + return TOKEN_FID; + } + else { + return TOKEN_ID; + } + } + + name / (space* [=>,]) { + yylval.str = new std::string (tok, tok_len ()); + return TOKEN_ID; + } + + name / [^] { + if (!globopts->FFlag) { + yylval.str = new std::string (tok, tok_len()); + return TOKEN_ID; + } + else { + std::vector *str = new std::vector; + for (char *s = tok; s < cur; ++s) { + const uint32_t + chr = static_cast(*s), + col = static_cast(s - tok); + str->push_back(ASTChar(chr, col)); + } + yylval.regexp = ast_str(cline, get_column(), str, false); + return TOKEN_REGEXP; + } + } + + "." { + yylval.regexp = ast_dot(cline, get_column()); + return TOKEN_REGEXP; + } + + space+ { goto scan; } eol space* "#" space* "line" space+ / lineinf { set_sourceline (); @@ -326,15 +317,16 @@ scan: if (lexer_state == LEX_FLEX_NAME) { lexer_state = LEX_NORMAL; return TOKEN_FID_END; - } else { + } + else { goto scan; } } - * { - fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); - goto scan; - } + * { + fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); + goto scan; + } */ } -- 2.40.0