From 44737d3792dcdcf0fb2279e76f3ce7a1add21ea5 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 29 Oct 2018 23:00:50 +0000 Subject: [PATCH] Fixed out of bounds read in lexer. The error was caused by assuming that a sequence of zeroes (used for padding in YYFILL) cannot form a valid lexeme suffix. This is not the case with strings, as they may contain arbitrary characters. The fix is to manually loop over string characters in lexer, stopping at each zero to check if it's the end of input. Found by american fuzzy lop (thanks to Henri Salo). --- re2c/bootstrap/src/ast/lex.cc | 1757 +++++++++++++--------------- re2c/bootstrap/src/ast/lex_conf.cc | 2 +- re2c/src/ast/lex.re | 261 ++--- re2c/src/ast/scanner.h | 4 + re2c/test/american_fuzzy_lop/01.c | 1 + re2c/test/american_fuzzy_lop/01.re | 1 + 6 files changed, 916 insertions(+), 1110 deletions(-) create mode 100644 re2c/test/american_fuzzy_lop/01.c create mode 100644 re2c/test/american_fuzzy_lop/01.re diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 4d81f470..5d3e349f 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 Thu Aug 30 23:14:50 2018 */ +/* Generated by re2c 1.1.1 on Mon Oct 29 22:56:51 2018 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include @@ -22,11 +22,11 @@ extern YYSTYPE yylval; -#define YYCTYPE unsigned char -#define YYCURSOR cur -#define YYLIMIT lim -#define YYMARKER mar -#define YYCTXMARKER ctx +#define YYCTYPE unsigned char +#define YYCURSOR cur +#define YYLIMIT lim +#define YYMARKER mar +#define YYCTXMARKER ctx #define YYFILL(n) { fill (n); } namespace re2c @@ -58,7 +58,7 @@ echo: YYCTYPE yych; unsigned int yyaccept = 0; static const unsigned char yybm[] = { - 128, 128, 128, 128, 128, 128, 128, 128, + 0, 128, 128, 128, 128, 128, 128, 128, 128, 160, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, @@ -546,6 +546,7 @@ yy97: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; + if (yych <= 0x00) goto yy13; if (yych == '\n') goto yy13; goto yy85; yy98: @@ -565,7 +566,7 @@ yy100: lex_end_of_comment(out); goto echo; } -#line 569 "src/ast/lex.cc" +#line 570 "src/ast/lex.cc" yy102: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'h') goto yy111; @@ -593,7 +594,7 @@ yy107: out.wraw(tok, ptr); return Reuse; } -#line 597 "src/ast/lex.cc" +#line 598 "src/ast/lex.cc" yy109: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy116; @@ -642,7 +643,7 @@ yy119: lex_tags(out, true); goto echo; } -#line 646 "src/ast/lex.cc" +#line 647 "src/ast/lex.cc" yy121: ++YYCURSOR; #line 78 "../src/ast/lex.re" @@ -650,7 +651,7 @@ yy121: out.wraw(tok, ptr); return Rules; } -#line 654 "src/ast/lex.cc" +#line 655 "src/ast/lex.cc" yy123: ++YYCURSOR; #line 124 "../src/ast/lex.re" @@ -659,7 +660,7 @@ yy123: lex_tags(out, false); goto echo; } -#line 663 "src/ast/lex.cc" +#line 664 "src/ast/lex.cc" yy125: ++YYCURSOR; #line 115 "../src/ast/lex.re" @@ -671,7 +672,7 @@ yy125: lex_end_of_comment(out); goto echo; } -#line 675 "src/ast/lex.cc" +#line 676 "src/ast/lex.cc" yy127: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy131; @@ -684,7 +685,7 @@ yy128: lex_end_of_comment(out); goto echo; } -#line 688 "src/ast/lex.cc" +#line 689 "src/ast/lex.cc" yy130: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy132; @@ -706,7 +707,7 @@ yy133: lex_end_of_comment(out); goto echo; } -#line 710 "src/ast/lex.cc" +#line 711 "src/ast/lex.cc" yy135: yych = (YYCTYPE)*++YYCURSOR; if (yych != 'c') goto yy13; @@ -718,7 +719,7 @@ yy135: lex_end_of_comment(out); goto echo; } -#line 722 "src/ast/lex.cc" +#line 723 "src/ast/lex.cc" } #line 155 "../src/ast/lex.re" @@ -728,7 +729,7 @@ void Scanner::lex_end_of_comment(OutputFile &out) { uint32_t ignored = 0; for (;;) { -#line 732 "src/ast/lex.cc" +#line 733 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -746,18 +747,18 @@ yy140: ++YYCURSOR; #line 162 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "expected end of block"); } -#line 750 "src/ast/lex.cc" +#line 751 "src/ast/lex.cc" yy142: ++YYCURSOR; yy143: #line 164 "../src/ast/lex.re" { continue; } -#line 756 "src/ast/lex.cc" +#line 757 "src/ast/lex.cc" yy144: ++YYCURSOR; #line 165 "../src/ast/lex.re" { ++ignored; continue; } -#line 761 "src/ast/lex.cc" +#line 762 "src/ast/lex.cc" yy146: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy144; @@ -775,7 +776,7 @@ yy147: tok = pos = cur; return; } -#line 779 "src/ast/lex.cc" +#line 780 "src/ast/lex.cc" } #line 174 "../src/ast/lex.re" } @@ -785,7 +786,7 @@ void Scanner::lex_tags(OutputFile &out, bool mtags) { std::string fmt, sep; for (;;) { -#line 789 "src/ast/lex.cc" +#line 790 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -845,7 +846,7 @@ void Scanner::lex_tags(OutputFile &out, bool mtags) yy153: #line 181 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "unrecognized configuration"); } -#line 849 "src/ast/lex.cc" +#line 850 "src/ast/lex.cc" yy154: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -855,12 +856,12 @@ yy154: } #line 186 "../src/ast/lex.re" { continue; } -#line 859 "src/ast/lex.cc" +#line 860 "src/ast/lex.cc" yy157: ++YYCURSOR; #line 187 "../src/ast/lex.re" { ++cline; continue; } -#line 864 "src/ast/lex.cc" +#line 865 "src/ast/lex.cc" yy159: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy157; @@ -885,7 +886,7 @@ yy163: tok = pos = cur; return; } -#line 889 "src/ast/lex.cc" +#line 890 "src/ast/lex.cc" yy165: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'r') goto yy168; @@ -924,7 +925,7 @@ yy174: ++YYCURSOR; #line 183 "../src/ast/lex.re" { fmt = lex_conf_string(); continue; } -#line 928 "src/ast/lex.cc" +#line 929 "src/ast/lex.cc" yy176: yych = (YYCTYPE)*++YYCURSOR; if (yych != 't') goto yy166; @@ -935,7 +936,7 @@ yy176: ++YYCURSOR; #line 184 "../src/ast/lex.re" { sep = lex_conf_string(); continue; } -#line 939 "src/ast/lex.cc" +#line 940 "src/ast/lex.cc" } #line 193 "../src/ast/lex.re" } @@ -943,7 +944,6 @@ yy176: int Scanner::scan(const conopt_t *globopts) { - uint32_t depth, code_line; scan: tchar = cur - pos; tok = cur; @@ -953,7 +953,7 @@ scan: YYCTYPE yych; unsigned int yyaccept = 0; static const unsigned char yybm[] = { - 128, 128, 128, 128, 128, 128, 128, 128, + 0, 128, 128, 128, 128, 128, 128, 128, 128, 144, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, @@ -1048,7 +1048,7 @@ scan: yy183: ++YYCURSOR; yy184: -#line 353 "../src/ast/lex.re" +#line 334 "../src/ast/lex.re" { fatal_lc(get_cline(), get_column(), "unexpected character: '%c'", *tok); goto scan; @@ -1061,7 +1061,7 @@ yy185: if (yybm[0+yych] & 16) { goto yy185; } -#line 332 "../src/ast/lex.re" +#line 313 "../src/ast/lex.re" { goto scan; } @@ -1076,7 +1076,7 @@ yy188: if (yych == '#') goto yy214; } yy189: -#line 341 "../src/ast/lex.re" +#line 322 "../src/ast/lex.re" { if (cur == eof) return 0; pos = cur; @@ -1096,12 +1096,12 @@ yy190: yy191: ++YYCURSOR; yy192: -#line 245 "../src/ast/lex.re" +#line 226 "../src/ast/lex.re" { return *tok; } #line 1102 "src/ast/lex.cc" yy193: ++YYCURSOR; -#line 235 "../src/ast/lex.re" +#line 216 "../src/ast/lex.re" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; } #line 1107 "src/ast/lex.cc" yy195: @@ -1121,7 +1121,7 @@ yy196: goto yy184; yy197: ++YYCURSOR; -#line 234 "../src/ast/lex.re" +#line 215 "../src/ast/lex.re" { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; } #line 1127 "src/ast/lex.cc" yy199: @@ -1130,7 +1130,7 @@ yy199: goto yy192; yy200: ++YYCURSOR; -#line 327 "../src/ast/lex.re" +#line 308 "../src/ast/lex.re" { yylval.regexp = ast_dot(cline, get_column()); return TOKEN_REGEXP; @@ -1178,7 +1178,7 @@ yy205: yy206: yych = (YYCTYPE)*++YYCURSOR; if (yych == '^') goto yy233; -#line 236 "../src/ast/lex.re" +#line 217 "../src/ast/lex.re" { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; } #line 1184 "src/ast/lex.cc" yy208: @@ -1203,13 +1203,9 @@ yy209: } } yy210: -#line 203 "../src/ast/lex.re" - { - depth = 1; - code_line = cline; - goto code; - } -#line 1213 "src/ast/lex.cc" +#line 202 "../src/ast/lex.re" + { lex_code(1); return TOKEN_CODE; } +#line 1209 "src/ast/lex.cc" yy211: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1260,51 +1256,41 @@ yy216: } } yy218: -#line 239 "../src/ast/lex.re" +#line 220 "../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 1270 "src/ast/lex.cc" +#line 1266 "src/ast/lex.cc" yy219: ++YYCURSOR; -#line 229 "../src/ast/lex.re" +#line 210 "../src/ast/lex.re" { tok = cur; return 0; } -#line 1278 "src/ast/lex.cc" +#line 1274 "src/ast/lex.cc" yy221: ++YYCURSOR; -#line 223 "../src/ast/lex.re" - { - depth = 1; - goto comment; - } -#line 1286 "src/ast/lex.cc" +#line 207 "../src/ast/lex.re" + { lex_c_comment(); goto scan; } +#line 1279 "src/ast/lex.cc" yy223: ++YYCURSOR; -#line 220 "../src/ast/lex.re" - { - goto nextLine; - } -#line 1293 "src/ast/lex.cc" +#line 206 "../src/ast/lex.re" + { lex_cpp_comment(); goto scan; } +#line 1284 "src/ast/lex.cc" yy225: yych = (YYCTYPE)*++YYCURSOR; if (yych == '>') goto yy243; -#line 213 "../src/ast/lex.re" - { - tok += 2; /* skip ":=" */ - depth = 0; - code_line = cline; - goto code; - } -#line 1304 "src/ast/lex.cc" +#line 203 "../src/ast/lex.re" + { tok += 2; lex_code(0); return TOKEN_CODE; } +#line 1290 "src/ast/lex.cc" yy227: ++YYCURSOR; YYCURSOR -= 1; -#line 310 "../src/ast/lex.re" +#line 291 "../src/ast/lex.re" { if (!globopts->FFlag) { yylval.str = new std::string (tok, tok_len()); @@ -1321,7 +1307,7 @@ yy227: return TOKEN_REGEXP; } } -#line 1325 "src/ast/lex.cc" +#line 1311 "src/ast/lex.cc" yy229: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -1341,17 +1327,17 @@ yy229: yy231: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 305 "../src/ast/lex.re" +#line 286 "../src/ast/lex.re" { yylval.str = new std::string (tok, tok_len ()); return TOKEN_ID; } -#line 1350 "src/ast/lex.cc" +#line 1336 "src/ast/lex.cc" yy233: ++YYCURSOR; -#line 237 "../src/ast/lex.re" +#line 218 "../src/ast/lex.re" { yylval.regexp = lex_cls(true); return TOKEN_REGEXP; } -#line 1355 "src/ast/lex.cc" +#line 1341 "src/ast/lex.cc" yy235: yych = (YYCTYPE)*++YYCURSOR; if (yych == '2') goto yy247; @@ -1359,11 +1345,11 @@ yy235: yy236: ++YYCURSOR; yy237: -#line 278 "../src/ast/lex.re" +#line 259 "../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 1367 "src/ast/lex.cc" +#line 1353 "src/ast/lex.cc" yy238: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1403,15 +1389,13 @@ yy242: yy243: ++YYCURSOR; YYCURSOR -= 2; -#line 209 "../src/ast/lex.re" - { - return *tok; - } -#line 1411 "src/ast/lex.cc" +#line 204 "../src/ast/lex.re" + { return *tok; } +#line 1395 "src/ast/lex.cc" yy245: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 292 "../src/ast/lex.re" +#line 273 "../src/ast/lex.re" { yylval.str = new std::string (tok, tok_len ()); if (globopts->FFlag) @@ -1424,7 +1408,7 @@ yy245: return TOKEN_ID; } } -#line 1428 "src/ast/lex.cc" +#line 1412 "src/ast/lex.cc" yy247: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'c') goto yy254; @@ -1438,7 +1422,7 @@ yy248: goto yy237; yy249: ++YYCURSOR; -#line 247 "../src/ast/lex.re" +#line 228 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 1, yylval.bounds.min)) { @@ -1447,10 +1431,10 @@ yy249: yylval.bounds.max = yylval.bounds.min; return TOKEN_CLOSESIZE; } -#line 1451 "src/ast/lex.cc" +#line 1435 "src/ast/lex.cc" yy251: ++YYCURSOR; -#line 282 "../src/ast/lex.re" +#line 263 "../src/ast/lex.re" { if (!globopts->FFlag) { fatal_lc(get_cline(), get_column(), "curly braces for names only allowed with -F switch"); @@ -1458,7 +1442,7 @@ yy251: yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces return TOKEN_ID; } -#line 1462 "src/ast/lex.cc" +#line 1446 "src/ast/lex.cc" yy253: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'n') goto yy259; @@ -1477,7 +1461,7 @@ yy255: goto yy213; yy257: ++YYCURSOR; -#line 269 "../src/ast/lex.re" +#line 250 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok + 1, cur - 2, yylval.bounds.min)) { @@ -1486,19 +1470,19 @@ yy257: yylval.bounds.max = std::numeric_limits::max(); return TOKEN_CLOSESIZE; } -#line 1490 "src/ast/lex.cc" +#line 1474 "src/ast/lex.cc" yy259: yych = (YYCTYPE)*++YYCURSOR; if (yych == 'e') goto yy264; goto yy213; yy260: ++YYCURSOR; -#line 290 "../src/ast/lex.re" +#line 271 "../src/ast/lex.re" { return TOKEN_CONF; } -#line 1499 "src/ast/lex.cc" +#line 1483 "src/ast/lex.cc" yy262: ++YYCURSOR; -#line 256 "../src/ast/lex.re" +#line 237 "../src/ast/lex.re" { const char * p = strchr (tok, ','); if (!s_to_u32_unsafe (tok + 1, p, yylval.bounds.min)) @@ -1511,7 +1495,7 @@ yy262: } return TOKEN_CLOSESIZE; } -#line 1515 "src/ast/lex.cc" +#line 1499 "src/ast/lex.cc" yy264: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '0') goto yy266; @@ -1567,12 +1551,12 @@ yy269: yy271: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 336 "../src/ast/lex.re" +#line 317 "../src/ast/lex.re" { set_sourceline (); return TOKEN_LINE_INFO; } -#line 1576 "src/ast/lex.cc" +#line 1560 "src/ast/lex.cc" yy273: yych = (YYCTYPE)*++YYCURSOR; if (yych == '\n') goto yy271; @@ -1594,615 +1578,482 @@ yy277: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; + if (yych <= 0x00) goto yy213; if (yych == '\n') goto yy213; goto yy274; } -#line 357 "../src/ast/lex.re" +#line 338 "../src/ast/lex.re" +} +void Scanner::lex_code(uint32_t depth) +{ + const uint32_t line = cline; code: -#line 1606 "src/ast/lex.cc" +#line 1595 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; static const unsigned char yybm[] = { - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 112, 0, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 112, 96, 64, 96, 96, 96, 96, 32, - 96, 96, 96, 96, 96, 96, 96, 96, - 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 0, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, + 0, 128, 128, 128, 128, 128, 128, 128, + 128, 160, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 160, 128, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 0, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, }; - if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = (YYCTYPE)*YYCURSOR; if (yych <= '&') { - if (yych <= '\n') { + if (yych <= '\f') { if (yych <= 0x00) goto yy280; - if (yych <= '\t') goto yy282; - goto yy284; + if (yych == '\n') goto yy284; + goto yy282; } else { - if (yych == '"') goto yy286; + if (yych <= '\r') goto yy286; + if (yych == '"') goto yy287; goto yy282; } } else { - if (yych <= '{') { + if (yych <= 'z') { if (yych <= '\'') goto yy287; - if (yych <= 'z') goto yy282; - goto yy288; + if (yych == '/') goto yy289; + goto yy282; } else { - if (yych == '}') goto yy290; + if (yych <= '{') goto yy290; + if (yych == '}') goto yy292; goto yy282; } } yy280: ++YYCURSOR; -#line 420 "../src/ast/lex.re" +#line 395 "../src/ast/lex.re" { - if (cur == eof) - { - if (depth) - { - fatal_l(get_cline(), "missing '}'"); - } - return 0; - } - goto code; - } -#line 1679 "src/ast/lex.cc" + if (cur == eof) { + if (depth) fatal_l(get_cline(), "missing '}'"); + } + goto code; + } +#line 1665 "src/ast/lex.cc" yy282: ++YYCURSOR; yy283: -#line 434 "../src/ast/lex.re" - { - goto code; - } -#line 1687 "src/ast/lex.cc" +#line 405 "../src/ast/lex.re" + { goto code; } +#line 1671 "src/ast/lex.cc" yy284: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '\r') { if (yych <= '\t') { - if (yych >= '\t') goto yy292; + if (yych >= '\t') goto yy294; } else { - if (yych <= '\n') goto yy294; - if (yych >= '\r') goto yy294; + if (yych <= '\n') goto yy296; + if (yych >= '\r') goto yy296; } } else { if (yych <= ' ') { - if (yych >= ' ') goto yy292; + if (yych >= ' ') goto yy294; } else { - if (yych == '#') goto yy295; + if (yych == '#') goto yy297; } } yy285: -#line 401 "../src/ast/lex.re" +#line 380 "../src/ast/lex.re" { - if (depth == 0) - { - tok += strspn(tok, " \t\r\n"); - while (cur > tok && strchr(" \t\r\n", cur[-1])) - { - --cur; - } - yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); - return TOKEN_CODE; - } - else if (cur == eof) - { - fatal_l(get_cline(), "missing '}'"); - } - pos = cur; - cline++; - goto code; - } -#line 1726 "src/ast/lex.cc" + if (depth == 0) { + tok += strspn(tok, " \t\r\n"); + while (cur > tok && strchr(" \t\r\n", cur[-1])) --cur; + yylval.code = new Code(get_fname (), line, tok, tok_len ()); + return; + } + else if (cur == eof) { + fatal_l(get_cline(), "missing '}'"); + } + pos = cur; + cline++; + goto code; + } +#line 1705 "src/ast/lex.cc" yy286: - yyaccept = 1; - yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy283; - goto yy299; + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '\n') goto yy284; + goto yy283; yy287: - yyaccept = 1; - yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy283; - goto yy304; -yy288: ++YYCURSOR; -#line 373 "../src/ast/lex.re" - { - if (depth == 0) - { - fatal_l(get_cline(), "Curly braces are not allowed after ':='"); - } - else - { - ++depth; - } - goto code; - } -#line 1751 "src/ast/lex.cc" +#line 404 "../src/ast/lex.re" + { lex_string(cur[-1]); goto code; } +#line 1714 "src/ast/lex.cc" +yy289: + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '*') goto yy300; + if (yych == '/') goto yy302; + goto yy283; yy290: ++YYCURSOR; -#line 361 "../src/ast/lex.re" +#line 357 "../src/ast/lex.re" { - if (depth == 0) - { - fatal_l(get_cline(), "Curly braces are not allowed after ':='"); - } - else if (--depth == 0) - { - yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); - return TOKEN_CODE; - } - goto code; - } -#line 1767 "src/ast/lex.cc" + if (depth == 0) { + fatal_l(get_cline(), "Curly braces are not allowed after ':='"); + } + else { + ++depth; + } + goto code; + } +#line 1732 "src/ast/lex.cc" yy292: - yyaccept = 2; + ++YYCURSOR; +#line 346 "../src/ast/lex.re" + { + if (depth == 0) { + fatal_l(get_cline(), "Curly braces are not allowed after ':='"); + } + else if (--depth == 0) { + yylval.code = new Code(get_fname (), line, tok, tok_len ()); + return; + } + goto code; + } +#line 1746 "src/ast/lex.cc" +yy294: + yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= 0x1F) { - if (yych == '\t') goto yy306; + if (yych == '\t') goto yy304; } else { - if (yych <= ' ') goto yy306; - if (yych == '#') goto yy295; + if (yych <= ' ') goto yy304; + if (yych == '#') goto yy297; } -yy293: +yy295: YYCURSOR -= 1; -#line 388 "../src/ast/lex.re" +#line 372 "../src/ast/lex.re" { - if (depth == 0) - { - goto code; - } - else if (cur == eof) - { - fatal_l(get_cline(), "missing '}'"); - } - pos = cur; - cline++; - goto code; - } -#line 1793 "src/ast/lex.cc" -yy294: + if (depth == 0) goto code; + else if (cur == eof) fatal_l(get_cline(), "missing '}'"); + pos = cur; + cline++; + goto code; + } +#line 1766 "src/ast/lex.cc" +yy296: ++YYCURSOR; - goto yy293; -yy295: + goto yy295; +yy297: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 16) { - goto yy295; + if (yybm[0+yych] & 32) { + goto yy297; } - if (yych == 'l') goto yy308; -yy297: + if (yych == 'l') goto yy306; +yy299: YYCURSOR = YYMARKER; - if (yyaccept <= 1) { - if (yyaccept == 0) { - goto yy285; - } else { - goto yy283; - } + if (yyaccept == 0) { + goto yy285; } else { - goto yy293; - } -yy298: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; -yy299: - if (yybm[0+yych] & 32) { - goto yy298; + goto yy295; } - if (yych <= '\n') goto yy297; - if (yych >= '#') goto yy302; yy300: ++YYCURSOR; -#line 431 "../src/ast/lex.re" - { - goto code; - } -#line 1832 "src/ast/lex.cc" +#line 402 "../src/ast/lex.re" + { lex_c_comment(); goto code; } +#line 1789 "src/ast/lex.cc" yy302: ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy297; - goto yy298; -yy303: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; +#line 403 "../src/ast/lex.re" + { lex_cpp_comment(); goto code; } +#line 1794 "src/ast/lex.cc" yy304: - if (yybm[0+yych] & 64) { - goto yy303; - } - if (yych <= '\n') goto yy297; - if (yych <= '\'') goto yy300; - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy297; - goto yy303; -yy306: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych <= 0x1F) { - if (yych == '\t') goto yy306; - goto yy297; + if (yych == '\t') goto yy304; + goto yy299; } else { - if (yych <= ' ') goto yy306; - if (yych == '#') goto yy295; - goto yy297; + if (yych <= ' ') goto yy304; + if (yych == '#') goto yy297; + goto yy299; } -yy308: +yy306: yych = (YYCTYPE)*++YYCURSOR; - if (yych != 'i') goto yy297; + if (yych != 'i') goto yy299; yych = (YYCTYPE)*++YYCURSOR; - if (yych != 'n') goto yy297; + if (yych != 'n') goto yy299; yych = (YYCTYPE)*++YYCURSOR; - if (yych != 'e') goto yy297; + if (yych != 'e') goto yy299; yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '0') goto yy313; - if (yych <= '9') goto yy297; - goto yy313; -yy312: + if (yych <= '0') goto yy311; + if (yych <= '9') goto yy299; + goto yy311; +yy310: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy313: +yy311: if (yych <= 0x1F) { - if (yych == '\t') goto yy312; - goto yy297; + if (yych == '\t') goto yy310; + goto yy299; } else { - if (yych <= ' ') goto yy312; - if (yych <= '0') goto yy297; - if (yych >= ':') goto yy297; + if (yych <= ' ') goto yy310; + if (yych <= '0') goto yy299; + if (yych >= ':') goto yy299; YYCTXMARKER = YYCURSOR; } -yy314: +yy312: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy314; + if (yybm[0+yych] & 64) { + goto yy312; } if (yych <= '\f') { - if (yych <= 0x08) goto yy297; - if (yych <= '\t') goto yy316; - if (yych <= '\n') goto yy318; - goto yy297; + if (yych <= 0x08) goto yy299; + if (yych <= '\t') goto yy314; + if (yych <= '\n') goto yy316; + goto yy299; } else { - if (yych <= '\r') goto yy320; - if (yych != ' ') goto yy297; + if (yych <= '\r') goto yy318; + if (yych != ' ') goto yy299; } -yy316: +yy314: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yych <= 0x1F) { - if (yych == '\t') goto yy316; - goto yy297; + if (yych == '\t') goto yy314; + goto yy299; } else { - if (yych <= ' ') goto yy316; - if (yych == '"') goto yy321; - goto yy297; + if (yych <= ' ') goto yy314; + if (yych == '"') goto yy319; + goto yy299; } -yy318: +yy316: ++YYCURSOR; YYCURSOR = YYCTXMARKER; -#line 384 "../src/ast/lex.re" +#line 367 "../src/ast/lex.re" { - set_sourceline (); - goto code; - } -#line 1927 "src/ast/lex.cc" -yy320: + set_sourceline (); + goto code; + } +#line 1868 "src/ast/lex.cc" +yy318: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy318; - goto yy297; -yy321: + if (yych == '\n') goto yy316; + goto yy299; +yy319: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = (YYCTYPE)*YYCURSOR; - if (yych <= '!') { - if (yych == '\n') goto yy297; - goto yy321; - } else { - if (yych <= '"') goto yy323; - if (yych == '\\') goto yy324; - goto yy321; + if (yybm[0+yych] & 128) { + goto yy319; } -yy323: + if (yych <= '\n') goto yy299; + if (yych >= '#') goto yy322; yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy318; - if (yych == '\r') goto yy320; - goto yy297; -yy324: + if (yych == '\n') goto yy316; + if (yych == '\r') goto yy318; + goto yy299; +yy322: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy297; - goto yy321; + if (yych <= 0x00) goto yy299; + if (yych == '\n') goto yy299; + goto yy319; } -#line 437 "../src/ast/lex.re" +#line 406 "../src/ast/lex.re" +} -comment: +void Scanner::lex_string(char delim) +{ +loop: -#line 1961 "src/ast/lex.cc" +#line 1902 "src/ast/lex.cc" { YYCTYPE yych; - static const unsigned char yybm[] = { - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 160, 0, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 160, 128, 0, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 0, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, - }; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; - if (yych <= ')') { - if (yych == '\n') goto yy329; + if (yych <= '!') { + if (yych <= '\n') { + if (yych <= 0x00) goto yy325; + if (yych <= '\t') goto yy327; + goto yy329; + } else { + if (yych == '\r') goto yy331; + goto yy327; + } } else { - if (yych <= '*') goto yy331; - if (yych == '/') goto yy332; + if (yych <= '\'') { + if (yych <= '"') goto yy332; + if (yych <= '&') goto yy327; + goto yy332; + } else { + if (yych == '\\') goto yy334; + goto yy327; + } } +yy325: + ++YYCURSOR; +#line 416 "../src/ast/lex.re" + { if (cur == eof) fatal_l(get_cline(), "unexpected end of input"); else goto loop; } +#line 1930 "src/ast/lex.cc" +yy327: ++YYCURSOR; yy328: -#line 469 "../src/ast/lex.re" - { - if (cur == eof) - { - return 0; - } - goto comment; - } -#line 2016 "src/ast/lex.cc" +#line 417 "../src/ast/lex.re" + { goto loop; } +#line 1936 "src/ast/lex.cc" yy329: - yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy333; - } - if (yych == '#') goto yy336; -yy330: -#line 460 "../src/ast/lex.re" - { - if (cur == eof) - { - return 0; - } - tok = pos = cur; - cline++; - goto comment; - } -#line 2034 "src/ast/lex.cc" + ++YYCURSOR; +#line 415 "../src/ast/lex.re" + { pos = cur; ++cline; goto loop; } +#line 1941 "src/ast/lex.cc" yy331: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '/') goto yy338; + if (yych == '\n') goto yy329; goto yy328; yy332: - yych = (YYCTYPE)*++YYCURSOR; - if (yych == '*') goto yy340; - goto yy328; -yy333: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 32) { - goto yy333; - } - if (yych == '#') goto yy336; -yy335: - YYCURSOR = YYMARKER; - goto yy330; -yy336: - ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); - yych = (YYCTYPE)*YYCURSOR; - if (yych <= 0x1F) { - if (yych == '\t') goto yy336; - goto yy335; - } else { - if (yych <= ' ') goto yy336; - if (yych == 'l') goto yy342; - goto yy335; - } -yy338: ++YYCURSOR; -#line 441 "../src/ast/lex.re" - { - if (--depth == 0) - { - goto scan; - } - else - { - goto comment; - } - } -#line 2079 "src/ast/lex.cc" -yy340: - ++YYCURSOR; -#line 451 "../src/ast/lex.re" - { - ++depth; - fatal_lc(get_cline(), get_column(), "ambiguous /* found"); - goto comment; - } -#line 2088 "src/ast/lex.cc" -yy342: - yych = (YYCTYPE)*++YYCURSOR; - if (yych != 'i') goto yy335; +#line 413 "../src/ast/lex.re" + { if (cur[-1] == delim) return; else goto loop; } +#line 1950 "src/ast/lex.cc" +yy334: yych = (YYCTYPE)*++YYCURSOR; - if (yych != 'n') goto yy335; - yych = (YYCTYPE)*++YYCURSOR; - if (yych != 'e') goto yy335; - yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '0') goto yy347; - if (yych <= '9') goto yy335; - goto yy347; -yy346: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; -yy347: - if (yych <= 0x1F) { - if (yych == '\t') goto yy346; - goto yy335; + if (yych <= '&') { + if (yych != '"') goto yy328; } else { - if (yych <= ' ') goto yy346; - if (yych <= '0') goto yy335; - if (yych >= ':') goto yy335; - YYCTXMARKER = YYCURSOR; + if (yych <= '\'') goto yy335; + if (yych != '\\') goto yy328; } -yy348: +yy335: ++YYCURSOR; +#line 414 "../src/ast/lex.re" + { goto loop; } +#line 1963 "src/ast/lex.cc" +} +#line 418 "../src/ast/lex.re" + +} + +void Scanner::lex_c_comment() +{ +loop: + +#line 1973 "src/ast/lex.cc" +{ + YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 64) { - goto yy348; - } if (yych <= '\f') { - if (yych <= 0x08) goto yy335; - if (yych <= '\t') goto yy350; - if (yych <= '\n') goto yy352; - goto yy335; + if (yych <= 0x00) goto yy339; + if (yych == '\n') goto yy343; + goto yy341; } else { - if (yych <= '\r') goto yy354; - if (yych != ' ') goto yy335; + if (yych <= '\r') goto yy345; + if (yych == '*') goto yy346; + goto yy341; } -yy350: +yy339: ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yych <= 0x1F) { - if (yych == '\t') goto yy350; - goto yy335; - } else { - if (yych <= ' ') goto yy350; - if (yych == '"') goto yy355; - goto yy335; - } -yy352: +#line 427 "../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" +yy341: ++YYCURSOR; - YYCURSOR = YYCTXMARKER; -#line 456 "../src/ast/lex.re" - { - set_sourceline (); - goto comment; - } -#line 2150 "src/ast/lex.cc" -yy354: - yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy352; - goto yy335; -yy355: - ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = (YYCTYPE)*YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy355; - } - if (yych <= '\n') goto yy335; - if (yych >= '#') goto yy358; +yy342: +#line 428 "../src/ast/lex.re" + { goto loop; } +#line 1997 "src/ast/lex.cc" +yy343: + ++YYCURSOR; +#line 426 "../src/ast/lex.re" + { pos = cur; ++cline; goto loop; } +#line 2002 "src/ast/lex.cc" +yy345: + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '\n') goto yy343; + goto yy342; +yy346: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy352; - if (yych == '\r') goto yy354; - goto yy335; -yy358: + if (yych != '/') goto yy342; ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy335; - goto yy355; +#line 425 "../src/ast/lex.re" + { return; } +#line 2013 "src/ast/lex.cc" } -#line 476 "../src/ast/lex.re" +#line 429 "../src/ast/lex.re" +} -nextLine: +void Scanner::lex_cpp_comment() +{ +loop: -#line 2180 "src/ast/lex.cc" +#line 2023 "src/ast/lex.cc" { YYCTYPE yych; - if (YYLIMIT <= YYCURSOR) YYFILL(1); + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy363; + if (yych <= '\n') { + if (yych <= 0x00) goto yy351; + if (yych <= '\t') goto yy353; + goto yy355; + } else { + if (yych == '\r') goto yy357; + goto yy353; + } +yy351: ++YYCURSOR; -#line 487 "../src/ast/lex.re" - { if(cur == eof) { - return 0; - } - goto nextLine; - } -#line 2193 "src/ast/lex.cc" -yy363: - ++YYCURSOR; -#line 480 "../src/ast/lex.re" - { if(cur == eof) { - return 0; - } - tok = pos = cur; - cline++; - goto scan; - } -#line 2204 "src/ast/lex.cc" +#line 437 "../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" +yy353: + ++YYCURSOR; +yy354: +#line 438 "../src/ast/lex.re" + { goto loop; } +#line 2046 "src/ast/lex.cc" +yy355: + ++YYCURSOR; +#line 436 "../src/ast/lex.re" + { pos = cur; ++cline; return; } +#line 2051 "src/ast/lex.cc" +yy357: + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '\n') goto yy355; + goto yy354; } -#line 492 "../src/ast/lex.re" +#line 439 "../src/ast/lex.re" } @@ -2214,44 +2065,44 @@ fst: tok = cur; c = get_column(); -#line 2218 "src/ast/lex.cc" +#line 2069 "src/ast/lex.cc" { YYCTYPE yych; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; - if (yych == ']') goto yy368; -#line 504 "../src/ast/lex.re" + if (yych == ']') goto yy361; +#line 451 "../src/ast/lex.re" { l = lex_cls_chr(); goto snd; } -#line 2226 "src/ast/lex.cc" -yy368: +#line 2077 "src/ast/lex.cc" +yy361: ++YYCURSOR; -#line 503 "../src/ast/lex.re" +#line 450 "../src/ast/lex.re" { return ast_cls(cline, c0, cls, neg); } -#line 2231 "src/ast/lex.cc" +#line 2082 "src/ast/lex.cc" } -#line 505 "../src/ast/lex.re" +#line 452 "../src/ast/lex.re" snd: -#line 2237 "src/ast/lex.cc" +#line 2088 "src/ast/lex.cc" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*(YYMARKER = YYCURSOR); - if (yych == '-') goto yy373; -yy372: -#line 508 "../src/ast/lex.re" + if (yych == '-') goto yy366; +yy365: +#line 455 "../src/ast/lex.re" { u = l; goto add; } -#line 2246 "src/ast/lex.cc" -yy373: +#line 2097 "src/ast/lex.cc" +yy366: yych = (YYCTYPE)*++YYCURSOR; - if (yych != ']') goto yy375; + if (yych != ']') goto yy368; YYCURSOR = YYMARKER; - goto yy372; -yy375: + goto yy365; +yy368: ++YYCURSOR; YYCURSOR -= 1; -#line 509 "../src/ast/lex.re" +#line 456 "../src/ast/lex.re" { u = lex_cls_chr(); if (l > u) { @@ -2260,9 +2111,9 @@ yy375: } goto add; } -#line 2264 "src/ast/lex.cc" +#line 2115 "src/ast/lex.cc" } -#line 517 "../src/ast/lex.re" +#line 464 "../src/ast/lex.re" add: cls->push_back(ASTRange(l, u, c)); @@ -2274,297 +2125,297 @@ uint32_t Scanner::lex_cls_chr() tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2278 "src/ast/lex.cc" +#line 2129 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 10) YYFILL(10); yych = (YYCTYPE)*YYCURSOR; if (yych <= '\f') { - if (yych == '\n') goto yy381; + if (yych == '\n') goto yy374; } else { - if (yych <= '\r') goto yy383; - if (yych == '\\') goto yy384; + if (yych <= '\r') goto yy376; + if (yych == '\\') goto yy377; } ++YYCURSOR; -yy380: -#line 534 "../src/ast/lex.re" +yy373: +#line 481 "../src/ast/lex.re" { return static_cast(tok[0]); } -#line 2294 "src/ast/lex.cc" -yy381: +#line 2145 "src/ast/lex.cc" +yy374: ++YYCURSOR; -#line 529 "../src/ast/lex.re" +#line 476 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character class"); } -#line 2299 "src/ast/lex.cc" -yy383: +#line 2150 "src/ast/lex.cc" +yy376: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy381; - goto yy380; -yy384: + if (yych == '\n') goto yy374; + goto yy373; +yy377: yych = (YYCTYPE)*++YYCURSOR; if (yych <= ']') { if (yych <= '3') { if (yych <= '\r') { - if (yych == '\n') goto yy381; - if (yych >= '\r') goto yy387; + if (yych == '\n') goto yy374; + if (yych >= '\r') goto yy380; } else { - if (yych == '-') goto yy388; - if (yych >= '0') goto yy390; + if (yych == '-') goto yy381; + if (yych >= '0') goto yy383; } } else { if (yych <= 'W') { - if (yych <= '7') goto yy392; - if (yych == 'U') goto yy393; + if (yych <= '7') goto yy385; + if (yych == 'U') goto yy386; } else { - if (yych <= 'X') goto yy395; - if (yych <= '[') goto yy385; - if (yych <= '\\') goto yy396; - goto yy398; + if (yych <= 'X') goto yy388; + if (yych <= '[') goto yy378; + if (yych <= '\\') goto yy389; + goto yy391; } } } else { if (yych <= 'q') { if (yych <= 'e') { - if (yych <= '`') goto yy385; - if (yych <= 'a') goto yy400; - if (yych <= 'b') goto yy402; + if (yych <= '`') goto yy378; + if (yych <= 'a') goto yy393; + if (yych <= 'b') goto yy395; } else { - if (yych <= 'f') goto yy404; - if (yych == 'n') goto yy406; + if (yych <= 'f') goto yy397; + if (yych == 'n') goto yy399; } } else { if (yych <= 'u') { - if (yych <= 'r') goto yy408; - if (yych <= 's') goto yy385; - if (yych <= 't') goto yy410; - goto yy395; + if (yych <= 'r') goto yy401; + if (yych <= 's') goto yy378; + if (yych <= 't') goto yy403; + goto yy388; } else { - if (yych <= 'v') goto yy412; - if (yych == 'x') goto yy414; + if (yych <= 'v') goto yy405; + if (yych == 'x') goto yy407; } } } -yy385: +yy378: ++YYCURSOR; -yy386: -#line 547 "../src/ast/lex.re" +yy379: +#line 494 "../src/ast/lex.re" { warn.useless_escape(cline, get_column(), tok[1]); return static_cast(tok[1]); } -#line 2356 "src/ast/lex.cc" -yy387: +#line 2207 "src/ast/lex.cc" +yy380: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy381; - goto yy386; -yy388: + if (yych == '\n') goto yy374; + goto yy379; +yy381: ++YYCURSOR; -#line 545 "../src/ast/lex.re" +#line 492 "../src/ast/lex.re" { return static_cast('-'); } -#line 2365 "src/ast/lex.cc" -yy390: +#line 2216 "src/ast/lex.cc" +yy383: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy391; - if (yych <= '7') goto yy415; -yy391: -#line 531 "../src/ast/lex.re" + if (yych <= '/') goto yy384; + if (yych <= '7') goto yy408; +yy384: +#line 478 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2374 "src/ast/lex.cc" -yy392: +#line 2225 "src/ast/lex.cc" +yy385: ++YYCURSOR; - goto yy391; -yy393: + goto yy384; +yy386: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy394; - if (yych <= '9') goto yy417; + if (yych <= '/') goto yy387; + if (yych <= '9') goto yy410; } else { - if (yych <= 'F') goto yy417; - if (yych <= '`') goto yy394; - if (yych <= 'f') goto yy417; + if (yych <= 'F') goto yy410; + if (yych <= '`') goto yy387; + if (yych <= 'f') goto yy410; } -yy394: -#line 530 "../src/ast/lex.re" +yy387: +#line 477 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2392 "src/ast/lex.cc" -yy395: +#line 2243 "src/ast/lex.cc" +yy388: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy394; - if (yych <= '9') goto yy418; - goto yy394; + if (yych <= '/') goto yy387; + if (yych <= '9') goto yy411; + goto yy387; } else { - if (yych <= 'F') goto yy418; - if (yych <= '`') goto yy394; - if (yych <= 'f') goto yy418; - goto yy394; + if (yych <= 'F') goto yy411; + if (yych <= '`') goto yy387; + if (yych <= 'f') goto yy411; + goto yy387; } -yy396: +yy389: ++YYCURSOR; -#line 544 "../src/ast/lex.re" +#line 491 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2410 "src/ast/lex.cc" -yy398: +#line 2261 "src/ast/lex.cc" +yy391: ++YYCURSOR; -#line 546 "../src/ast/lex.re" +#line 493 "../src/ast/lex.re" { return static_cast(']'); } -#line 2415 "src/ast/lex.cc" -yy400: +#line 2266 "src/ast/lex.cc" +yy393: ++YYCURSOR; -#line 537 "../src/ast/lex.re" +#line 484 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2420 "src/ast/lex.cc" -yy402: +#line 2271 "src/ast/lex.cc" +yy395: ++YYCURSOR; -#line 538 "../src/ast/lex.re" +#line 485 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2425 "src/ast/lex.cc" -yy404: +#line 2276 "src/ast/lex.cc" +yy397: ++YYCURSOR; -#line 539 "../src/ast/lex.re" +#line 486 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2430 "src/ast/lex.cc" -yy406: +#line 2281 "src/ast/lex.cc" +yy399: ++YYCURSOR; -#line 540 "../src/ast/lex.re" +#line 487 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2435 "src/ast/lex.cc" -yy408: +#line 2286 "src/ast/lex.cc" +yy401: ++YYCURSOR; -#line 541 "../src/ast/lex.re" +#line 488 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2440 "src/ast/lex.cc" -yy410: +#line 2291 "src/ast/lex.cc" +yy403: ++YYCURSOR; -#line 542 "../src/ast/lex.re" +#line 489 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2445 "src/ast/lex.cc" -yy412: +#line 2296 "src/ast/lex.cc" +yy405: ++YYCURSOR; -#line 543 "../src/ast/lex.re" +#line 490 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2450 "src/ast/lex.cc" -yy414: +#line 2301 "src/ast/lex.cc" +yy407: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy394; - if (yych <= '9') goto yy419; - goto yy394; + if (yych <= '/') goto yy387; + if (yych <= '9') goto yy412; + goto yy387; } else { - if (yych <= 'F') goto yy419; - if (yych <= '`') goto yy394; - if (yych <= 'f') goto yy419; - goto yy394; + if (yych <= 'F') goto yy412; + if (yych <= '`') goto yy387; + if (yych <= 'f') goto yy412; + goto yy387; } -yy415: +yy408: yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '/') goto yy416; - if (yych <= '7') goto yy420; -yy416: + if (yych <= '/') goto yy409; + if (yych <= '7') goto yy413; +yy409: YYCURSOR = YYMARKER; if (yyaccept == 0) { - goto yy391; + goto yy384; } else { - goto yy394; + goto yy387; } -yy417: +yy410: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych <= '9') goto yy422; - goto yy416; + if (yych <= '/') goto yy409; + if (yych <= '9') goto yy415; + goto yy409; } else { - if (yych <= 'F') goto yy422; - if (yych <= '`') goto yy416; - if (yych <= 'f') goto yy422; - goto yy416; + if (yych <= 'F') goto yy415; + if (yych <= '`') goto yy409; + if (yych <= 'f') goto yy415; + goto yy409; } -yy418: +yy411: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych <= '9') goto yy423; - goto yy416; + if (yych <= '/') goto yy409; + if (yych <= '9') goto yy416; + goto yy409; } else { - if (yych <= 'F') goto yy423; - if (yych <= '`') goto yy416; - if (yych <= 'f') goto yy423; - goto yy416; + if (yych <= 'F') goto yy416; + if (yych <= '`') goto yy409; + if (yych <= 'f') goto yy416; + goto yy409; } -yy419: +yy412: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych <= '9') goto yy424; - goto yy416; + if (yych <= '/') goto yy409; + if (yych <= '9') goto yy417; + goto yy409; } else { - if (yych <= 'F') goto yy424; - if (yych <= '`') goto yy416; - if (yych <= 'f') goto yy424; - goto yy416; + if (yych <= 'F') goto yy417; + if (yych <= '`') goto yy409; + if (yych <= 'f') goto yy417; + goto yy409; } -yy420: +yy413: ++YYCURSOR; -#line 536 "../src/ast/lex.re" +#line 483 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2515 "src/ast/lex.cc" -yy422: +#line 2366 "src/ast/lex.cc" +yy415: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych <= '9') goto yy426; - goto yy416; + if (yych <= '/') goto yy409; + if (yych <= '9') goto yy419; + goto yy409; } else { - if (yych <= 'F') goto yy426; - if (yych <= '`') goto yy416; - if (yych <= 'f') goto yy426; - goto yy416; + if (yych <= 'F') goto yy419; + if (yych <= '`') goto yy409; + if (yych <= 'f') goto yy419; + goto yy409; } -yy423: +yy416: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych <= '9') goto yy419; - goto yy416; + if (yych <= '/') goto yy409; + if (yych <= '9') goto yy412; + goto yy409; } else { - if (yych <= 'F') goto yy419; - if (yych <= '`') goto yy416; - if (yych <= 'f') goto yy419; - goto yy416; + if (yych <= 'F') goto yy412; + if (yych <= '`') goto yy409; + if (yych <= 'f') goto yy412; + goto yy409; } -yy424: +yy417: ++YYCURSOR; -#line 535 "../src/ast/lex.re" +#line 482 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2544 "src/ast/lex.cc" -yy426: +#line 2395 "src/ast/lex.cc" +yy419: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych >= ':') goto yy416; + if (yych <= '/') goto yy409; + if (yych >= ':') goto yy409; } else { - if (yych <= 'F') goto yy427; - if (yych <= '`') goto yy416; - if (yych >= 'g') goto yy416; + if (yych <= 'F') goto yy420; + if (yych <= '`') goto yy409; + if (yych >= 'g') goto yy409; } -yy427: +yy420: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy416; - if (yych <= '9') goto yy418; - goto yy416; + if (yych <= '/') goto yy409; + if (yych <= '9') goto yy411; + goto yy409; } else { - if (yych <= 'F') goto yy418; - if (yych <= '`') goto yy416; - if (yych <= 'f') goto yy418; - goto yy416; + if (yych <= 'F') goto yy411; + if (yych <= '`') goto yy409; + if (yych <= 'f') goto yy411; + goto yy409; } } -#line 551 "../src/ast/lex.re" +#line 498 "../src/ast/lex.re" } @@ -2574,289 +2425,289 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2578 "src/ast/lex.cc" +#line 2429 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 10) YYFILL(10); yych = (YYCTYPE)*YYCURSOR; if (yych <= '\f') { - if (yych == '\n') goto yy432; + if (yych == '\n') goto yy425; } else { - if (yych <= '\r') goto yy434; - if (yych == '\\') goto yy435; + if (yych <= '\r') goto yy427; + if (yych == '\\') goto yy428; } ++YYCURSOR; -yy431: -#line 566 "../src/ast/lex.re" +yy424: +#line 513 "../src/ast/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2597 "src/ast/lex.cc" -yy432: +#line 2448 "src/ast/lex.cc" +yy425: ++YYCURSOR; -#line 561 "../src/ast/lex.re" +#line 508 "../src/ast/lex.re" { fatal_lc(l, c, "newline in character string"); } -#line 2602 "src/ast/lex.cc" -yy434: +#line 2453 "src/ast/lex.cc" +yy427: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy432; - goto yy431; -yy435: + if (yych == '\n') goto yy425; + goto yy424; +yy428: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '`') { if (yych <= '7') { if (yych <= '\f') { - if (yych == '\n') goto yy432; + if (yych == '\n') goto yy425; } else { - if (yych <= '\r') goto yy438; - if (yych <= '/') goto yy436; - if (yych <= '3') goto yy439; - goto yy441; + if (yych <= '\r') goto yy431; + if (yych <= '/') goto yy429; + if (yych <= '3') goto yy432; + goto yy434; } } else { if (yych <= 'W') { - if (yych == 'U') goto yy442; + if (yych == 'U') goto yy435; } else { - if (yych <= 'X') goto yy444; - if (yych == '\\') goto yy445; + if (yych <= 'X') goto yy437; + if (yych == '\\') goto yy438; } } } else { if (yych <= 'q') { if (yych <= 'e') { - if (yych <= 'a') goto yy447; - if (yych <= 'b') goto yy449; + if (yych <= 'a') goto yy440; + if (yych <= 'b') goto yy442; } else { - if (yych <= 'f') goto yy451; - if (yych == 'n') goto yy453; + if (yych <= 'f') goto yy444; + if (yych == 'n') goto yy446; } } else { if (yych <= 'u') { - if (yych <= 'r') goto yy455; - if (yych <= 's') goto yy436; - if (yych <= 't') goto yy457; - goto yy444; + if (yych <= 'r') goto yy448; + if (yych <= 's') goto yy429; + if (yych <= 't') goto yy450; + goto yy437; } else { - if (yych <= 'v') goto yy459; - if (yych == 'x') goto yy461; + if (yych <= 'v') goto yy452; + if (yych == 'x') goto yy454; } } } -yy436: +yy429: ++YYCURSOR; -yy437: -#line 580 "../src/ast/lex.re" +yy430: +#line 527 "../src/ast/lex.re" { if (tok[1] != quote) { warn.useless_escape(cline, get_column(), tok[1]); } return static_cast(tok[1]); } -#line 2658 "src/ast/lex.cc" -yy438: +#line 2509 "src/ast/lex.cc" +yy431: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy432; - goto yy437; -yy439: + if (yych == '\n') goto yy425; + goto yy430; +yy432: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy440; - if (yych <= '7') goto yy462; -yy440: -#line 563 "../src/ast/lex.re" + if (yych <= '/') goto yy433; + if (yych <= '7') goto yy455; +yy433: +#line 510 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2671 "src/ast/lex.cc" -yy441: +#line 2522 "src/ast/lex.cc" +yy434: ++YYCURSOR; - goto yy440; -yy442: + goto yy433; +yy435: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy443; - if (yych <= '9') goto yy464; + if (yych <= '/') goto yy436; + if (yych <= '9') goto yy457; } else { - if (yych <= 'F') goto yy464; - if (yych <= '`') goto yy443; - if (yych <= 'f') goto yy464; + if (yych <= 'F') goto yy457; + if (yych <= '`') goto yy436; + if (yych <= 'f') goto yy457; } -yy443: -#line 562 "../src/ast/lex.re" +yy436: +#line 509 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2689 "src/ast/lex.cc" -yy444: +#line 2540 "src/ast/lex.cc" +yy437: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy443; - if (yych <= '9') goto yy465; - goto yy443; + if (yych <= '/') goto yy436; + if (yych <= '9') goto yy458; + goto yy436; } else { - if (yych <= 'F') goto yy465; - if (yych <= '`') goto yy443; - if (yych <= 'f') goto yy465; - goto yy443; + if (yych <= 'F') goto yy458; + if (yych <= '`') goto yy436; + if (yych <= 'f') goto yy458; + goto yy436; } -yy445: +yy438: ++YYCURSOR; -#line 579 "../src/ast/lex.re" +#line 526 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2707 "src/ast/lex.cc" -yy447: +#line 2558 "src/ast/lex.cc" +yy440: ++YYCURSOR; -#line 572 "../src/ast/lex.re" +#line 519 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2712 "src/ast/lex.cc" -yy449: +#line 2563 "src/ast/lex.cc" +yy442: ++YYCURSOR; -#line 573 "../src/ast/lex.re" +#line 520 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2717 "src/ast/lex.cc" -yy451: +#line 2568 "src/ast/lex.cc" +yy444: ++YYCURSOR; -#line 574 "../src/ast/lex.re" +#line 521 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2722 "src/ast/lex.cc" -yy453: +#line 2573 "src/ast/lex.cc" +yy446: ++YYCURSOR; -#line 575 "../src/ast/lex.re" +#line 522 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2727 "src/ast/lex.cc" -yy455: +#line 2578 "src/ast/lex.cc" +yy448: ++YYCURSOR; -#line 576 "../src/ast/lex.re" +#line 523 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2732 "src/ast/lex.cc" -yy457: +#line 2583 "src/ast/lex.cc" +yy450: ++YYCURSOR; -#line 577 "../src/ast/lex.re" +#line 524 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2737 "src/ast/lex.cc" -yy459: +#line 2588 "src/ast/lex.cc" +yy452: ++YYCURSOR; -#line 578 "../src/ast/lex.re" +#line 525 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2742 "src/ast/lex.cc" -yy461: +#line 2593 "src/ast/lex.cc" +yy454: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy443; - if (yych <= '9') goto yy466; - goto yy443; + if (yych <= '/') goto yy436; + if (yych <= '9') goto yy459; + goto yy436; } else { - if (yych <= 'F') goto yy466; - if (yych <= '`') goto yy443; - if (yych <= 'f') goto yy466; - goto yy443; + if (yych <= 'F') goto yy459; + if (yych <= '`') goto yy436; + if (yych <= 'f') goto yy459; + goto yy436; } -yy462: +yy455: yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '/') goto yy463; - if (yych <= '7') goto yy467; -yy463: + if (yych <= '/') goto yy456; + if (yych <= '7') goto yy460; +yy456: YYCURSOR = YYMARKER; if (yyaccept == 0) { - goto yy440; + goto yy433; } else { - goto yy443; + goto yy436; } -yy464: +yy457: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych <= '9') goto yy469; - goto yy463; + if (yych <= '/') goto yy456; + if (yych <= '9') goto yy462; + goto yy456; } else { - if (yych <= 'F') goto yy469; - if (yych <= '`') goto yy463; - if (yych <= 'f') goto yy469; - goto yy463; + if (yych <= 'F') goto yy462; + if (yych <= '`') goto yy456; + if (yych <= 'f') goto yy462; + goto yy456; } -yy465: +yy458: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych <= '9') goto yy470; - goto yy463; + if (yych <= '/') goto yy456; + if (yych <= '9') goto yy463; + goto yy456; } else { - if (yych <= 'F') goto yy470; - if (yych <= '`') goto yy463; - if (yych <= 'f') goto yy470; - goto yy463; + if (yych <= 'F') goto yy463; + if (yych <= '`') goto yy456; + if (yych <= 'f') goto yy463; + goto yy456; } -yy466: +yy459: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych <= '9') goto yy471; - goto yy463; + if (yych <= '/') goto yy456; + if (yych <= '9') goto yy464; + goto yy456; } else { - if (yych <= 'F') goto yy471; - if (yych <= '`') goto yy463; - if (yych <= 'f') goto yy471; - goto yy463; + if (yych <= 'F') goto yy464; + if (yych <= '`') goto yy456; + if (yych <= 'f') goto yy464; + goto yy456; } -yy467: +yy460: ++YYCURSOR; -#line 571 "../src/ast/lex.re" +#line 518 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2807 "src/ast/lex.cc" -yy469: +#line 2658 "src/ast/lex.cc" +yy462: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych <= '9') goto yy473; - goto yy463; + if (yych <= '/') goto yy456; + if (yych <= '9') goto yy466; + goto yy456; } else { - if (yych <= 'F') goto yy473; - if (yych <= '`') goto yy463; - if (yych <= 'f') goto yy473; - goto yy463; + if (yych <= 'F') goto yy466; + if (yych <= '`') goto yy456; + if (yych <= 'f') goto yy466; + goto yy456; } -yy470: +yy463: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych <= '9') goto yy466; - goto yy463; + if (yych <= '/') goto yy456; + if (yych <= '9') goto yy459; + goto yy456; } else { - if (yych <= 'F') goto yy466; - if (yych <= '`') goto yy463; - if (yych <= 'f') goto yy466; - goto yy463; + if (yych <= 'F') goto yy459; + if (yych <= '`') goto yy456; + if (yych <= 'f') goto yy459; + goto yy456; } -yy471: +yy464: ++YYCURSOR; -#line 570 "../src/ast/lex.re" +#line 517 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2836 "src/ast/lex.cc" -yy473: +#line 2687 "src/ast/lex.cc" +yy466: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych >= ':') goto yy463; + if (yych <= '/') goto yy456; + if (yych >= ':') goto yy456; } else { - if (yych <= 'F') goto yy474; - if (yych <= '`') goto yy463; - if (yych >= 'g') goto yy463; + if (yych <= 'F') goto yy467; + if (yych <= '`') goto yy456; + if (yych >= 'g') goto yy456; } -yy474: +yy467: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy463; - if (yych <= '9') goto yy465; - goto yy463; + if (yych <= '/') goto yy456; + if (yych <= '9') goto yy458; + goto yy456; } else { - if (yych <= 'F') goto yy465; - if (yych <= '`') goto yy463; - if (yych <= 'f') goto yy465; - goto yy463; + if (yych <= 'F') goto yy458; + if (yych <= '`') goto yy456; + if (yych <= 'f') goto yy458; + goto yy456; } } -#line 586 "../src/ast/lex.re" +#line 533 "../src/ast/lex.re" } @@ -2876,11 +2727,11 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2880 "src/ast/lex.cc" +#line 2731 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { - 128, 128, 128, 128, 128, 128, 128, 128, + 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, @@ -2917,98 +2768,100 @@ sourceline: yych = (YYCTYPE)*YYCURSOR; if (yych <= '\r') { if (yych <= '\t') { - if (yych >= 0x01) goto yy479; + if (yych >= 0x01) goto yy472; } else { - if (yych <= '\n') goto yy481; - if (yych <= '\f') goto yy479; - goto yy483; + if (yych <= '\n') goto yy474; + if (yych <= '\f') goto yy472; + goto yy476; } } else { if (yych <= '"') { - if (yych <= '!') goto yy479; - goto yy484; + if (yych <= '!') goto yy472; + goto yy477; } else { - if (yych <= '0') goto yy479; - if (yych <= '9') goto yy485; - goto yy479; + if (yych <= '0') goto yy472; + if (yych <= '9') goto yy478; + goto yy472; } } ++YYCURSOR; -#line 623 "../src/ast/lex.re" +#line 570 "../src/ast/lex.re" { --cur; tok = cur; return; } -#line 2944 "src/ast/lex.cc" -yy479: +#line 2795 "src/ast/lex.cc" +yy472: ++YYCURSOR; -yy480: -#line 629 "../src/ast/lex.re" +yy473: +#line 576 "../src/ast/lex.re" { goto sourceline; } -#line 2950 "src/ast/lex.cc" -yy481: +#line 2801 "src/ast/lex.cc" +yy474: ++YYCURSOR; -#line 618 "../src/ast/lex.re" +#line 565 "../src/ast/lex.re" { tok = cur; return; } -#line 2958 "src/ast/lex.cc" -yy483: +#line 2809 "src/ast/lex.cc" +yy476: yych = (YYCTYPE)*++YYCURSOR; - if (yych == '\n') goto yy481; - goto yy480; -yy484: + if (yych == '\n') goto yy474; + goto yy473; +yy477: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy480; - goto yy489; -yy485: + if (yych <= 0x00) goto yy473; + if (yych == '\n') goto yy473; + goto yy482; +yy478: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yybm[0+yych] & 64) { - goto yy485; + goto yy478; } -#line 605 "../src/ast/lex.re" +#line 552 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { fatal_lc(get_cline(), get_column(), "line number overflow"); } goto sourceline; } -#line 2981 "src/ast/lex.cc" -yy488: +#line 2833 "src/ast/lex.cc" +yy481: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy489: +yy482: if (yybm[0+yych] & 128) { - goto yy488; + goto yy481; } - if (yych <= '\n') goto yy490; - if (yych <= '"') goto yy491; - goto yy493; -yy490: + if (yych <= '\n') goto yy483; + if (yych <= '"') goto yy484; + goto yy486; +yy483: YYCURSOR = YYMARKER; - goto yy480; -yy491: + goto yy473; +yy484: ++YYCURSOR; -#line 612 "../src/ast/lex.re" +#line 559 "../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 3004 "src/ast/lex.cc" -yy493: +#line 2856 "src/ast/lex.cc" +yy486: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy490; - goto yy488; + if (yych <= 0x00) goto yy483; + if (yych == '\n') goto yy483; + goto yy481; } -#line 630 "../src/ast/lex.re" +#line 577 "../src/ast/lex.re" } diff --git a/re2c/bootstrap/src/ast/lex_conf.cc b/re2c/bootstrap/src/ast/lex_conf.cc index c6957ca5..0d3fd398 100644 --- a/re2c/bootstrap/src/ast/lex_conf.cc +++ b/re2c/bootstrap/src/ast/lex_conf.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Thu Aug 30 23:14:50 2018 */ +/* Generated by re2c 1.1.1 on Mon Oct 29 22:56:51 2018 */ #line 1 "../src/ast/lex_conf.re" #include "src/util/c99_stdint.h" #include diff --git a/re2c/src/ast/lex.re b/re2c/src/ast/lex.re index 83a20d8c..72439ba3 100644 --- a/re2c/src/ast/lex.re +++ b/re2c/src/ast/lex.re @@ -20,11 +20,11 @@ extern YYSTYPE yylval; -#define YYCTYPE unsigned char -#define YYCURSOR cur -#define YYLIMIT lim -#define YYMARKER mar -#define YYCTXMARKER ctx +#define YYCTYPE unsigned char +#define YYCURSOR cur +#define YYLIMIT lim +#define YYMARKER mar +#define YYCTXMARKER ctx #define YYFILL(n) { fill (n); } namespace re2c @@ -39,8 +39,8 @@ namespace re2c /*!re2c eof = "\000"; -dstring = "\"" ((. \ [\\"] ) | "\\" .)* "\""; -sstring = "'" ((. \ [\\'] ) | "\\" .)* "'" ; +dstring = "\"" ([^\x00\n\\"] | "\\" [^\x00\n])* "\""; +sstring = "'" ([^\x00\n\\'] | "\\" [^\x00\n])* "'" ; letter = [a-zA-Z]; digit = [0-9]; lineno = [1-9] digit*; @@ -195,35 +195,16 @@ void Scanner::lex_tags(OutputFile &out, bool mtags) int Scanner::scan(const conopt_t *globopts) { - uint32_t depth, code_line; scan: tchar = cur - pos; tok = cur; /*!re2c - "{" { - depth = 1; - code_line = cline; - goto code; - } - - ":" / "=>" { - return *tok; - } + "{" { lex_code(1); return TOKEN_CODE; } + ":=" { tok += 2; lex_code(0); return TOKEN_CODE; } + ":" / "=>" { return *tok; } - ":=" { - tok += 2; /* skip ":=" */ - depth = 0; - code_line = cline; - goto code; - } - - "//" { - goto nextLine; - } - "/*" { - depth = 1; - goto comment; - } + "//" { lex_cpp_comment(); goto scan; } + "/*" { lex_c_comment(); goto scan; } endRE = "%}" | "*/"; endRE { @@ -355,140 +336,106 @@ scan: goto scan; } */ +} +void Scanner::lex_code(uint32_t depth) +{ + const uint32_t line = cline; code: /*!re2c - "}" { - if (depth == 0) - { - fatal_l(get_cline(), "Curly braces are not allowed after ':='"); - } - else if (--depth == 0) - { - yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); - return TOKEN_CODE; - } - goto code; - } - "{" { - if (depth == 0) - { - fatal_l(get_cline(), "Curly braces are not allowed after ':='"); - } - else - { - ++depth; - } - goto code; - } - "\n" space* "#" space* "line" space+ / lineinf { - set_sourceline (); - goto code; - } - "\n" / ws { - if (depth == 0) - { - goto code; - } - else if (cur == eof) - { - fatal_l(get_cline(), "missing '}'"); - } - pos = cur; - cline++; - goto code; - } - "\n" { - if (depth == 0) - { - tok += strspn(tok, " \t\r\n"); - while (cur > tok && strchr(" \t\r\n", cur[-1])) - { - --cur; - } - yylval.code = new Code(get_fname (), code_line, tok, tok_len ()); - return TOKEN_CODE; - } - else if (cur == eof) - { - fatal_l(get_cline(), "missing '}'"); - } - pos = cur; - cline++; - goto code; - } - eof { - if (cur == eof) - { - if (depth) - { - fatal_l(get_cline(), "missing '}'"); - } - return 0; - } - goto code; - } - dstring | sstring { - goto code; - } - * { - goto code; - } + "}" { + if (depth == 0) { + fatal_l(get_cline(), "Curly braces are not allowed after ':='"); + } + else if (--depth == 0) { + yylval.code = new Code(get_fname (), line, tok, tok_len ()); + return; + } + goto code; + } + + "{" { + if (depth == 0) { + fatal_l(get_cline(), "Curly braces are not allowed after ':='"); + } + else { + ++depth; + } + goto code; + } + + eol space* "#" space* "line" space+ / lineinf { + set_sourceline (); + goto code; + } + + eol / ws { + if (depth == 0) goto code; + else if (cur == eof) fatal_l(get_cline(), "missing '}'"); + pos = cur; + cline++; + goto code; + } + + eol { + if (depth == 0) { + tok += strspn(tok, " \t\r\n"); + while (cur > tok && strchr(" \t\r\n", cur[-1])) --cur; + yylval.code = new Code(get_fname (), line, tok, tok_len ()); + return; + } + else if (cur == eof) { + fatal_l(get_cline(), "missing '}'"); + } + pos = cur; + cline++; + goto code; + } + + eof { + if (cur == eof) { + if (depth) fatal_l(get_cline(), "missing '}'"); + } + goto code; + } + + "/*" { lex_c_comment(); goto code; } + "//" { lex_cpp_comment(); goto code; } + ["'] { lex_string(cur[-1]); goto code; } + * { goto code; } */ +} -comment: +void Scanner::lex_string(char delim) +{ +loop: /*!re2c - "*" "/" { - if (--depth == 0) - { - goto scan; - } - else - { - goto comment; - } - } - "/" "*" { - ++depth; - fatal_lc(get_cline(), get_column(), "ambiguous /* found"); - goto comment; - } - "\n" space* "#" space* "line" space+ / lineinf { - set_sourceline (); - goto comment; - } - "\n" { - if (cur == eof) - { - return 0; - } - tok = pos = cur; - cline++; - goto comment; - } - * { - if (cur == eof) - { - return 0; - } - goto comment; - } + ["'] { if (cur[-1] == delim) return; else goto loop; } + esc [\\"'] { goto loop; } + eol { pos = cur; ++cline; goto loop; } + eof { if (cur == eof) fatal_l(get_cline(), "unexpected end of input"); else goto loop; } + * { goto loop; } */ +} -nextLine: -/*!re2c /* resync emacs */ - "\n" { if(cur == eof) { - return 0; - } - tok = pos = cur; - cline++; - goto scan; - } - * { if(cur == eof) { - return 0; - } - goto nextLine; - } +void Scanner::lex_c_comment() +{ +loop: +/*!re2c + eoc { return; } + eol { pos = cur; ++cline; goto loop; } + eof { if (cur == eof) fatal_l(get_cline(), "end of input in comment"); else goto loop; } + * { goto loop; } +*/ +} + +void Scanner::lex_cpp_comment() +{ +loop: +/*!re2c + eol { pos = cur; ++cline; return; } + eof { if (cur == eof) fatal_l(get_cline(), "end of input in comment"); else goto loop; } + * { goto loop; } */ } diff --git a/re2c/src/ast/scanner.h b/re2c/src/ast/scanner.h index 6db16ab1..fe35962e 100644 --- a/re2c/src/ast/scanner.h +++ b/re2c/src/ast/scanner.h @@ -62,6 +62,10 @@ class Scanner: private ScannerState void fill(uint32_t need); void lex_end_of_comment(OutputFile &out); + void lex_code(uint32_t depth); + void lex_c_comment(); + void lex_cpp_comment(); + void lex_string(char delim); void lex_tags(OutputFile &out, bool mtags); void set_sourceline (); uint32_t lex_cls_chr(); diff --git a/re2c/test/american_fuzzy_lop/01.c b/re2c/test/american_fuzzy_lop/01.c new file mode 100644 index 00000000..b62aa5fa --- /dev/null +++ b/re2c/test/american_fuzzy_lop/01.c @@ -0,0 +1 @@ +re2c: error: line 1: unexpected end of input diff --git a/re2c/test/american_fuzzy_lop/01.re b/re2c/test/american_fuzzy_lop/01.re new file mode 100644 index 00000000..98dbbcd1 --- /dev/null +++ b/re2c/test/american_fuzzy_lop/01.re @@ -0,0 +1 @@ +%{{" \ No newline at end of file -- 2.40.0