From b237daed2095c1e138761fb94a01d53ba2c80c95 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 28 Nov 2015 18:11:58 +0000 Subject: [PATCH] Get rid of UINT32_MAX and friends UINT32_MAX is conditionally defined only for C compiler on FreeBSD but not for C++, Stop using __STDC_LIMIT_MACROS workaround as it does not work on FreeBSD. Use std::numeric_limits<> from C++98 instead. Signed-off-by: Sergei Trofimovich --- re2c/bootstrap/src/parse/lex.cc | 457 +++++++++++++------------- re2c/bootstrap/src/parse/parser.cc | 13 +- re2c/src/codegen/skeleton/maxlen.cc | 6 +- re2c/src/codegen/skeleton/skeleton.cc | 17 +- re2c/src/ir/rule_rank.cc | 3 +- re2c/src/parse/lex.re | 3 +- re2c/src/parse/parser.ypp | 3 +- re2c/src/test/s_to_n32_unsafe/test.cc | 16 +- re2c/src/util/s_to_n32_unsafe.cc | 8 +- 9 files changed, 270 insertions(+), 256 deletions(-) diff --git a/re2c/bootstrap/src/parse/lex.cc b/re2c/bootstrap/src/parse/lex.cc index 634a68ba..a9e5b785 100644 --- a/re2c/bootstrap/src/parse/lex.cc +++ b/re2c/bootstrap/src/parse/lex.cc @@ -1,8 +1,9 @@ -/* Generated by re2c 0.15.2 on Sat Nov 28 10:47:09 2015*/ +/* Generated by re2c 0.15.2 on Sat Nov 28 18:04:39 2015*/ #line 1 "../src/parse/lex.re" #include #include #include +#include #include #include "src/ir/dfa/dfa.h" @@ -30,10 +31,10 @@ namespace re2c // source code is in ASCII: pointers have type 'char *' // but re2c makes an implicit assumption that YYCTYPE is unsigned // when it generates comparisons -#line 33 "../src/parse/lex.re" +#line 34 "../src/parse/lex.re" -#line 53 "../src/parse/lex.re" +#line 54 "../src/parse/lex.re" Scanner::ParseMode Scanner::echo() @@ -49,7 +50,7 @@ Scanner::ParseMode Scanner::echo() tok = cur; echo: -#line 53 "src/parse/lex.cc" +#line 54 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -107,7 +108,7 @@ echo: } } ++YYCURSOR; -#line 193 "../src/parse/lex.re" +#line 194 "../src/parse/lex.re" { if (!ignore_eoc && opts->target == opt_t::CODE) { @@ -119,15 +120,15 @@ echo: return Stop; } } -#line 123 "src/parse/lex.cc" +#line 124 "src/parse/lex.cc" yy4: ++YYCURSOR; yy5: -#line 204 "../src/parse/lex.re" +#line 205 "../src/parse/lex.re" { goto echo; } -#line 131 "src/parse/lex.cc" +#line 132 "src/parse/lex.cc" yy6: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -136,7 +137,7 @@ yy6: } if (yych == '#') goto yy91; yy7: -#line 180 "../src/parse/lex.re" +#line 181 "../src/parse/lex.re" { if (ignore_eoc) { @@ -150,7 +151,7 @@ yy7: cline++; goto echo; } -#line 154 "src/parse/lex.cc" +#line 155 "src/parse/lex.cc" yy8: yych = (YYCTYPE)*++YYCURSOR; if (yych == '{') goto yy32; @@ -234,7 +235,7 @@ yy21: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; ++YYCURSOR; -#line 84 "../src/parse/lex.re" +#line 85 "../src/parse/lex.re" { if (opts->rFlag) { @@ -247,13 +248,13 @@ yy21: tok = cur; return Rules; } -#line 251 "src/parse/lex.cc" +#line 252 "src/parse/lex.cc" yy31: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; yy32: ++YYCURSOR; -#line 69 "../src/parse/lex.re" +#line 70 "../src/parse/lex.re" { if (opts->rFlag) { @@ -269,7 +270,7 @@ yy32: tok = cur; return Parse; } -#line 273 "src/parse/lex.cc" +#line 274 "src/parse/lex.cc" yy34: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'e') goto yy12; @@ -284,7 +285,7 @@ yy34: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; ++YYCURSOR; -#line 96 "../src/parse/lex.re" +#line 97 "../src/parse/lex.re" { if (!opts->rFlag) { @@ -299,7 +300,7 @@ yy34: tok = cur; return Reuse; } -#line 303 "src/parse/lex.cc" +#line 304 "src/parse/lex.cc" yy42: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'x') goto yy12; @@ -314,7 +315,7 @@ yy42: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; ++YYCURSOR; -#line 110 "../src/parse/lex.re" +#line 111 "../src/parse/lex.re" { if (opts->target != opt_t::DOT) { @@ -324,7 +325,7 @@ yy42: ignore_eoc = true; goto echo; } -#line 328 "src/parse/lex.cc" +#line 329 "src/parse/lex.cc" yy50: yych = (YYCTYPE)*++YYCURSOR; if (yych != 't') goto yy12; @@ -349,14 +350,14 @@ yy50: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; ++YYCURSOR; -#line 119 "../src/parse/lex.re" +#line 120 "../src/parse/lex.re" { tok = pos = cur; out.wdelay_state_goto (opts->topIndent); ignore_eoc = true; goto echo; } -#line 360 "src/parse/lex.cc" +#line 361 "src/parse/lex.cc" yy63: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'n') goto yy12; @@ -377,13 +378,13 @@ yy63: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; ++YYCURSOR; -#line 125 "../src/parse/lex.re" +#line 126 "../src/parse/lex.re" { tok = pos = cur; ignore_eoc = true; goto echo; } -#line 387 "src/parse/lex.cc" +#line 388 "src/parse/lex.cc" yy74: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'p') goto yy12; @@ -402,7 +403,7 @@ yy74: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy12; ++YYCURSOR; -#line 130 "../src/parse/lex.re" +#line 131 "../src/parse/lex.re" { tok = pos = cur; ignore_eoc = true; @@ -414,14 +415,14 @@ yy74: } goto echo; } -#line 418 "src/parse/lex.cc" +#line 419 "src/parse/lex.cc" yy84: yyaccept = 2; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych == '\n') goto yy87; if (yych == '\r') goto yy86; yy85: -#line 159 "../src/parse/lex.re" +#line 160 "../src/parse/lex.re" { if (ignore_eoc) { @@ -439,13 +440,13 @@ yy85: tok = pos = cur; goto echo; } -#line 443 "src/parse/lex.cc" +#line 444 "src/parse/lex.cc" yy86: yych = (YYCTYPE)*++YYCURSOR; if (yych != '\n') goto yy12; yy87: ++YYCURSOR; -#line 141 "../src/parse/lex.re" +#line 142 "../src/parse/lex.re" { cline++; if (ignore_eoc) @@ -464,7 +465,7 @@ yy87: tok = pos = cur; goto echo; } -#line 468 "src/parse/lex.cc" +#line 469 "src/parse/lex.cc" yy89: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -539,12 +540,12 @@ yy101: yy103: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 176 "../src/parse/lex.re" +#line 177 "../src/parse/lex.re" { set_sourceline (); goto echo; } -#line 548 "src/parse/lex.cc" +#line 549 "src/parse/lex.cc" yy105: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy103; @@ -569,7 +570,7 @@ yy109: if (yych == '\r') goto yy105; goto yy12; } -#line 207 "../src/parse/lex.re" +#line 208 "../src/parse/lex.re" } @@ -589,7 +590,7 @@ scan: start: -#line 593 "src/parse/lex.cc" +#line 594 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -704,22 +705,22 @@ start: yy112: ++YYCURSOR; yy113: -#line 379 "../src/parse/lex.re" +#line 380 "../src/parse/lex.re" { fatalf("unexpected character: '%c'", *tok); goto scan; } -#line 713 "src/parse/lex.cc" +#line 714 "src/parse/lex.cc" yy114: ++YYCURSOR; yych = (YYCTYPE)*YYCURSOR; goto yy220; yy115: -#line 363 "../src/parse/lex.re" +#line 364 "../src/parse/lex.re" { goto scan; } -#line 723 "src/parse/lex.cc" +#line 724 "src/parse/lex.cc" yy116: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -730,65 +731,65 @@ yy116: if (yych == '#') goto yy200; } yy117: -#line 372 "../src/parse/lex.re" +#line 373 "../src/parse/lex.re" { if (cur == eof) return 0; pos = cur; cline++; goto scan; } -#line 741 "src/parse/lex.cc" +#line 742 "src/parse/lex.cc" yy118: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy197; goto yy113; yy119: ++YYCURSOR; -#line 256 "../src/parse/lex.re" +#line 257 "../src/parse/lex.re" { yylval.regexp = lex_str('"', opts->bCaseInsensitive || opts->bCaseInverted); return REGEXP; } -#line 750 "src/parse/lex.cc" +#line 751 "src/parse/lex.cc" yy121: yych = (YYCTYPE)*++YYCURSOR; if (yych == '}') goto yy195; goto yy113; yy122: ++YYCURSOR; -#line 255 "../src/parse/lex.re" +#line 256 "../src/parse/lex.re" { yylval.regexp = lex_str('\'', opts->bCaseInsensitive || !opts->bCaseInverted); return REGEXP; } -#line 759 "src/parse/lex.cc" +#line 760 "src/parse/lex.cc" yy124: ++YYCURSOR; yy125: -#line 266 "../src/parse/lex.re" +#line 267 "../src/parse/lex.re" { return *tok; } -#line 767 "src/parse/lex.cc" +#line 768 "src/parse/lex.cc" yy126: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '/') goto yy195; -#line 270 "../src/parse/lex.re" +#line 271 "../src/parse/lex.re" { yylval.op = *tok; return STAR; } -#line 776 "src/parse/lex.cc" +#line 777 "src/parse/lex.cc" yy128: ++YYCURSOR; -#line 274 "../src/parse/lex.re" +#line 275 "../src/parse/lex.re" { yylval.op = *tok; return CLOSE; } -#line 784 "src/parse/lex.cc" +#line 785 "src/parse/lex.cc" yy130: ++YYCURSOR; -#line 358 "../src/parse/lex.re" +#line 359 "../src/parse/lex.re" { yylval.regexp = mkDot(); return REGEXP; } -#line 792 "src/parse/lex.cc" +#line 793 "src/parse/lex.cc" yy132: yych = (YYCTYPE)*++YYCURSOR; if (yych == '*') goto yy191; @@ -812,9 +813,9 @@ yy135: yy136: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '^') goto yy176; -#line 257 "../src/parse/lex.re" +#line 258 "../src/parse/lex.re" { yylval.regexp = lex_cls(false); return REGEXP; } -#line 818 "src/parse/lex.cc" +#line 819 "src/parse/lex.cc" yy138: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -838,12 +839,12 @@ yy139: } } yy140: -#line 226 "../src/parse/lex.re" +#line 227 "../src/parse/lex.re" { depth = 1; goto code; } -#line 847 "src/parse/lex.cc" +#line 848 "src/parse/lex.cc" yy141: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -892,14 +893,14 @@ yy144: yy146: ++YYCURSOR; yy147: -#line 310 "../src/parse/lex.re" +#line 311 "../src/parse/lex.re" { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 900 "src/parse/lex.cc" +#line 901 "src/parse/lex.cc" yy148: ++YYCURSOR; -#line 314 "../src/parse/lex.re" +#line 315 "../src/parse/lex.re" { if (!opts->FFlag) { fatal("curly braces for names only allowed with -F switch"); @@ -907,10 +908,10 @@ yy148: yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return ID; } -#line 911 "src/parse/lex.cc" +#line 912 "src/parse/lex.cc" yy150: ++YYCURSOR; -#line 279 "../src/parse/lex.re" +#line 280 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.extop.min)) { @@ -919,7 +920,7 @@ yy150: yylval.extop.max = yylval.extop.min; return CLOSESIZE; } -#line 923 "src/parse/lex.cc" +#line 924 "src/parse/lex.cc" yy152: yyaccept = 3; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -927,16 +928,16 @@ yy152: if (yych <= '9') goto yy155; if (yych != '}') goto yy147; ++YYCURSOR; -#line 301 "../src/parse/lex.re" +#line 302 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.extop.min)) { fatal ("repetition lower bound overflow"); } - yylval.extop.max = UINT32_MAX; + yylval.extop.max = std::numeric_limits::max(); return CLOSESIZE; } -#line 940 "src/parse/lex.cc" +#line 941 "src/parse/lex.cc" yy155: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -945,7 +946,7 @@ yy155: if (yych <= '9') goto yy155; if (yych != '}') goto yy143; ++YYCURSOR; -#line 288 "../src/parse/lex.re" +#line 289 "../src/parse/lex.re" { const char * p = strchr (tok, ','); if (!s_to_u32_unsafe (tok + 1, p, yylval.extop.min)) @@ -958,11 +959,11 @@ yy155: } return CLOSESIZE; } -#line 962 "src/parse/lex.cc" +#line 963 "src/parse/lex.cc" yy159: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 342 "../src/parse/lex.re" +#line 343 "../src/parse/lex.re" { if (!opts->FFlag) { yylval.str = new std::string (tok, tok_len()); @@ -978,7 +979,7 @@ yy159: return REGEXP; } } -#line 982 "src/parse/lex.cc" +#line 983 "src/parse/lex.cc" yy161: yych = (YYCTYPE)*++YYCURSOR; goto yy174; @@ -986,12 +987,12 @@ yy162: ++YYCURSOR; yy163: YYCURSOR = YYCTXMARKER; -#line 337 "../src/parse/lex.re" +#line 338 "../src/parse/lex.re" { yylval.str = new std::string (tok, tok_len ()); return ID; } -#line 995 "src/parse/lex.cc" +#line 996 "src/parse/lex.cc" yy164: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1036,13 +1037,13 @@ yy166: YYCTXMARKER = YYCURSOR; if (yych != ':') goto yy165; ++YYCURSOR; -#line 322 "../src/parse/lex.re" +#line 323 "../src/parse/lex.re" { lex_conf (); return CONF; } -#line 1042 "src/parse/lex.cc" +#line 1043 "src/parse/lex.cc" yy171: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 324 "../src/parse/lex.re" +#line 325 "../src/parse/lex.re" { yylval.str = new std::string (tok, tok_len ()); if (opts->FFlag) @@ -1055,7 +1056,7 @@ yy171: return ID; } } -#line 1059 "src/parse/lex.cc" +#line 1060 "src/parse/lex.cc" yy173: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1072,16 +1073,16 @@ yy175: goto yy163; yy176: ++YYCURSOR; -#line 258 "../src/parse/lex.re" +#line 259 "../src/parse/lex.re" { yylval.regexp = lex_cls(true); return REGEXP; } -#line 1078 "src/parse/lex.cc" +#line 1079 "src/parse/lex.cc" yy178: ++YYCURSOR; -#line 263 "../src/parse/lex.re" +#line 264 "../src/parse/lex.re" { return SETUP; } -#line 1085 "src/parse/lex.cc" +#line 1086 "src/parse/lex.cc" yy180: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -1111,11 +1112,11 @@ yy182: yy183: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 260 "../src/parse/lex.re" +#line 261 "../src/parse/lex.re" { return NOCOND; } -#line 1119 "src/parse/lex.cc" +#line 1120 "src/parse/lex.cc" yy185: yych = (YYCTYPE)*++YYCURSOR; if (yych == '>') goto yy183; @@ -1127,44 +1128,44 @@ yy186: yy187: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) == '>') goto yy189; -#line 235 "../src/parse/lex.re" +#line 236 "../src/parse/lex.re" { tok += 2; /* skip ":=" */ depth = 0; goto code; } -#line 1137 "src/parse/lex.cc" +#line 1138 "src/parse/lex.cc" yy189: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 231 "../src/parse/lex.re" +#line 232 "../src/parse/lex.re" { return *tok; } -#line 1145 "src/parse/lex.cc" +#line 1146 "src/parse/lex.cc" yy191: ++YYCURSOR; -#line 244 "../src/parse/lex.re" +#line 245 "../src/parse/lex.re" { depth = 1; goto comment; } -#line 1153 "src/parse/lex.cc" +#line 1154 "src/parse/lex.cc" yy193: ++YYCURSOR; -#line 241 "../src/parse/lex.re" +#line 242 "../src/parse/lex.re" { goto nextLine; } -#line 1160 "src/parse/lex.cc" +#line 1161 "src/parse/lex.cc" yy195: ++YYCURSOR; -#line 250 "../src/parse/lex.re" +#line 251 "../src/parse/lex.re" { tok = cur; return 0; } -#line 1168 "src/parse/lex.cc" +#line 1169 "src/parse/lex.cc" yy197: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1257,12 +1258,12 @@ yy210: yy212: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 367 "../src/parse/lex.re" +#line 368 "../src/parse/lex.re" { set_sourceline (); goto scan; } -#line 1266 "src/parse/lex.cc" +#line 1267 "src/parse/lex.cc" yy214: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy212; @@ -1295,12 +1296,12 @@ yy220: if (yych == ' ') goto yy219; goto yy115; } -#line 383 "../src/parse/lex.re" +#line 384 "../src/parse/lex.re" flex_name: -#line 1304 "src/parse/lex.cc" +#line 1305 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1309,22 +1310,22 @@ flex_name: if (yych == '\r') goto yy227; ++YYCURSOR; yy224: -#line 394 "../src/parse/lex.re" +#line 395 "../src/parse/lex.re" { YYCURSOR = tok; goto start; } -#line 1318 "src/parse/lex.cc" +#line 1319 "src/parse/lex.cc" yy225: ++YYCURSOR; yy226: -#line 388 "../src/parse/lex.re" +#line 389 "../src/parse/lex.re" { YYCURSOR = tok; lexer_state = LEX_NORMAL; return FID_END; } -#line 1328 "src/parse/lex.cc" +#line 1329 "src/parse/lex.cc" yy227: yych = (YYCTYPE)*++YYCURSOR; if (yych != '\n') goto yy224; @@ -1332,12 +1333,12 @@ yy227: yych = (YYCTYPE)*YYCURSOR; goto yy226; } -#line 398 "../src/parse/lex.re" +#line 399 "../src/parse/lex.re" code: -#line 1341 "src/parse/lex.cc" +#line 1342 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1398,7 +1399,7 @@ code: } yy231: ++YYCURSOR; -#line 461 "../src/parse/lex.re" +#line 462 "../src/parse/lex.re" { if (cur == eof) { @@ -1410,15 +1411,15 @@ yy231: } goto code; } -#line 1414 "src/parse/lex.cc" +#line 1415 "src/parse/lex.cc" yy233: ++YYCURSOR; yy234: -#line 475 "../src/parse/lex.re" +#line 476 "../src/parse/lex.re" { goto code; } -#line 1422 "src/parse/lex.cc" +#line 1423 "src/parse/lex.cc" yy235: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1438,7 +1439,7 @@ yy235: } } yy236: -#line 442 "../src/parse/lex.re" +#line 443 "../src/parse/lex.re" { if (depth == 0) { @@ -1458,7 +1459,7 @@ yy236: cline++; goto code; } -#line 1462 "src/parse/lex.cc" +#line 1463 "src/parse/lex.cc" yy237: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -1471,7 +1472,7 @@ yy238: goto yy244; yy239: ++YYCURSOR; -#line 414 "../src/parse/lex.re" +#line 415 "../src/parse/lex.re" { if (depth == 0) { @@ -1483,10 +1484,10 @@ yy239: } goto code; } -#line 1487 "src/parse/lex.cc" +#line 1488 "src/parse/lex.cc" yy241: ++YYCURSOR; -#line 402 "../src/parse/lex.re" +#line 403 "../src/parse/lex.re" { if (depth == 0) { @@ -1499,7 +1500,7 @@ yy241: } goto code; } -#line 1503 "src/parse/lex.cc" +#line 1504 "src/parse/lex.cc" yy243: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1530,11 +1531,11 @@ yy246: goto yy243; yy247: ++YYCURSOR; -#line 472 "../src/parse/lex.re" +#line 473 "../src/parse/lex.re" { goto code; } -#line 1538 "src/parse/lex.cc" +#line 1539 "src/parse/lex.cc" yy249: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1561,7 +1562,7 @@ yy252: } yy253: YYCURSOR = YYCTXMARKER; -#line 429 "../src/parse/lex.re" +#line 430 "../src/parse/lex.re" { if (depth == 0) { @@ -1575,7 +1576,7 @@ yy253: cline++; goto code; } -#line 1579 "src/parse/lex.cc" +#line 1580 "src/parse/lex.cc" yy254: yych = (YYCTYPE)*++YYCURSOR; goto yy253; @@ -1642,12 +1643,12 @@ yy265: yy267: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 425 "../src/parse/lex.re" +#line 426 "../src/parse/lex.re" { set_sourceline (); goto code; } -#line 1651 "src/parse/lex.cc" +#line 1652 "src/parse/lex.cc" yy269: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy267; @@ -1686,12 +1687,12 @@ yy274: goto yy245; } } -#line 478 "../src/parse/lex.re" +#line 479 "../src/parse/lex.re" comment: -#line 1695 "src/parse/lex.cc" +#line 1696 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -1738,7 +1739,7 @@ comment: } ++YYCURSOR; yy279: -#line 510 "../src/parse/lex.re" +#line 511 "../src/parse/lex.re" { if (cur == eof) { @@ -1746,7 +1747,7 @@ yy279: } goto comment; } -#line 1750 "src/parse/lex.cc" +#line 1751 "src/parse/lex.cc" yy280: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 32) { @@ -1754,7 +1755,7 @@ yy280: } if (yych == '#') goto yy291; yy281: -#line 501 "../src/parse/lex.re" +#line 502 "../src/parse/lex.re" { if (cur == eof) { @@ -1764,7 +1765,7 @@ yy281: cline++; goto comment; } -#line 1768 "src/parse/lex.cc" +#line 1769 "src/parse/lex.cc" yy282: yych = (YYCTYPE)*++YYCURSOR; if (yych == '/') goto yy286; @@ -1773,16 +1774,16 @@ yy283: yych = (YYCTYPE)*++YYCURSOR; if (yych != '*') goto yy279; ++YYCURSOR; -#line 492 "../src/parse/lex.re" +#line 493 "../src/parse/lex.re" { ++depth; fatal("ambiguous /* found"); goto comment; } -#line 1783 "src/parse/lex.cc" +#line 1784 "src/parse/lex.cc" yy286: ++YYCURSOR; -#line 482 "../src/parse/lex.re" +#line 483 "../src/parse/lex.re" { if (--depth == 0) { @@ -1793,7 +1794,7 @@ yy286: goto comment; } } -#line 1797 "src/parse/lex.cc" +#line 1798 "src/parse/lex.cc" yy288: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1871,12 +1872,12 @@ yy301: yy303: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 497 "../src/parse/lex.re" +#line 498 "../src/parse/lex.re" { set_sourceline (); goto comment; } -#line 1880 "src/parse/lex.cc" +#line 1881 "src/parse/lex.cc" yy305: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy303; @@ -1901,28 +1902,28 @@ yy309: if (yych == '\r') goto yy305; goto yy290; } -#line 517 "../src/parse/lex.re" +#line 518 "../src/parse/lex.re" nextLine: -#line 1910 "src/parse/lex.cc" +#line 1911 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == '\n') goto yy314; ++YYCURSOR; -#line 528 "../src/parse/lex.re" +#line 529 "../src/parse/lex.re" { if(cur == eof) { return 0; } goto nextLine; } -#line 1923 "src/parse/lex.cc" +#line 1924 "src/parse/lex.cc" yy314: ++YYCURSOR; -#line 521 "../src/parse/lex.re" +#line 522 "../src/parse/lex.re" { if(cur == eof) { return 0; } @@ -1930,9 +1931,9 @@ yy314: cline++; goto scan; } -#line 1934 "src/parse/lex.cc" +#line 1935 "src/parse/lex.cc" } -#line 533 "../src/parse/lex.re" +#line 534 "../src/parse/lex.re" } @@ -1956,35 +1957,35 @@ RegExp *Scanner::lex_cls(bool neg) uint32_t u, l; fst: -#line 1960 "src/parse/lex.cc" +#line 1961 "src/parse/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych == ']') goto yy319; -#line 557 "../src/parse/lex.re" +#line 558 "../src/parse/lex.re" { l = lex_cls_chr(); goto snd; } -#line 1968 "src/parse/lex.cc" +#line 1969 "src/parse/lex.cc" yy319: ++YYCURSOR; -#line 556 "../src/parse/lex.re" +#line 557 "../src/parse/lex.re" { goto end; } -#line 1973 "src/parse/lex.cc" +#line 1974 "src/parse/lex.cc" } -#line 558 "../src/parse/lex.re" +#line 559 "../src/parse/lex.re" snd: -#line 1979 "src/parse/lex.cc" +#line 1980 "src/parse/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); if (yych == '-') goto yy324; yy323: -#line 561 "../src/parse/lex.re" +#line 562 "../src/parse/lex.re" { u = l; goto add; } -#line 1988 "src/parse/lex.cc" +#line 1989 "src/parse/lex.cc" yy324: yych = (YYCTYPE)*++YYCURSOR; YYCTXMARKER = YYCURSOR; @@ -1994,7 +1995,7 @@ yy324: yy326: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 562 "../src/parse/lex.re" +#line 563 "../src/parse/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2003,9 +2004,9 @@ yy326: } goto add; } -#line 2007 "src/parse/lex.cc" +#line 2008 "src/parse/lex.cc" } -#line 570 "../src/parse/lex.re" +#line 571 "../src/parse/lex.re" add: if (!(s = opts->encoding.encodeRange(l, u))) { @@ -2024,7 +2025,7 @@ uint32_t Scanner::lex_cls_chr() { tok = cur; -#line 2028 "src/parse/lex.cc" +#line 2029 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2033,14 +2034,14 @@ uint32_t Scanner::lex_cls_chr() if (yych == '\n') goto yy332; if (yych == '\\') goto yy334; ++YYCURSOR; -#line 593 "../src/parse/lex.re" +#line 594 "../src/parse/lex.re" { return static_cast(tok[0]); } -#line 2039 "src/parse/lex.cc" +#line 2040 "src/parse/lex.cc" yy332: ++YYCURSOR; -#line 588 "../src/parse/lex.re" +#line 589 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 2044 "src/parse/lex.cc" +#line 2045 "src/parse/lex.cc" yy334: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) <= '`') { @@ -2089,31 +2090,31 @@ yy334: } } } -#line 591 "../src/parse/lex.re" +#line 592 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 2095 "src/parse/lex.cc" +#line 2096 "src/parse/lex.cc" yy336: ++YYCURSOR; -#line 606 "../src/parse/lex.re" +#line 607 "../src/parse/lex.re" { warn.useless_escape(tline, tok - pos, tok[1]); return static_cast(tok[1]); } -#line 2103 "src/parse/lex.cc" +#line 2104 "src/parse/lex.cc" yy338: ++YYCURSOR; -#line 604 "../src/parse/lex.re" +#line 605 "../src/parse/lex.re" { return static_cast('-'); } -#line 2108 "src/parse/lex.cc" +#line 2109 "src/parse/lex.cc" yy340: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy341; if (yych <= '7') goto yy379; yy341: -#line 590 "../src/parse/lex.re" +#line 591 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 2117 "src/parse/lex.cc" +#line 2118 "src/parse/lex.cc" yy342: yych = (YYCTYPE)*++YYCURSOR; goto yy341; @@ -2129,9 +2130,9 @@ yy343: if (yych <= 'f') goto yy372; } yy344: -#line 589 "../src/parse/lex.re" +#line 590 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 2135 "src/parse/lex.cc" +#line 2136 "src/parse/lex.cc" yy345: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2147,49 +2148,49 @@ yy345: } yy346: ++YYCURSOR; -#line 603 "../src/parse/lex.re" +#line 604 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2153 "src/parse/lex.cc" +#line 2154 "src/parse/lex.cc" yy348: ++YYCURSOR; -#line 605 "../src/parse/lex.re" +#line 606 "../src/parse/lex.re" { return static_cast(']'); } -#line 2158 "src/parse/lex.cc" +#line 2159 "src/parse/lex.cc" yy350: ++YYCURSOR; -#line 596 "../src/parse/lex.re" +#line 597 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2163 "src/parse/lex.cc" +#line 2164 "src/parse/lex.cc" yy352: ++YYCURSOR; -#line 597 "../src/parse/lex.re" +#line 598 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2168 "src/parse/lex.cc" +#line 2169 "src/parse/lex.cc" yy354: ++YYCURSOR; -#line 598 "../src/parse/lex.re" +#line 599 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2173 "src/parse/lex.cc" +#line 2174 "src/parse/lex.cc" yy356: ++YYCURSOR; -#line 599 "../src/parse/lex.re" +#line 600 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2178 "src/parse/lex.cc" +#line 2179 "src/parse/lex.cc" yy358: ++YYCURSOR; -#line 600 "../src/parse/lex.re" +#line 601 "../src/parse/lex.re" { return static_cast('\r'); } -#line 2183 "src/parse/lex.cc" +#line 2184 "src/parse/lex.cc" yy360: ++YYCURSOR; -#line 601 "../src/parse/lex.re" +#line 602 "../src/parse/lex.re" { return static_cast('\t'); } -#line 2188 "src/parse/lex.cc" +#line 2189 "src/parse/lex.cc" yy362: ++YYCURSOR; -#line 602 "../src/parse/lex.re" +#line 603 "../src/parse/lex.re" { return static_cast('\v'); } -#line 2193 "src/parse/lex.cc" +#line 2194 "src/parse/lex.cc" yy364: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2220,9 +2221,9 @@ yy366: } yy367: ++YYCURSOR; -#line 594 "../src/parse/lex.re" +#line 595 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 2226 "src/parse/lex.cc" +#line 2227 "src/parse/lex.cc" yy369: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2332,11 +2333,11 @@ yy379: if (yych <= '/') goto yy366; if (yych >= '8') goto yy366; ++YYCURSOR; -#line 595 "../src/parse/lex.re" +#line 596 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 2338 "src/parse/lex.cc" +#line 2339 "src/parse/lex.cc" } -#line 610 "../src/parse/lex.re" +#line 611 "../src/parse/lex.re" } @@ -2345,7 +2346,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) end = false; tok = cur; -#line 2349 "src/parse/lex.cc" +#line 2350 "src/parse/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -2354,17 +2355,17 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) if (yych == '\n') goto yy386; if (yych == '\\') goto yy388; ++YYCURSOR; -#line 623 "../src/parse/lex.re" +#line 624 "../src/parse/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2363 "src/parse/lex.cc" +#line 2364 "src/parse/lex.cc" yy386: ++YYCURSOR; -#line 618 "../src/parse/lex.re" +#line 619 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error"); } -#line 2368 "src/parse/lex.cc" +#line 2369 "src/parse/lex.cc" yy388: ++YYCURSOR; if ((yych = (YYCTYPE)*YYCURSOR) <= 'a') { @@ -2410,28 +2411,28 @@ yy388: } } } -#line 621 "../src/parse/lex.re" +#line 622 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in escape sequence"); } -#line 2416 "src/parse/lex.cc" +#line 2417 "src/parse/lex.cc" yy390: ++YYCURSOR; -#line 637 "../src/parse/lex.re" +#line 638 "../src/parse/lex.re" { if (tok[1] != quote) { warn.useless_escape(tline, tok - pos, tok[1]); } return static_cast(tok[1]); } -#line 2426 "src/parse/lex.cc" +#line 2427 "src/parse/lex.cc" yy392: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy393; if (yych <= '7') goto yy429; yy393: -#line 620 "../src/parse/lex.re" +#line 621 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in octal escape sequence"); } -#line 2435 "src/parse/lex.cc" +#line 2436 "src/parse/lex.cc" yy394: yych = (YYCTYPE)*++YYCURSOR; goto yy393; @@ -2447,9 +2448,9 @@ yy395: if (yych <= 'f') goto yy422; } yy396: -#line 619 "../src/parse/lex.re" +#line 620 "../src/parse/lex.re" { fatal ((tok - pos) - tchar, "syntax error in hexadecimal escape sequence"); } -#line 2453 "src/parse/lex.cc" +#line 2454 "src/parse/lex.cc" yy397: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2465,44 +2466,44 @@ yy397: } yy398: ++YYCURSOR; -#line 636 "../src/parse/lex.re" +#line 637 "../src/parse/lex.re" { return static_cast('\\'); } -#line 2471 "src/parse/lex.cc" +#line 2472 "src/parse/lex.cc" yy400: ++YYCURSOR; -#line 629 "../src/parse/lex.re" +#line 630 "../src/parse/lex.re" { return static_cast('\a'); } -#line 2476 "src/parse/lex.cc" +#line 2477 "src/parse/lex.cc" yy402: ++YYCURSOR; -#line 630 "../src/parse/lex.re" +#line 631 "../src/parse/lex.re" { return static_cast('\b'); } -#line 2481 "src/parse/lex.cc" +#line 2482 "src/parse/lex.cc" yy404: ++YYCURSOR; -#line 631 "../src/parse/lex.re" +#line 632 "../src/parse/lex.re" { return static_cast('\f'); } -#line 2486 "src/parse/lex.cc" +#line 2487 "src/parse/lex.cc" yy406: ++YYCURSOR; -#line 632 "../src/parse/lex.re" +#line 633 "../src/parse/lex.re" { return static_cast('\n'); } -#line 2491 "src/parse/lex.cc" +#line 2492 "src/parse/lex.cc" yy408: ++YYCURSOR; -#line 633 "../src/parse/lex.re" +#line 634 "../src/parse/lex.re" { return static_cast('\r'); } -#line 2496 "src/parse/lex.cc" +#line 2497 "src/parse/lex.cc" yy410: ++YYCURSOR; -#line 634 "../src/parse/lex.re" +#line 635 "../src/parse/lex.re" { return static_cast('\t'); } -#line 2501 "src/parse/lex.cc" +#line 2502 "src/parse/lex.cc" yy412: ++YYCURSOR; -#line 635 "../src/parse/lex.re" +#line 636 "../src/parse/lex.re" { return static_cast('\v'); } -#line 2506 "src/parse/lex.cc" +#line 2507 "src/parse/lex.cc" yy414: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); @@ -2533,9 +2534,9 @@ yy416: } yy417: ++YYCURSOR; -#line 627 "../src/parse/lex.re" +#line 628 "../src/parse/lex.re" { return unesc_hex(tok, cur); } -#line 2539 "src/parse/lex.cc" +#line 2540 "src/parse/lex.cc" yy419: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { @@ -2645,11 +2646,11 @@ yy429: if (yych <= '/') goto yy416; if (yych >= '8') goto yy416; ++YYCURSOR; -#line 628 "../src/parse/lex.re" +#line 629 "../src/parse/lex.re" { return unesc_oct(tok, cur); } -#line 2651 "src/parse/lex.cc" +#line 2652 "src/parse/lex.cc" } -#line 643 "../src/parse/lex.re" +#line 644 "../src/parse/lex.re" } @@ -2670,7 +2671,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2674 "src/parse/lex.cc" +#line 2675 "src/parse/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2719,14 +2720,14 @@ sourceline: yy434: ++YYCURSOR; yy435: -#line 686 "../src/parse/lex.re" +#line 687 "../src/parse/lex.re" { goto sourceline; } -#line 2727 "src/parse/lex.cc" +#line 2728 "src/parse/lex.cc" yy436: ++YYCURSOR; -#line 674 "../src/parse/lex.re" +#line 675 "../src/parse/lex.re" { if (cur == eof) { @@ -2739,7 +2740,7 @@ yy436: tok = cur; return; } -#line 2743 "src/parse/lex.cc" +#line 2744 "src/parse/lex.cc" yy438: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych == '\n') goto yy435; @@ -2749,7 +2750,7 @@ yy439: yych = (YYCTYPE)*YYCURSOR; goto yy442; yy440: -#line 663 "../src/parse/lex.re" +#line 664 "../src/parse/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { @@ -2757,7 +2758,7 @@ yy440: } goto sourceline; } -#line 2761 "src/parse/lex.cc" +#line 2762 "src/parse/lex.cc" yy441: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -2789,14 +2790,14 @@ yy446: goto yy443; yy447: ++YYCURSOR; -#line 670 "../src/parse/lex.re" +#line 671 "../src/parse/lex.re" { escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes goto sourceline; } -#line 2798 "src/parse/lex.cc" +#line 2799 "src/parse/lex.cc" } -#line 689 "../src/parse/lex.re" +#line 690 "../src/parse/lex.re" } diff --git a/re2c/bootstrap/src/parse/parser.cc b/re2c/bootstrap/src/parse/parser.cc index 6318628b..0f1a5b9b 100644 --- a/re2c/bootstrap/src/parse/parser.cc +++ b/re2c/bootstrap/src/parse/parser.cc @@ -73,6 +73,7 @@ #include #include #include +#include #include #include "config.h" @@ -583,11 +584,11 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 183, 183, 185, 189, 193, 202, 211, 215, 219, - 223, 240, 258, 262, 268, 273, 279, 283, 298, 315, - 320, 326, 342, 360, 380, 386, 394, 397, 404, 410, - 420, 423, 431, 434, 441, 445, 452, 456, 463, 467, - 474, 478, 493, 513, 517, 521, 525, 532, 542, 546 + 0, 184, 184, 186, 190, 194, 203, 212, 216, 220, + 224, 241, 259, 263, 269, 274, 280, 284, 299, 316, + 321, 327, 343, 361, 381, 387, 395, 398, 405, 411, + 421, 424, 432, 435, 442, 446, 453, 457, 464, 468, + 475, 479, 494, 514, 518, 522, 526, 533, 543, 547 }; #endif @@ -1953,7 +1954,7 @@ yyreduce: { (yyvsp[(1) - (2)].regexp)->ins_access = RegExp::PRIVATE; - if ((yyvsp[(2) - (2)].extop).max == UINT32_MAX) + if ((yyvsp[(2) - (2)].extop).max == std::numeric_limits::max()) { (yyval.regexp) = repeat_from ((yyvsp[(1) - (2)].regexp), (yyvsp[(2) - (2)].extop).min); } diff --git a/re2c/src/codegen/skeleton/maxlen.cc b/re2c/src/codegen/skeleton/maxlen.cc index 9648d7da..a9d8041c 100644 --- a/re2c/src/codegen/skeleton/maxlen.cc +++ b/re2c/src/codegen/skeleton/maxlen.cc @@ -1,10 +1,12 @@ +#include + #include "src/codegen/skeleton/skeleton.h" namespace re2c { -// 0 < DIST_MAX < DIST_ERROR <= UINT32_MAX -const uint32_t Node::DIST_ERROR = UINT32_MAX; +// 0 < DIST_MAX < DIST_ERROR <= std::numeric_limits::max() +const uint32_t Node::DIST_ERROR = std::numeric_limits::max(); const uint32_t Node::DIST_MAX = DIST_ERROR - 1; // different from YYMAXFILL calculation diff --git a/re2c/src/codegen/skeleton/skeleton.cc b/re2c/src/codegen/skeleton/skeleton.cc index e60d837a..bd179ce2 100644 --- a/re2c/src/codegen/skeleton/skeleton.cc +++ b/re2c/src/codegen/skeleton/skeleton.cc @@ -1,3 +1,4 @@ +#include #include // exit #include "src/codegen/skeleton/skeleton.h" @@ -112,11 +113,11 @@ Skeleton::Skeleton (const DFA & dfa, const rules_t & rs) // initialize size of key const uint32_t max = std::max (maxlen, maxrule); - if (max <= UINT8_MAX) + if (max <= std::numeric_limits::max()) { sizeof_key = 1; } - else if (max <= UINT16_MAX) + else if (max <= std::numeric_limits::max()) { sizeof_key = 2; } @@ -127,13 +128,13 @@ Skeleton::~Skeleton () delete [] nodes; } -template <> uint32_t Skeleton::none () { return UINT32_MAX; } -template <> uint16_t Skeleton::none () { return UINT16_MAX; } -template <> uint8_t Skeleton::none () { return UINT8_MAX; } +template <> uint32_t Skeleton::none () { return std::numeric_limits::max(); } +template <> uint16_t Skeleton::none () { return std::numeric_limits::max(); } +template <> uint8_t Skeleton::none () { return std::numeric_limits::max(); } -template <> uint32_t Skeleton::def () { return UINT32_MAX - 1; } -template <> uint16_t Skeleton::def () { return UINT16_MAX - 1; } -template <> uint8_t Skeleton::def () { return UINT8_MAX - 1; } +template <> uint32_t Skeleton::def () { return std::numeric_limits::max() - 1; } +template <> uint16_t Skeleton::def () { return std::numeric_limits::max() - 1; } +template <> uint8_t Skeleton::def () { return std::numeric_limits::max() - 1; } uint32_t Skeleton::rule2key (rule_rank_t r) const { diff --git a/re2c/src/ir/rule_rank.cc b/re2c/src/ir/rule_rank.cc index 8e09ef97..12d2de88 100644 --- a/re2c/src/ir/rule_rank.cc +++ b/re2c/src/ir/rule_rank.cc @@ -1,4 +1,5 @@ #include +#include #include #include "src/ir/rule_rank.h" @@ -6,7 +7,7 @@ namespace re2c { -const uint32_t rule_rank_t::NONE = UINT32_MAX; +const uint32_t rule_rank_t::NONE = std::numeric_limits::max(); const uint32_t rule_rank_t::DEF = rule_rank_t::NONE - 1; rule_rank_t::rule_rank_t () diff --git a/re2c/src/parse/lex.re b/re2c/src/parse/lex.re index ccc24e98..9e4f0f5b 100644 --- a/re2c/src/parse/lex.re +++ b/re2c/src/parse/lex.re @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "src/ir/dfa/dfa.h" @@ -303,7 +304,7 @@ start: { fatal ("repetition lower bound overflow"); } - yylval.extop.max = UINT32_MAX; + yylval.extop.max = std::numeric_limits::max(); return CLOSESIZE; } diff --git a/re2c/src/parse/parser.ypp b/re2c/src/parse/parser.ypp index 590d9343..20e9ce99 100644 --- a/re2c/src/parse/parser.ypp +++ b/re2c/src/parse/parser.ypp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "config.h" @@ -493,7 +494,7 @@ factor: | primary CLOSESIZE { $1->ins_access = RegExp::PRIVATE; - if ($2.max == UINT32_MAX) + if ($2.max == std::numeric_limits::max()) { $$ = repeat_from ($1, $2.min); } diff --git a/re2c/src/test/s_to_n32_unsafe/test.cc b/re2c/src/test/s_to_n32_unsafe/test.cc index 44977beb..47b3d47d 100644 --- a/re2c/src/test/s_to_n32_unsafe/test.cc +++ b/re2c/src/test/s_to_n32_unsafe/test.cc @@ -1,3 +1,4 @@ +#include #include #include "src/util/s_to_n32_unsafe.h" @@ -64,15 +65,17 @@ static int32_t test () { ok |= test_u (i); } - // UINT32_MAX neighbourhood - for (uint64_t i = UINT32_MAX - UDELTA; i <= UINT32_MAX + UDELTA; ++i) + // u32_max neighbourhood + static const uint64_t u32_max = std::numeric_limits::max(); + for (uint64_t i = u32_max - UDELTA; i <= u32_max + UDELTA; ++i) { ok |= test_u (i); } static const int64_t IDELTA = 0xFFFF; - // INT32_MIN neighbourhood - for (int64_t i = INT32_MIN - IDELTA; i <= INT32_MIN + IDELTA; ++i) + // i32_min neighbourhood + static const int64_t i32_min = std::numeric_limits::min(); + for (int64_t i = i32_min - IDELTA; i <= i32_min + IDELTA; ++i) { ok |= test_i (i); } @@ -81,8 +84,9 @@ static int32_t test () { ok |= test_i (i); } - // INT32_MAX neighbourhood - for (int64_t i = INT32_MAX - IDELTA; i <= INT32_MAX + IDELTA; ++i) + // i32_max neighbourhood + static const int64_t i32_max = std::numeric_limits::max(); + for (int64_t i = i32_max - IDELTA; i <= i32_max + IDELTA; ++i) { ok |= test_i (i); } diff --git a/re2c/src/util/s_to_n32_unsafe.cc b/re2c/src/util/s_to_n32_unsafe.cc index 050547c2..fa7590b9 100644 --- a/re2c/src/util/s_to_n32_unsafe.cc +++ b/re2c/src/util/s_to_n32_unsafe.cc @@ -1,3 +1,5 @@ +#include + #include "src/util/s_to_n32_unsafe.h" // assumes that string matches regexp [0-9]+ @@ -9,7 +11,7 @@ bool s_to_u32_unsafe (const char * s, const char * s_end, uint32_t & number) { u *= 10; u += static_cast (*s) - 0x30; - if (u >= UINT32_MAX) + if (u >= std::numeric_limits::max()) { return false; } @@ -30,7 +32,7 @@ bool s_to_i32_unsafe (const char * s, const char * s_end, int32_t & number) { i *= 10; i -= *s - 0x30; - if (i < INT32_MIN) + if (i < std::numeric_limits::min()) { return false; } @@ -42,7 +44,7 @@ bool s_to_i32_unsafe (const char * s, const char * s_end, int32_t & number) { i *= 10; i += *s - 0x30; - if (i > INT32_MAX) + if (i > std::numeric_limits::max()) { return false; } -- 2.40.0