From f6cb83dadc7555c3681c251bfc5e366149874e4f Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 7 Nov 2016 09:46:18 +0000 Subject: [PATCH] Recognize newlines in character strings and classes. As for now, newline inside of a character string or class is an error: re2c should emit clear error message. Different styles of newlines should be recognized ("\n", "\r\n"). This commit fixes bug #162 reported by pauloscustodio: Reading files with "rb" causes issues in Windows --- re2c/bootstrap/src/ast/lex.cc | 746 +++++++++--------- re2c/src/ast/lex.re | 2 + re2c/test/code_points_error_esc.c | 1 - re2c/test/code_points_error_lf.c | 1 - re2c/test/cpoint_class_error_eol.c | 1 + re2c/test/cpoint_class_error_eol.re | 4 + re2c/test/cpoint_class_error_esc_eol.c | 1 + re2c/test/cpoint_class_error_esc_eol.re | 4 + re2c/test/cpoint_string_error_eol.c | 1 + ...error_lf.re => cpoint_string_error_eol.re} | 0 re2c/test/cpoint_string_error_esc_eol.c | 1 + ..._esc.re => cpoint_string_error_esc_eol.re} | 0 12 files changed, 394 insertions(+), 368 deletions(-) delete mode 100644 re2c/test/code_points_error_esc.c delete mode 100644 re2c/test/code_points_error_lf.c create mode 100644 re2c/test/cpoint_class_error_eol.c create mode 100644 re2c/test/cpoint_class_error_eol.re create mode 100644 re2c/test/cpoint_class_error_esc_eol.c create mode 100644 re2c/test/cpoint_class_error_esc_eol.re create mode 100644 re2c/test/cpoint_string_error_eol.c rename re2c/test/{code_points_error_lf.re => cpoint_string_error_eol.re} (100%) create mode 100644 re2c/test/cpoint_string_error_esc_eol.c rename re2c/test/{code_points_error_esc.re => cpoint_string_error_esc_eol.re} (100%) diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 2e76152d..e5d21cc3 100644 --- a/re2c/bootstrap/src/ast/lex.cc +++ b/re2c/bootstrap/src/ast/lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Sun Jul 30 16:18:18 2017 */ +/* Generated by re2c 0.16 on Sun Jul 30 18:04:13 2017 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include @@ -2260,284 +2260,291 @@ uint32_t Scanner::lex_cls_chr() unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 10) YYFILL(10); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy369; - if (yych == '\\') goto yy371; + if (yych <= '\f') { + if (yych == '\n') goto yy369; + } else { + if (yych <= '\r') goto yy371; + if (yych == '\\') goto yy372; + } ++YYCURSOR; -#line 538 "../src/ast/lex.re" +yy368: +#line 539 "../src/ast/lex.re" { return static_cast(tok[0]); } -#line 2269 "src/ast/lex.cc" +#line 2274 "src/ast/lex.cc" yy369: ++YYCURSOR; -#line 533 "../src/ast/lex.re" - { fatal_lc(l, c, "syntax error"); } -#line 2274 "src/ast/lex.cc" +#line 534 "../src/ast/lex.re" + { fatal_lc(l, c, "newline in character class"); } +#line 2279 "src/ast/lex.cc" yy371: yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '`') { - if (yych <= '7') { - if (yych <= ',') { - if (yych != '\n') goto yy373; + if (yych == '\n') goto yy369; + goto yy368; +yy372: + yych = (YYCTYPE)*++YYCURSOR; + if (yych <= ']') { + if (yych <= '3') { + if (yych <= '\r') { + if (yych == '\n') goto yy369; + if (yych >= '\r') goto yy375; } else { - if (yych <= '-') goto yy375; - if (yych <= '/') goto yy373; - if (yych <= '3') goto yy377; - goto yy379; + if (yych == '-') goto yy376; + if (yych >= '0') goto yy378; } } else { - if (yych <= 'X') { - if (yych == 'U') goto yy380; - if (yych <= 'W') goto yy373; - goto yy382; + if (yych <= 'W') { + if (yych <= '7') goto yy380; + if (yych == 'U') goto yy381; } else { + if (yych <= 'X') goto yy383; if (yych <= '[') goto yy373; - if (yych <= '\\') goto yy383; - if (yych <= ']') goto yy385; - goto yy373; + if (yych <= '\\') goto yy384; + goto yy386; } } } else { if (yych <= 'q') { if (yych <= 'e') { - if (yych <= 'a') goto yy387; - if (yych <= 'b') goto yy389; - goto yy373; + if (yych <= '`') goto yy373; + if (yych <= 'a') goto yy388; + if (yych <= 'b') goto yy390; } else { - if (yych <= 'f') goto yy391; - if (yych == 'n') goto yy393; - goto yy373; + if (yych <= 'f') goto yy392; + if (yych == 'n') goto yy394; } } else { if (yych <= 'u') { - if (yych <= 'r') goto yy395; + if (yych <= 'r') goto yy396; if (yych <= 's') goto yy373; - if (yych <= 't') goto yy397; - goto yy382; + if (yych <= 't') goto yy398; + goto yy383; } else { - if (yych <= 'v') goto yy399; - if (yych == 'x') goto yy401; - goto yy373; + if (yych <= 'v') goto yy400; + if (yych == 'x') goto yy402; } } } -#line 536 "../src/ast/lex.re" - { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 2325 "src/ast/lex.cc" yy373: ++YYCURSOR; -#line 551 "../src/ast/lex.re" +yy374: +#line 552 "../src/ast/lex.re" { warn.useless_escape(cline, get_column(), tok[1]); return static_cast(tok[1]); } -#line 2333 "src/ast/lex.cc" +#line 2336 "src/ast/lex.cc" yy375: + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '\n') goto yy369; + goto yy374; +yy376: ++YYCURSOR; -#line 549 "../src/ast/lex.re" +#line 550 "../src/ast/lex.re" { return static_cast('-'); } -#line 2338 "src/ast/lex.cc" -yy377: +#line 2345 "src/ast/lex.cc" +yy378: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy378; - if (yych <= '7') goto yy402; -yy378: -#line 535 "../src/ast/lex.re" - { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2347 "src/ast/lex.cc" + if (yych <= '/') goto yy379; + if (yych <= '7') goto yy403; yy379: - ++YYCURSOR; - goto yy378; +#line 536 "../src/ast/lex.re" + { fatal_lc(l, c, "syntax error in octal escape sequence"); } +#line 2354 "src/ast/lex.cc" yy380: + ++YYCURSOR; + goto yy379; +yy381: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy381; - if (yych <= '9') goto yy404; + if (yych <= '/') goto yy382; + if (yych <= '9') goto yy405; } else { - if (yych <= 'F') goto yy404; - if (yych <= '`') goto yy381; - if (yych <= 'f') goto yy404; + if (yych <= 'F') goto yy405; + if (yych <= '`') goto yy382; + if (yych <= 'f') goto yy405; } -yy381: -#line 534 "../src/ast/lex.re" - { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2365 "src/ast/lex.cc" yy382: +#line 535 "../src/ast/lex.re" + { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } +#line 2372 "src/ast/lex.cc" +yy383: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy381; - if (yych <= '9') goto yy405; - goto yy381; + if (yych <= '/') goto yy382; + if (yych <= '9') goto yy406; + goto yy382; } else { - if (yych <= 'F') goto yy405; - if (yych <= '`') goto yy381; - if (yych <= 'f') goto yy405; - goto yy381; + if (yych <= 'F') goto yy406; + if (yych <= '`') goto yy382; + if (yych <= 'f') goto yy406; + goto yy382; } -yy383: +yy384: ++YYCURSOR; -#line 548 "../src/ast/lex.re" +#line 549 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2383 "src/ast/lex.cc" -yy385: +#line 2390 "src/ast/lex.cc" +yy386: ++YYCURSOR; -#line 550 "../src/ast/lex.re" +#line 551 "../src/ast/lex.re" { return static_cast(']'); } -#line 2388 "src/ast/lex.cc" -yy387: +#line 2395 "src/ast/lex.cc" +yy388: ++YYCURSOR; -#line 541 "../src/ast/lex.re" +#line 542 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2393 "src/ast/lex.cc" -yy389: +#line 2400 "src/ast/lex.cc" +yy390: ++YYCURSOR; -#line 542 "../src/ast/lex.re" +#line 543 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2398 "src/ast/lex.cc" -yy391: +#line 2405 "src/ast/lex.cc" +yy392: ++YYCURSOR; -#line 543 "../src/ast/lex.re" +#line 544 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2403 "src/ast/lex.cc" -yy393: +#line 2410 "src/ast/lex.cc" +yy394: ++YYCURSOR; -#line 544 "../src/ast/lex.re" +#line 545 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2408 "src/ast/lex.cc" -yy395: +#line 2415 "src/ast/lex.cc" +yy396: ++YYCURSOR; -#line 545 "../src/ast/lex.re" +#line 546 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2413 "src/ast/lex.cc" -yy397: +#line 2420 "src/ast/lex.cc" +yy398: ++YYCURSOR; -#line 546 "../src/ast/lex.re" +#line 547 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2418 "src/ast/lex.cc" -yy399: +#line 2425 "src/ast/lex.cc" +yy400: ++YYCURSOR; -#line 547 "../src/ast/lex.re" +#line 548 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2423 "src/ast/lex.cc" -yy401: +#line 2430 "src/ast/lex.cc" +yy402: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy381; - if (yych <= '9') goto yy406; - goto yy381; + if (yych <= '/') goto yy382; + if (yych <= '9') goto yy407; + goto yy382; } else { - if (yych <= 'F') goto yy406; - if (yych <= '`') goto yy381; - if (yych <= 'f') goto yy406; - goto yy381; + if (yych <= 'F') goto yy407; + if (yych <= '`') goto yy382; + if (yych <= 'f') goto yy407; + goto yy382; } -yy402: - yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '/') goto yy403; - if (yych <= '7') goto yy407; yy403: + yych = (YYCTYPE)*++YYCURSOR; + if (yych <= '/') goto yy404; + if (yych <= '7') goto yy408; +yy404: YYCURSOR = YYMARKER; if (yyaccept == 0) { - goto yy378; + goto yy379; } else { - goto yy381; - } -yy404: - yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '@') { - if (yych <= '/') goto yy403; - if (yych <= '9') goto yy409; - goto yy403; - } else { - if (yych <= 'F') goto yy409; - if (yych <= '`') goto yy403; - if (yych <= 'f') goto yy409; - goto yy403; + goto yy382; } yy405: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy403; + if (yych <= '/') goto yy404; if (yych <= '9') goto yy410; - goto yy403; + goto yy404; } else { if (yych <= 'F') goto yy410; - if (yych <= '`') goto yy403; + if (yych <= '`') goto yy404; if (yych <= 'f') goto yy410; - goto yy403; + goto yy404; } yy406: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy403; + if (yych <= '/') goto yy404; if (yych <= '9') goto yy411; - goto yy403; + goto yy404; } else { if (yych <= 'F') goto yy411; - if (yych <= '`') goto yy403; + if (yych <= '`') goto yy404; if (yych <= 'f') goto yy411; - goto yy403; + goto yy404; } yy407: - ++YYCURSOR; -#line 540 "../src/ast/lex.re" - { return unesc_oct(tok, cur); } -#line 2488 "src/ast/lex.cc" -yy409: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy403; - if (yych <= '9') goto yy413; - goto yy403; + if (yych <= '/') goto yy404; + if (yych <= '9') goto yy412; + goto yy404; } else { - if (yych <= 'F') goto yy413; - if (yych <= '`') goto yy403; - if (yych <= 'f') goto yy413; - goto yy403; + if (yych <= 'F') goto yy412; + if (yych <= '`') goto yy404; + if (yych <= 'f') goto yy412; + goto yy404; } +yy408: + ++YYCURSOR; +#line 541 "../src/ast/lex.re" + { return unesc_oct(tok, cur); } +#line 2495 "src/ast/lex.cc" yy410: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy403; - if (yych <= '9') goto yy406; - goto yy403; + if (yych <= '/') goto yy404; + if (yych <= '9') goto yy414; + goto yy404; } else { - if (yych <= 'F') goto yy406; - if (yych <= '`') goto yy403; - if (yych <= 'f') goto yy406; - goto yy403; + if (yych <= 'F') goto yy414; + if (yych <= '`') goto yy404; + if (yych <= 'f') goto yy414; + goto yy404; } yy411: + yych = (YYCTYPE)*++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy404; + if (yych <= '9') goto yy407; + goto yy404; + } else { + if (yych <= 'F') goto yy407; + if (yych <= '`') goto yy404; + if (yych <= 'f') goto yy407; + goto yy404; + } +yy412: ++YYCURSOR; -#line 539 "../src/ast/lex.re" +#line 540 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2517 "src/ast/lex.cc" -yy413: +#line 2524 "src/ast/lex.cc" +yy414: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy403; - if (yych >= ':') goto yy403; + if (yych <= '/') goto yy404; + if (yych >= ':') goto yy404; } else { - if (yych <= 'F') goto yy414; - if (yych <= '`') goto yy403; - if (yych >= 'g') goto yy403; + if (yych <= 'F') goto yy415; + if (yych <= '`') goto yy404; + if (yych >= 'g') goto yy404; } -yy414: +yy415: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy403; - if (yych <= '9') goto yy405; - goto yy403; + if (yych <= '/') goto yy404; + if (yych <= '9') goto yy406; + goto yy404; } else { - if (yych <= 'F') goto yy405; - if (yych <= '`') goto yy403; - if (yych <= 'f') goto yy405; - goto yy403; + if (yych <= 'F') goto yy406; + if (yych <= '`') goto yy404; + if (yych <= 'f') goto yy406; + goto yy404; } } -#line 555 "../src/ast/lex.re" +#line 556 "../src/ast/lex.re" } @@ -2547,282 +2554,289 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) tok = cur; const uint32_t l = get_cline(), c = get_column(); -#line 2551 "src/ast/lex.cc" +#line 2558 "src/ast/lex.cc" { YYCTYPE yych; unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 10) YYFILL(10); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy419; - if (yych == '\\') goto yy421; + if (yych <= '\f') { + if (yych == '\n') goto yy420; + } else { + if (yych <= '\r') goto yy422; + if (yych == '\\') goto yy423; + } ++YYCURSOR; -#line 569 "../src/ast/lex.re" +yy419: +#line 571 "../src/ast/lex.re" { end = tok[0] == quote; return static_cast(tok[0]); } -#line 2565 "src/ast/lex.cc" -yy419: +#line 2577 "src/ast/lex.cc" +yy420: ++YYCURSOR; -#line 564 "../src/ast/lex.re" - { fatal_lc(l, c, "syntax error"); } -#line 2570 "src/ast/lex.cc" -yy421: +#line 566 "../src/ast/lex.re" + { fatal_lc(l, c, "newline in character string"); } +#line 2582 "src/ast/lex.cc" +yy422: yych = (YYCTYPE)*++YYCURSOR; - if (yych <= 'a') { - if (yych <= 'T') { - if (yych <= '/') { - if (yych != '\n') goto yy423; + if (yych == '\n') goto yy420; + goto yy419; +yy423: + yych = (YYCTYPE)*++YYCURSOR; + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '\f') { + if (yych == '\n') goto yy420; } else { - if (yych <= '3') goto yy425; - if (yych <= '7') goto yy427; - goto yy423; + if (yych <= '\r') goto yy426; + if (yych <= '/') goto yy424; + if (yych <= '3') goto yy427; + goto yy429; } } else { - if (yych <= 'X') { - if (yych <= 'U') goto yy428; - if (yych <= 'W') goto yy423; - goto yy430; + if (yych <= 'W') { + if (yych == 'U') goto yy430; } else { - if (yych == '\\') goto yy431; - if (yych <= '`') goto yy423; - goto yy433; + if (yych <= 'X') goto yy432; + if (yych == '\\') goto yy433; } } } else { - if (yych <= 'r') { - if (yych <= 'f') { - if (yych <= 'b') goto yy435; - if (yych <= 'e') goto yy423; - goto yy437; + if (yych <= 'q') { + if (yych <= 'e') { + if (yych <= 'a') goto yy435; + if (yych <= 'b') goto yy437; } else { - if (yych == 'n') goto yy439; - if (yych <= 'q') goto yy423; - goto yy441; + if (yych <= 'f') goto yy439; + if (yych == 'n') goto yy441; } } else { if (yych <= 'u') { - if (yych <= 's') goto yy423; - if (yych <= 't') goto yy443; - goto yy430; + if (yych <= 'r') goto yy443; + if (yych <= 's') goto yy424; + if (yych <= 't') goto yy445; + goto yy432; } else { - if (yych <= 'v') goto yy445; - if (yych == 'x') goto yy447; - goto yy423; + if (yych <= 'v') goto yy447; + if (yych == 'x') goto yy449; } } } -#line 567 "../src/ast/lex.re" - { fatal_lc(l, c, "syntax error in escape sequence"); } -#line 2618 "src/ast/lex.cc" -yy423: +yy424: ++YYCURSOR; -#line 583 "../src/ast/lex.re" +yy425: +#line 585 "../src/ast/lex.re" { if (tok[1] != quote) { warn.useless_escape(cline, get_column(), tok[1]); } return static_cast(tok[1]); } -#line 2628 "src/ast/lex.cc" -yy425: +#line 2638 "src/ast/lex.cc" +yy426: + yych = (YYCTYPE)*++YYCURSOR; + if (yych == '\n') goto yy420; + goto yy425; +yy427: yyaccept = 0; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych <= '/') goto yy426; - if (yych <= '7') goto yy448; -yy426: -#line 566 "../src/ast/lex.re" + if (yych <= '/') goto yy428; + if (yych <= '7') goto yy450; +yy428: +#line 568 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in octal escape sequence"); } -#line 2637 "src/ast/lex.cc" -yy427: +#line 2651 "src/ast/lex.cc" +yy429: ++YYCURSOR; - goto yy426; -yy428: + goto yy428; +yy430: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy429; - if (yych <= '9') goto yy450; + if (yych <= '/') goto yy431; + if (yych <= '9') goto yy452; } else { - if (yych <= 'F') goto yy450; - if (yych <= '`') goto yy429; - if (yych <= 'f') goto yy450; + if (yych <= 'F') goto yy452; + if (yych <= '`') goto yy431; + if (yych <= 'f') goto yy452; } -yy429: -#line 565 "../src/ast/lex.re" +yy431: +#line 567 "../src/ast/lex.re" { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } -#line 2655 "src/ast/lex.cc" -yy430: +#line 2669 "src/ast/lex.cc" +yy432: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy429; - if (yych <= '9') goto yy451; - goto yy429; + if (yych <= '/') goto yy431; + if (yych <= '9') goto yy453; + goto yy431; } else { - if (yych <= 'F') goto yy451; - if (yych <= '`') goto yy429; - if (yych <= 'f') goto yy451; - goto yy429; + if (yych <= 'F') goto yy453; + if (yych <= '`') goto yy431; + if (yych <= 'f') goto yy453; + goto yy431; } -yy431: +yy433: ++YYCURSOR; -#line 582 "../src/ast/lex.re" +#line 584 "../src/ast/lex.re" { return static_cast('\\'); } -#line 2673 "src/ast/lex.cc" -yy433: +#line 2687 "src/ast/lex.cc" +yy435: ++YYCURSOR; -#line 575 "../src/ast/lex.re" +#line 577 "../src/ast/lex.re" { return static_cast('\a'); } -#line 2678 "src/ast/lex.cc" -yy435: +#line 2692 "src/ast/lex.cc" +yy437: ++YYCURSOR; -#line 576 "../src/ast/lex.re" +#line 578 "../src/ast/lex.re" { return static_cast('\b'); } -#line 2683 "src/ast/lex.cc" -yy437: +#line 2697 "src/ast/lex.cc" +yy439: ++YYCURSOR; -#line 577 "../src/ast/lex.re" +#line 579 "../src/ast/lex.re" { return static_cast('\f'); } -#line 2688 "src/ast/lex.cc" -yy439: +#line 2702 "src/ast/lex.cc" +yy441: ++YYCURSOR; -#line 578 "../src/ast/lex.re" +#line 580 "../src/ast/lex.re" { return static_cast('\n'); } -#line 2693 "src/ast/lex.cc" -yy441: +#line 2707 "src/ast/lex.cc" +yy443: ++YYCURSOR; -#line 579 "../src/ast/lex.re" +#line 581 "../src/ast/lex.re" { return static_cast('\r'); } -#line 2698 "src/ast/lex.cc" -yy443: +#line 2712 "src/ast/lex.cc" +yy445: ++YYCURSOR; -#line 580 "../src/ast/lex.re" +#line 582 "../src/ast/lex.re" { return static_cast('\t'); } -#line 2703 "src/ast/lex.cc" -yy445: +#line 2717 "src/ast/lex.cc" +yy447: ++YYCURSOR; -#line 581 "../src/ast/lex.re" +#line 583 "../src/ast/lex.re" { return static_cast('\v'); } -#line 2708 "src/ast/lex.cc" -yy447: +#line 2722 "src/ast/lex.cc" +yy449: yyaccept = 1; yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); if (yych <= '@') { - if (yych <= '/') goto yy429; - if (yych <= '9') goto yy452; - goto yy429; + if (yych <= '/') goto yy431; + if (yych <= '9') goto yy454; + goto yy431; } else { - if (yych <= 'F') goto yy452; - if (yych <= '`') goto yy429; - if (yych <= 'f') goto yy452; - goto yy429; + if (yych <= 'F') goto yy454; + if (yych <= '`') goto yy431; + if (yych <= 'f') goto yy454; + goto yy431; } -yy448: +yy450: yych = (YYCTYPE)*++YYCURSOR; - if (yych <= '/') goto yy449; - if (yych <= '7') goto yy453; -yy449: + if (yych <= '/') goto yy451; + if (yych <= '7') goto yy455; +yy451: YYCURSOR = YYMARKER; if (yyaccept == 0) { - goto yy426; + goto yy428; } else { - goto yy429; + goto yy431; } -yy450: +yy452: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych <= '9') goto yy455; - goto yy449; + if (yych <= '/') goto yy451; + if (yych <= '9') goto yy457; + goto yy451; } else { - if (yych <= 'F') goto yy455; - if (yych <= '`') goto yy449; - if (yych <= 'f') goto yy455; - goto yy449; + if (yych <= 'F') goto yy457; + if (yych <= '`') goto yy451; + if (yych <= 'f') goto yy457; + goto yy451; } -yy451: +yy453: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych <= '9') goto yy456; - goto yy449; + if (yych <= '/') goto yy451; + if (yych <= '9') goto yy458; + goto yy451; } else { - if (yych <= 'F') goto yy456; - if (yych <= '`') goto yy449; - if (yych <= 'f') goto yy456; - goto yy449; + if (yych <= 'F') goto yy458; + if (yych <= '`') goto yy451; + if (yych <= 'f') goto yy458; + goto yy451; } -yy452: +yy454: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych <= '9') goto yy457; - goto yy449; + if (yych <= '/') goto yy451; + if (yych <= '9') goto yy459; + goto yy451; } else { - if (yych <= 'F') goto yy457; - if (yych <= '`') goto yy449; - if (yych <= 'f') goto yy457; - goto yy449; + if (yych <= 'F') goto yy459; + if (yych <= '`') goto yy451; + if (yych <= 'f') goto yy459; + goto yy451; } -yy453: +yy455: ++YYCURSOR; -#line 574 "../src/ast/lex.re" +#line 576 "../src/ast/lex.re" { return unesc_oct(tok, cur); } -#line 2773 "src/ast/lex.cc" -yy455: +#line 2787 "src/ast/lex.cc" +yy457: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych <= '9') goto yy459; - goto yy449; + if (yych <= '/') goto yy451; + if (yych <= '9') goto yy461; + goto yy451; } else { - if (yych <= 'F') goto yy459; - if (yych <= '`') goto yy449; - if (yych <= 'f') goto yy459; - goto yy449; + if (yych <= 'F') goto yy461; + if (yych <= '`') goto yy451; + if (yych <= 'f') goto yy461; + goto yy451; } -yy456: +yy458: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych <= '9') goto yy452; - goto yy449; + if (yych <= '/') goto yy451; + if (yych <= '9') goto yy454; + goto yy451; } else { - if (yych <= 'F') goto yy452; - if (yych <= '`') goto yy449; - if (yych <= 'f') goto yy452; - goto yy449; + if (yych <= 'F') goto yy454; + if (yych <= '`') goto yy451; + if (yych <= 'f') goto yy454; + goto yy451; } -yy457: +yy459: ++YYCURSOR; -#line 573 "../src/ast/lex.re" +#line 575 "../src/ast/lex.re" { return unesc_hex(tok, cur); } -#line 2802 "src/ast/lex.cc" -yy459: +#line 2816 "src/ast/lex.cc" +yy461: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych >= ':') goto yy449; + if (yych <= '/') goto yy451; + if (yych >= ':') goto yy451; } else { - if (yych <= 'F') goto yy460; - if (yych <= '`') goto yy449; - if (yych >= 'g') goto yy449; + if (yych <= 'F') goto yy462; + if (yych <= '`') goto yy451; + if (yych >= 'g') goto yy451; } -yy460: +yy462: yych = (YYCTYPE)*++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy449; - if (yych <= '9') goto yy451; - goto yy449; + if (yych <= '/') goto yy451; + if (yych <= '9') goto yy453; + goto yy451; } else { - if (yych <= 'F') goto yy451; - if (yych <= '`') goto yy449; - if (yych <= 'f') goto yy451; - goto yy449; + if (yych <= 'F') goto yy453; + if (yych <= '`') goto yy451; + if (yych <= 'f') goto yy453; + goto yy451; } } -#line 589 "../src/ast/lex.re" +#line 591 "../src/ast/lex.re" } @@ -2842,7 +2856,7 @@ void Scanner::set_sourceline () sourceline: tok = cur; -#line 2846 "src/ast/lex.cc" +#line 2860 "src/ast/lex.cc" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -2882,23 +2896,23 @@ sourceline: if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = (YYCTYPE)*YYCURSOR; if (yych <= '!') { - if (yych == '\n') goto yy465; + if (yych == '\n') goto yy467; } else { - if (yych <= '"') goto yy467; - if (yych <= '0') goto yy463; - if (yych <= '9') goto yy468; + if (yych <= '"') goto yy469; + if (yych <= '0') goto yy465; + if (yych <= '9') goto yy470; } -yy463: +yy465: ++YYCURSOR; -yy464: -#line 631 "../src/ast/lex.re" +yy466: +#line 633 "../src/ast/lex.re" { goto sourceline; } -#line 2899 "src/ast/lex.cc" -yy465: +#line 2913 "src/ast/lex.cc" +yy467: ++YYCURSOR; -#line 619 "../src/ast/lex.re" +#line 621 "../src/ast/lex.re" { if (cur == eof) { @@ -2911,19 +2925,19 @@ yy465: tok = cur; return; } -#line 2915 "src/ast/lex.cc" -yy467: +#line 2929 "src/ast/lex.cc" +yy469: yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy464; - goto yy472; -yy468: + if (yych == '\n') goto yy466; + goto yy474; +yy470: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; if (yybm[0+yych] & 64) { - goto yy468; + goto yy470; } -#line 608 "../src/ast/lex.re" +#line 610 "../src/ast/lex.re" { if (!s_to_u32_unsafe (tok, cur, cline)) { @@ -2931,37 +2945,37 @@ yy468: } goto sourceline; } -#line 2935 "src/ast/lex.cc" -yy471: +#line 2949 "src/ast/lex.cc" +yy473: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; -yy472: +yy474: if (yybm[0+yych] & 128) { - goto yy471; + goto yy473; } - if (yych <= '\n') goto yy473; - if (yych <= '"') goto yy474; - goto yy476; -yy473: + if (yych <= '\n') goto yy475; + if (yych <= '"') goto yy476; + goto yy478; +yy475: YYCURSOR = YYMARKER; - goto yy464; -yy474: + goto yy466; +yy476: ++YYCURSOR; -#line 615 "../src/ast/lex.re" +#line 617 "../src/ast/lex.re" { escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes goto sourceline; } -#line 2957 "src/ast/lex.cc" -yy476: +#line 2971 "src/ast/lex.cc" +yy478: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = (YYCTYPE)*YYCURSOR; - if (yych == '\n') goto yy473; - goto yy471; + if (yych == '\n') goto yy475; + goto yy473; } -#line 634 "../src/ast/lex.re" +#line 636 "../src/ast/lex.re" } diff --git a/re2c/src/ast/lex.re b/re2c/src/ast/lex.re index 9220f2a3..3ff738d9 100644 --- a/re2c/src/ast/lex.re +++ b/re2c/src/ast/lex.re @@ -531,6 +531,7 @@ uint32_t Scanner::lex_cls_chr() const uint32_t l = get_cline(), c = get_column(); /*!re2c * { fatal_lc(l, c, "syntax error"); } + esc? eol { fatal_lc(l, c, "newline in character class"); } esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); } esc { fatal_lc(l, c, "syntax error in escape sequence"); } @@ -562,6 +563,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end) const uint32_t l = get_cline(), c = get_column(); /*!re2c * { fatal_lc(l, c, "syntax error"); } + esc? eol { fatal_lc(l, c, "newline in character string"); } esc [xXuU] { fatal_lc(l, c, "syntax error in hexadecimal escape sequence"); } esc [0-7] { fatal_lc(l, c, "syntax error in octal escape sequence"); } esc { fatal_lc(l, c, "syntax error in escape sequence"); } diff --git a/re2c/test/code_points_error_esc.c b/re2c/test/code_points_error_esc.c deleted file mode 100644 index 3b13a536..00000000 --- a/re2c/test/code_points_error_esc.c +++ /dev/null @@ -1 +0,0 @@ -re2c: error: line 2, column 5: syntax error in escape sequence diff --git a/re2c/test/code_points_error_lf.c b/re2c/test/code_points_error_lf.c deleted file mode 100644 index 0723e535..00000000 --- a/re2c/test/code_points_error_lf.c +++ /dev/null @@ -1 +0,0 @@ -re2c: error: line 2, column 5: syntax error diff --git a/re2c/test/cpoint_class_error_eol.c b/re2c/test/cpoint_class_error_eol.c new file mode 100644 index 00000000..1bfb71a6 --- /dev/null +++ b/re2c/test/cpoint_class_error_eol.c @@ -0,0 +1 @@ +re2c: error: line 2, column 4: newline in character class diff --git a/re2c/test/cpoint_class_error_eol.re b/re2c/test/cpoint_class_error_eol.re new file mode 100644 index 00000000..4d362b06 --- /dev/null +++ b/re2c/test/cpoint_class_error_eol.re @@ -0,0 +1,4 @@ +/*!re2c +[abc +de] {} +*/ diff --git a/re2c/test/cpoint_class_error_esc_eol.c b/re2c/test/cpoint_class_error_esc_eol.c new file mode 100644 index 00000000..1bfb71a6 --- /dev/null +++ b/re2c/test/cpoint_class_error_esc_eol.c @@ -0,0 +1 @@ +re2c: error: line 2, column 4: newline in character class diff --git a/re2c/test/cpoint_class_error_esc_eol.re b/re2c/test/cpoint_class_error_esc_eol.re new file mode 100644 index 00000000..facfeb0d --- /dev/null +++ b/re2c/test/cpoint_class_error_esc_eol.re @@ -0,0 +1,4 @@ +/*!re2c +[abc\ +de] {} +*/ diff --git a/re2c/test/cpoint_string_error_eol.c b/re2c/test/cpoint_string_error_eol.c new file mode 100644 index 00000000..a3a2ccaa --- /dev/null +++ b/re2c/test/cpoint_string_error_eol.c @@ -0,0 +1 @@ +re2c: error: line 2, column 5: newline in character string diff --git a/re2c/test/code_points_error_lf.re b/re2c/test/cpoint_string_error_eol.re similarity index 100% rename from re2c/test/code_points_error_lf.re rename to re2c/test/cpoint_string_error_eol.re diff --git a/re2c/test/cpoint_string_error_esc_eol.c b/re2c/test/cpoint_string_error_esc_eol.c new file mode 100644 index 00000000..a3a2ccaa --- /dev/null +++ b/re2c/test/cpoint_string_error_esc_eol.c @@ -0,0 +1 @@ +re2c: error: line 2, column 5: newline in character string diff --git a/re2c/test/code_points_error_esc.re b/re2c/test/cpoint_string_error_esc_eol.re similarity index 100% rename from re2c/test/code_points_error_esc.re rename to re2c/test/cpoint_string_error_esc_eol.re -- 2.40.0