From 27156203d33290454ec6375612712be3f37c1c77 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 5 Aug 2019 23:33:10 +0100 Subject: [PATCH] Allow to reset 're2c:eof' configuration. The ability to reset this configuration is necessary in order to be able to mix re2c blocks that use EOF rule and blocks that don't. This fixes bug #254: "Turn off re2c:eof". --- bootstrap/doc/re2c.1 | 8 +- bootstrap/src/parse/lex_conf.cc | 407 +++++++++--------- doc/manual/configurations/configurations.rst_ | 6 + src/parse/lex_conf.re | 5 +- test/eof/eof_07.c | 2 +- test/eof/eof_09.i.c | 88 ++++ test/eof/eof_09.i.re | 29 ++ 7 files changed, 334 insertions(+), 211 deletions(-) create mode 100644 test/eof/eof_09.i.c create mode 100644 test/eof/eof_09.i.re diff --git a/bootstrap/doc/re2c.1 b/bootstrap/doc/re2c.1 index a3e27bd0..9c60fe21 100644 --- a/bootstrap/doc/re2c.1 +++ b/bootstrap/doc/re2c.1 @@ -834,6 +834,12 @@ Replaces \fBYYSTAGN\fP identifier with the specified string. .B \fBre2c:define:YYSTAGP = \(aqYYSTAGP\(aq;\fP Replaces \fBYYSTAGP\fP identifier with the specified string. .TP +.B \fBre2c:eof = \-1;\fP +Specifies the sentinel symbol used with EOF rule \fB$\fP to check for the end +of input in the generated lexer. Default value is \fB\-1\fP (EOF rule is not +used). Other possible values include all valid code points. Only decimal +numbers are recognized. +.TP .B \fBre2c:flags:8\fP or \fBre2c:flags:utf\-8\fP Same as \fB\-8 \-\-utf\-8\fP command\-line option. .TP @@ -2363,6 +2369,6 @@ Since then it has been developed and maintained by mutiple volunteers; mots notably, Brain Young, Marcus Boerger, Dan Nuffer and Ulya Trofimovich. .SH VERSION INFORMATION .sp -This manpage describes re2c version 1.1.1, package date 02 Aug 2019. +This manpage describes re2c version 1.2, package date 05 Aug 2019. .\" Generated by docutils manpage writer. . diff --git a/bootstrap/src/parse/lex_conf.cc b/bootstrap/src/parse/lex_conf.cc index 76d180af..275fdb57 100644 --- a/bootstrap/src/parse/lex_conf.cc +++ b/bootstrap/src/parse/lex_conf.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Fri Aug 2 10:49:53 2019 */ +/* Generated by re2c 1.1.1 on Mon Aug 5 23:14:16 2019 */ #line 1 "../src/parse/lex_conf.re" #include "src/util/c99_stdint.h" #include @@ -107,7 +107,7 @@ void Scanner::lex_conf(Opt &opts) } } yy2: -#line 176 "../src/parse/lex_conf.re" +#line 173 "../src/parse/lex_conf.re" { msg.fatal(tok_loc(), "unrecognized configuration '%.*s'", static_cast(cur - tok), tok); @@ -233,13 +233,10 @@ yy29: #line 74 "../src/parse/lex_conf.re" { const int32_t eof = lex_conf_number(); - if (eof < 0) { - msg.fatal(cur_loc(), "EOF symbol cannot have negative value"); - } - opts.set_eof(static_cast(eof)); + opts.set_eof(eof < 0 ? NOEOF : static_cast(eof)); return; } -#line 243 "src/parse/lex_conf.cc" +#line 240 "src/parse/lex_conf.cc" yy31: yych = (unsigned char)*++cur; if (yych == 'g') goto yy43; @@ -525,7 +522,7 @@ yy93: } #line 68 "../src/parse/lex_conf.re" { lex_conf_enc(Enc::UTF8, opts); return; } -#line 529 "src/parse/lex_conf.cc" +#line 526 "src/parse/lex_conf.cc" yy95: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { @@ -538,7 +535,7 @@ yy95: opts.set_posix_semantics(b); return; } -#line 542 "src/parse/lex_conf.cc" +#line 539 "src/parse/lex_conf.cc" yy97: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { @@ -546,7 +543,7 @@ yy97: } #line 51 "../src/parse/lex_conf.re" { opts.set_tags (lex_conf_bool()); return; } -#line 550 "src/parse/lex_conf.cc" +#line 547 "src/parse/lex_conf.cc" yy99: yych = (unsigned char)*++cur; if (yych <= 'Z') { @@ -567,7 +564,7 @@ yy99: yy100: #line 46 "../src/parse/lex_conf.re" { opts.set_bFlag (lex_conf_bool()); return; } -#line 571 "src/parse/lex_conf.cc" +#line 568 "src/parse/lex_conf.cc" yy101: yych = (unsigned char)*++cur; if (yych == 'a') goto yy144; @@ -593,7 +590,7 @@ yy102: yy103: #line 47 "../src/parse/lex_conf.re" { opts.set_dFlag (lex_conf_bool()); return; } -#line 597 "src/parse/lex_conf.cc" +#line 594 "src/parse/lex_conf.cc" yy104: yych = (unsigned char)*++cur; if (yych <= '_') { @@ -619,7 +616,7 @@ yy104: yy105: #line 64 "../src/parse/lex_conf.re" { lex_conf_enc(Enc::EBCDIC, opts); return; } -#line 623 "src/parse/lex_conf.cc" +#line 620 "src/parse/lex_conf.cc" yy106: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { @@ -627,7 +624,7 @@ yy106: } #line 48 "../src/parse/lex_conf.re" { opts.set_gFlag (lex_conf_bool()); return; } -#line 631 "src/parse/lex_conf.cc" +#line 628 "src/parse/lex_conf.cc" yy108: yych = (unsigned char)*++cur; if (yych <= 'Z') { @@ -648,7 +645,7 @@ yy108: yy109: #line 49 "../src/parse/lex_conf.re" { opts.set_iFlag (lex_conf_bool()); return; } -#line 652 "src/parse/lex_conf.cc" +#line 649 "src/parse/lex_conf.cc" yy110: yych = (unsigned char)*++cur; if (yych == 'e') goto yy151; @@ -674,7 +671,7 @@ yy111: yy112: #line 54 "../src/parse/lex_conf.re" { opts.set_output_file (lex_conf_string()); return; } -#line 678 "src/parse/lex_conf.cc" +#line 675 "src/parse/lex_conf.cc" yy113: yych = (unsigned char)*++cur; if (yych == 'o') goto yy154; @@ -686,7 +683,7 @@ yy114: } #line 50 "../src/parse/lex_conf.re" { opts.set_sFlag (lex_conf_bool()); return; } -#line 690 "src/parse/lex_conf.cc" +#line 687 "src/parse/lex_conf.cc" yy116: yych = (unsigned char)*++cur; if (yych <= '^') { @@ -709,7 +706,7 @@ yy116: yy117: #line 55 "../src/parse/lex_conf.re" { opts.set_header_file (lex_conf_string()); return; } -#line 713 "src/parse/lex_conf.cc" +#line 710 "src/parse/lex_conf.cc" yy118: yych = (unsigned char)*++cur; if (yych <= '^') { @@ -733,7 +730,7 @@ yy118: yy119: #line 65 "../src/parse/lex_conf.re" { lex_conf_enc(Enc::UTF32, opts); return; } -#line 737 "src/parse/lex_conf.cc" +#line 734 "src/parse/lex_conf.cc" yy120: yych = (unsigned char)*++cur; if (yych <= 'Z') { @@ -754,7 +751,7 @@ yy120: yy121: #line 66 "../src/parse/lex_conf.re" { lex_conf_enc(Enc::UCS2, opts); return; } -#line 758 "src/parse/lex_conf.cc" +#line 755 "src/parse/lex_conf.cc" yy122: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { @@ -762,7 +759,7 @@ yy122: } #line 67 "../src/parse/lex_conf.re" { lex_conf_enc(Enc::UTF16, opts); return; } -#line 766 "src/parse/lex_conf.cc" +#line 763 "src/parse/lex_conf.cc" yy124: yych = (unsigned char)*++cur; if (yych <= 'r') goto yy4; @@ -961,9 +958,9 @@ yy170: if (yybm[0+yych] & 32) { goto yy3; } -#line 111 "../src/parse/lex_conf.re" +#line 108 "../src/parse/lex_conf.re" { opts.set_yybmHexTable (lex_conf_bool()); return; } -#line 967 "src/parse/lex_conf.cc" +#line 964 "src/parse/lex_conf.cc" yy172: yych = (unsigned char)*++cur; if (yych == 'v') goto yy212; @@ -1000,9 +997,9 @@ yy179: } if (yych == '@') goto yy220; yy180: -#line 95 "../src/parse/lex_conf.re" +#line 92 "../src/parse/lex_conf.re" { opts.set_condGoto (lex_conf_string ()); return; } -#line 1006 "src/parse/lex_conf.cc" +#line 1003 "src/parse/lex_conf.cc" yy181: yych = (unsigned char)*++cur; if (yych == 'r') goto yy222; @@ -1149,9 +1146,9 @@ yy213: if (yybm[0+yych] & 32) { goto yy3; } -#line 158 "../src/parse/lex_conf.re" +#line 155 "../src/parse/lex_conf.re" { opts.set_bEmitYYCh (lex_conf_bool()); return; } -#line 1155 "src/parse/lex_conf.cc" +#line 1152 "src/parse/lex_conf.cc" yy215: yych = (unsigned char)*++cur; if (yych == 'e') goto yy264; @@ -1207,9 +1204,9 @@ yy223: if (yybm[0+yych] & 32) { goto yy3; } -#line 91 "../src/parse/lex_conf.re" +#line 88 "../src/parse/lex_conf.re" { opts.set_condPrefix (lex_conf_string ()); return; } -#line 1213 "src/parse/lex_conf.cc" +#line 1210 "src/parse/lex_conf.cc" yy225: yych = (unsigned char)*++cur; if (yych == 'A') goto yy271; @@ -1334,7 +1331,7 @@ yy251: if (yybm[0+yych] & 32) { goto yy3; } -#line 144 "../src/parse/lex_conf.re" +#line 141 "../src/parse/lex_conf.re" { const int32_t n = lex_conf_number (); if (n < 0) { @@ -1343,7 +1340,7 @@ yy251: opts.set_topIndent (static_cast (n)); return; } -#line 1347 "src/parse/lex_conf.cc" +#line 1344 "src/parse/lex_conf.cc" yy253: yych = (unsigned char)*++cur; if (yych == 'l') goto yy304; @@ -1378,9 +1375,9 @@ yy256: } } yy257: -#line 171 "../src/parse/lex_conf.re" +#line 168 "../src/parse/lex_conf.re" { opts.set_startlabel (lex_conf_string()); return; } -#line 1384 "src/parse/lex_conf.cc" +#line 1381 "src/parse/lex_conf.cc" yy258: yych = (unsigned char)*++cur; if (yych == 't') goto yy312; @@ -1530,7 +1527,7 @@ yy293: } #line 71 "../src/parse/lex_conf.re" { lex_conf_input(opts); return; } -#line 1534 "src/parse/lex_conf.cc" +#line 1531 "src/parse/lex_conf.cc" yy295: yych = (unsigned char)*++cur; if (yych == 'd') goto yy351; @@ -1580,9 +1577,9 @@ yy306: if (yybm[0+yych] & 32) { goto yy3; } -#line 167 "../src/parse/lex_conf.re" +#line 164 "../src/parse/lex_conf.re" { opts.set_labelPrefix (lex_conf_string ()); return; } -#line 1586 "src/parse/lex_conf.cc" +#line 1583 "src/parse/lex_conf.cc" yy308: ++cur; if (lim <= cur) YYFILL(1); @@ -1618,9 +1615,9 @@ yy312: if (yybm[0+yych] & 32) { goto yy3; } -#line 106 "../src/parse/lex_conf.re" +#line 103 "../src/parse/lex_conf.re" { opts.set_bUseStateAbort (lex_conf_bool()); return; } -#line 1624 "src/parse/lex_conf.cc" +#line 1621 "src/parse/lex_conf.cc" yy314: yych = (unsigned char)*++cur; if (yych == 'a') goto yy367; @@ -1634,9 +1631,9 @@ yy316: if (yybm[0+yych] & 32) { goto yy3; } -#line 140 "../src/parse/lex_conf.re" +#line 137 "../src/parse/lex_conf.re" { opts.set_tags_prefix (lex_conf_string ()); return; } -#line 1640 "src/parse/lex_conf.cc" +#line 1637 "src/parse/lex_conf.cc" yy318: yych = (unsigned char)*++cur; if (yych <= 'c') { @@ -1678,9 +1675,9 @@ yy324: } if (yych == '@') goto yy380; yy325: -#line 93 "../src/parse/lex_conf.re" +#line 90 "../src/parse/lex_conf.re" { opts.set_condDivider (lex_conf_string ()); return; } -#line 1684 "src/parse/lex_conf.cc" +#line 1681 "src/parse/lex_conf.cc" yy326: yych = (unsigned char)*++cur; if (yych == 'n') goto yy381; @@ -1826,9 +1823,9 @@ yy360: if (yybm[0+yych] & 32) { goto yy3; } -#line 105 "../src/parse/lex_conf.re" +#line 102 "../src/parse/lex_conf.re" { opts.set_yynext (lex_conf_string ()); return; } -#line 1832 "src/parse/lex_conf.cc" +#line 1829 "src/parse/lex_conf.cc" yy362: yych = (unsigned char)*++cur; if (yych <= '0') goto yy221; @@ -1838,9 +1835,9 @@ yy363: ++cur; yy364: cur = ctx; -#line 170 "../src/parse/lex_conf.re" +#line 167 "../src/parse/lex_conf.re" { opts.set_startlabel_force (lex_conf_bool()); return; } -#line 1844 "src/parse/lex_conf.cc" +#line 1841 "src/parse/lex_conf.cc" yy365: ++cur; if (lim <= cur) YYFILL(1); @@ -1887,9 +1884,9 @@ yy375: if (yybm[0+yych] & 32) { goto yy3; } -#line 165 "../src/parse/lex_conf.re" +#line 162 "../src/parse/lex_conf.re" { opts.set_fill_check (lex_conf_bool()); return; } -#line 1893 "src/parse/lex_conf.cc" +#line 1890 "src/parse/lex_conf.cc" yy377: yych = (unsigned char)*++cur; if (yych == 'e') goto yy431; @@ -1958,9 +1955,9 @@ yy389: } } yy390: -#line 160 "../src/parse/lex_conf.re" +#line 157 "../src/parse/lex_conf.re" { opts.set_fill (lex_conf_string ()); return; } -#line 1964 "src/parse/lex_conf.cc" +#line 1961 "src/parse/lex_conf.cc" yy391: yych = (unsigned char)*++cur; if (yych == 'O') goto yy450; @@ -1991,9 +1988,9 @@ yy397: if (yybm[0+yych] & 32) { goto yy3; } -#line 127 "../src/parse/lex_conf.re" +#line 124 "../src/parse/lex_conf.re" { opts.set_yypeek (lex_conf_string ()); return; } -#line 1997 "src/parse/lex_conf.cc" +#line 1994 "src/parse/lex_conf.cc" yy399: yych = (unsigned char)*++cur; if (yych == 'O') goto yy460; @@ -2011,9 +2008,9 @@ yy402: if (yybm[0+yych] & 32) { goto yy3; } -#line 128 "../src/parse/lex_conf.re" +#line 125 "../src/parse/lex_conf.re" { opts.set_yyskip (lex_conf_string ()); return; } -#line 2017 "src/parse/lex_conf.cc" +#line 2014 "src/parse/lex_conf.cc" yy404: yych = (unsigned char)*++cur; if (yych == 'N') goto yy463; @@ -2075,9 +2072,9 @@ yy417: if (yybm[0+yych] & 32) { goto yy3; } -#line 143 "../src/parse/lex_conf.re" +#line 140 "../src/parse/lex_conf.re" { opts.set_indString (lex_conf_string ()); return; } -#line 2081 "src/parse/lex_conf.cc" +#line 2078 "src/parse/lex_conf.cc" yy419: yych = (unsigned char)*++cur; if (yych == 'a') goto yy479; @@ -2099,17 +2096,17 @@ yy423: if (yybm[0+yych] & 32) { goto yy3; } -#line 110 "../src/parse/lex_conf.re" +#line 107 "../src/parse/lex_conf.re" { opts.set_yybm (lex_conf_string ()); return; } -#line 2105 "src/parse/lex_conf.cc" +#line 2102 "src/parse/lex_conf.cc" yy425: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 156 "../src/parse/lex_conf.re" +#line 153 "../src/parse/lex_conf.re" { opts.set_yych (lex_conf_string ()); return; } -#line 2113 "src/parse/lex_conf.cc" +#line 2110 "src/parse/lex_conf.cc" yy427: yych = (unsigned char)*++cur; if (yych == 'a') goto yy483; @@ -2131,9 +2128,9 @@ yy431: if (yybm[0+yych] & 32) { goto yy3; } -#line 161 "../src/parse/lex_conf.re" +#line 158 "../src/parse/lex_conf.re" { opts.set_fill_use (lex_conf_bool()); return; } -#line 2137 "src/parse/lex_conf.cc" +#line 2134 "src/parse/lex_conf.cc" yy433: yych = (unsigned char)*++cur; if (yych == 't') goto yy487; @@ -2148,17 +2145,17 @@ yy435: goto yy221; yy436: ++cur; -#line 96 "../src/parse/lex_conf.re" +#line 93 "../src/parse/lex_conf.re" { opts.set_condGotoParam (lex_conf_string ()); return; } -#line 2154 "src/parse/lex_conf.cc" +#line 2151 "src/parse/lex_conf.cc" yy438: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 92 "../src/parse/lex_conf.re" +#line 89 "../src/parse/lex_conf.re" { opts.set_condEnumPrefix (lex_conf_string ()); return; } -#line 2162 "src/parse/lex_conf.cc" +#line 2159 "src/parse/lex_conf.cc" yy440: yych = (unsigned char)*++cur; if (yych == 'P') goto yy491; @@ -2176,9 +2173,9 @@ yy443: if (yybm[0+yych] & 32) { goto yy3; } -#line 155 "../src/parse/lex_conf.re" +#line 152 "../src/parse/lex_conf.re" { opts.set_yyctype (lex_conf_string ()); return; } -#line 2182 "src/parse/lex_conf.cc" +#line 2179 "src/parse/lex_conf.cc" yy445: yych = (unsigned char)*++cur; if (yych == 'R') goto yy495; @@ -2188,9 +2185,9 @@ yy446: if (yybm[0+yych] & 32) { goto yy3; } -#line 153 "../src/parse/lex_conf.re" +#line 150 "../src/parse/lex_conf.re" { opts.set_yydebug (lex_conf_string ()); return; } -#line 2194 "src/parse/lex_conf.cc" +#line 2191 "src/parse/lex_conf.cc" yy448: yych = (unsigned char)*++cur; if (yych == 'n') goto yy497; @@ -2216,9 +2213,9 @@ yy453: if (yybm[0+yych] & 32) { goto yy3; } -#line 125 "../src/parse/lex_conf.re" +#line 122 "../src/parse/lex_conf.re" { opts.set_yylimit (lex_conf_string ()); return; } -#line 2222 "src/parse/lex_conf.cc" +#line 2219 "src/parse/lex_conf.cc" yy455: yych = (unsigned char)*++cur; if (yych == 'R') goto yy502; @@ -2228,17 +2225,17 @@ yy456: if (yybm[0+yych] & 32) { goto yy3; } -#line 137 "../src/parse/lex_conf.re" +#line 134 "../src/parse/lex_conf.re" { opts.set_yymtagn (lex_conf_string ()); return; } -#line 2234 "src/parse/lex_conf.cc" +#line 2231 "src/parse/lex_conf.cc" yy458: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 138 "../src/parse/lex_conf.re" +#line 135 "../src/parse/lex_conf.re" { opts.set_yymtagp (lex_conf_string ()); return; } -#line 2242 "src/parse/lex_conf.cc" +#line 2239 "src/parse/lex_conf.cc" yy460: yych = (unsigned char)*++cur; if (yych == 'R') goto yy504; @@ -2256,17 +2253,17 @@ yy463: if (yybm[0+yych] & 32) { goto yy3; } -#line 135 "../src/parse/lex_conf.re" +#line 132 "../src/parse/lex_conf.re" { opts.set_yystagn (lex_conf_string ()); return; } -#line 2262 "src/parse/lex_conf.cc" +#line 2259 "src/parse/lex_conf.cc" yy465: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 136 "../src/parse/lex_conf.re" +#line 133 "../src/parse/lex_conf.re" { opts.set_yystagp (lex_conf_string ()); return; } -#line 2270 "src/parse/lex_conf.cc" +#line 2267 "src/parse/lex_conf.cc" yy467: yych = (unsigned char)*++cur; if (yych == 'o') goto yy507; @@ -2356,7 +2353,7 @@ yy488: if (yybm[0+yych] & 32) { goto yy3; } -#line 112 "../src/parse/lex_conf.re" +#line 109 "../src/parse/lex_conf.re" { const int32_t n = lex_conf_number (); if (n < 0) { @@ -2365,7 +2362,7 @@ yy488: opts.set_cGotoThreshold (static_cast (n)); return; } -#line 2369 "src/parse/lex_conf.cc" +#line 2366 "src/parse/lex_conf.cc" yy490: yych = (unsigned char)*++cur; if (yych == 'n') goto yy531; @@ -2389,9 +2386,9 @@ yy491: } } yy492: -#line 129 "../src/parse/lex_conf.re" +#line 126 "../src/parse/lex_conf.re" { opts.set_yybackup (lex_conf_string ()); return; } -#line 2395 "src/parse/lex_conf.cc" +#line 2392 "src/parse/lex_conf.cc" yy493: yych = (unsigned char)*++cur; if (yych == 'P') goto yy533; @@ -2405,9 +2402,9 @@ yy495: if (yybm[0+yych] & 32) { goto yy3; } -#line 122 "../src/parse/lex_conf.re" +#line 119 "../src/parse/lex_conf.re" { opts.set_yycursor (lex_conf_string ()); return; } -#line 2411 "src/parse/lex_conf.cc" +#line 2408 "src/parse/lex_conf.cc" yy497: yych = (unsigned char)*++cur; if (yych == 'a') goto yy535; @@ -2433,9 +2430,9 @@ yy502: if (yybm[0+yych] & 32) { goto yy3; } -#line 123 "../src/parse/lex_conf.re" +#line 120 "../src/parse/lex_conf.re" { opts.set_yymarker (lex_conf_string ()); return; } -#line 2439 "src/parse/lex_conf.cc" +#line 2436 "src/parse/lex_conf.cc" yy504: yych = (unsigned char)*++cur; if (yych == 'E') goto yy540; @@ -2505,17 +2502,17 @@ yy520: if (yybm[0+yych] & 32) { goto yy3; } -#line 107 "../src/parse/lex_conf.re" +#line 104 "../src/parse/lex_conf.re" { opts.set_bUseStateNext (lex_conf_bool()); return; } -#line 2511 "src/parse/lex_conf.cc" +#line 2508 "src/parse/lex_conf.cc" yy522: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 141 "../src/parse/lex_conf.re" +#line 138 "../src/parse/lex_conf.re" { opts.set_tags_expression(lex_conf_string ()); return; } -#line 2519 "src/parse/lex_conf.cc" +#line 2516 "src/parse/lex_conf.cc" yy524: yych = (unsigned char)*++cur; if (yych == 'p') goto yy556; @@ -2537,9 +2534,9 @@ yy528: if (yybm[0+yych] & 32) { goto yy3; } -#line 157 "../src/parse/lex_conf.re" +#line 154 "../src/parse/lex_conf.re" { opts.set_yychConversion (lex_conf_bool()); return; } -#line 2543 "src/parse/lex_conf.cc" +#line 2540 "src/parse/lex_conf.cc" yy530: yych = (unsigned char)*++cur; if (yych == 'r') goto yy560; @@ -2601,9 +2598,9 @@ yy540: } } yy541: -#line 131 "../src/parse/lex_conf.re" +#line 128 "../src/parse/lex_conf.re" { opts.set_yyrestore (lex_conf_string ()); return; } -#line 2607 "src/parse/lex_conf.cc" +#line 2604 "src/parse/lex_conf.cc" yy542: yych = (unsigned char)*++cur; if (yych == 'I') goto yy578; @@ -2683,14 +2680,14 @@ yy560: if (yybm[0+yych] & 32) { goto yy3; } -#line 163 "../src/parse/lex_conf.re" +#line 160 "../src/parse/lex_conf.re" { opts.set_fill_arg_use (lex_conf_bool()); return; } -#line 2689 "src/parse/lex_conf.cc" +#line 2686 "src/parse/lex_conf.cc" yy562: ++cur; -#line 94 "../src/parse/lex_conf.re" +#line 91 "../src/parse/lex_conf.re" { opts.set_condDividerParam (lex_conf_string ()); return; } -#line 2694 "src/parse/lex_conf.cc" +#line 2691 "src/parse/lex_conf.cc" yy564: yych = (unsigned char)*++cur; if (yych == 'X') goto yy602; @@ -2700,9 +2697,9 @@ yy565: if (yybm[0+yych] & 32) { goto yy3; } -#line 85 "../src/parse/lex_conf.re" +#line 82 "../src/parse/lex_conf.re" { opts.set_yycondtype (lex_conf_string ()); return; } -#line 2706 "src/parse/lex_conf.cc" +#line 2703 "src/parse/lex_conf.cc" yy567: yych = (unsigned char)*++cur; if (yych == 'R') goto yy604; @@ -2713,9 +2710,9 @@ yy568: goto yy4; yy569: ++cur; -#line 162 "../src/parse/lex_conf.re" +#line 159 "../src/parse/lex_conf.re" { opts.set_fill_arg (lex_conf_string ()); return; } -#line 2719 "src/parse/lex_conf.cc" +#line 2716 "src/parse/lex_conf.cc" yy571: yych = (unsigned char)*++cur; if (yych == 'T') goto yy607; @@ -2739,17 +2736,17 @@ yy572: } } yy573: -#line 99 "../src/parse/lex_conf.re" +#line 96 "../src/parse/lex_conf.re" { opts.set_state_get (lex_conf_string ()); return; } -#line 2745 "src/parse/lex_conf.cc" +#line 2742 "src/parse/lex_conf.cc" yy574: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 134 "../src/parse/lex_conf.re" +#line 131 "../src/parse/lex_conf.re" { opts.set_yylessthan (lex_conf_string ()); return; } -#line 2753 "src/parse/lex_conf.cc" +#line 2750 "src/parse/lex_conf.cc" yy576: yych = (unsigned char)*++cur; if (yych == 'T') goto yy609; @@ -2782,9 +2779,9 @@ yy579: } } yy580: -#line 101 "../src/parse/lex_conf.re" +#line 98 "../src/parse/lex_conf.re" { opts.set_state_set (lex_conf_string ()); return; } -#line 2788 "src/parse/lex_conf.cc" +#line 2785 "src/parse/lex_conf.cc" yy581: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { @@ -2814,7 +2811,7 @@ yy586: } #line 72 "../src/parse/lex_conf.re" { lex_conf_empty_class(opts); return; } -#line 2818 "src/parse/lex_conf.cc" +#line 2815 "src/parse/lex_conf.cc" yy588: yych = (unsigned char)*++cur; if (yych == 'l') goto yy618; @@ -2838,57 +2835,57 @@ yy592: if (yybm[0+yych] & 32) { goto yy3; } -#line 104 "../src/parse/lex_conf.re" +#line 101 "../src/parse/lex_conf.re" { opts.set_yyfilllabel (lex_conf_string ()); return; } -#line 2844 "src/parse/lex_conf.cc" +#line 2841 "src/parse/lex_conf.cc" yy594: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 108 "../src/parse/lex_conf.re" +#line 105 "../src/parse/lex_conf.re" { opts.set_yyaccept (lex_conf_string ()); return; } -#line 2852 "src/parse/lex_conf.cc" +#line 2849 "src/parse/lex_conf.cc" yy596: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 97 "../src/parse/lex_conf.re" +#line 94 "../src/parse/lex_conf.re" { opts.set_yyctable (lex_conf_string ()); return; } -#line 2860 "src/parse/lex_conf.cc" +#line 2857 "src/parse/lex_conf.cc" yy598: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 174 "../src/parse/lex_conf.re" +#line 171 "../src/parse/lex_conf.re" { lex_conf_string (); return; } -#line 2868 "src/parse/lex_conf.cc" +#line 2865 "src/parse/lex_conf.cc" yy600: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 120 "../src/parse/lex_conf.re" +#line 117 "../src/parse/lex_conf.re" { opts.set_yytarget (lex_conf_string ()); return; } -#line 2876 "src/parse/lex_conf.cc" +#line 2873 "src/parse/lex_conf.cc" yy602: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 130 "../src/parse/lex_conf.re" +#line 127 "../src/parse/lex_conf.re" { opts.set_yybackupctx (lex_conf_string ()); return; } -#line 2884 "src/parse/lex_conf.cc" +#line 2881 "src/parse/lex_conf.cc" yy604: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 124 "../src/parse/lex_conf.re" +#line 121 "../src/parse/lex_conf.re" { opts.set_yyctxmarker (lex_conf_string ()); return; } -#line 2892 "src/parse/lex_conf.cc" +#line 2889 "src/parse/lex_conf.cc" yy606: yych = (unsigned char)*++cur; if (yych == 'd') goto yy621; @@ -2956,9 +2953,9 @@ yy621: if (yybm[0+yych] & 32) { goto yy3; } -#line 164 "../src/parse/lex_conf.re" +#line 161 "../src/parse/lex_conf.re" { opts.set_fill_naked (lex_conf_bool()); return; } -#line 2962 "src/parse/lex_conf.cc" +#line 2959 "src/parse/lex_conf.cc" yy623: yych = (unsigned char)*++cur; if (yych == 'O') goto yy639; @@ -2972,17 +2969,17 @@ yy625: if (yybm[0+yych] & 32) { goto yy3; } -#line 132 "../src/parse/lex_conf.re" +#line 129 "../src/parse/lex_conf.re" { opts.set_yyrestorectx (lex_conf_string ()); return; } -#line 2978 "src/parse/lex_conf.cc" +#line 2975 "src/parse/lex_conf.cc" yy627: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 133 "../src/parse/lex_conf.re" +#line 130 "../src/parse/lex_conf.re" { opts.set_yyrestoretag (lex_conf_string ()); return; } -#line 2986 "src/parse/lex_conf.cc" +#line 2983 "src/parse/lex_conf.cc" yy629: yych = (unsigned char)*++cur; if (yych == 'O') goto yy641; @@ -3006,7 +3003,7 @@ yy633: } #line 53 "../src/parse/lex_conf.re" { opts.set_bCaseInverted (lex_conf_bool()); return; } -#line 3010 "src/parse/lex_conf.cc" +#line 3007 "src/parse/lex_conf.cc" yy635: yych = (unsigned char)*++cur; if (yych == 's') goto yy106; @@ -3072,9 +3069,9 @@ yy646: } } yy647: -#line 86 "../src/parse/lex_conf.re" +#line 83 "../src/parse/lex_conf.re" { opts.set_cond_get (lex_conf_string ()); return; } -#line 3078 "src/parse/lex_conf.cc" +#line 3075 "src/parse/lex_conf.cc" yy648: yych = (unsigned char)*++cur; if (yych == 'e') goto yy657; @@ -3099,9 +3096,9 @@ yy649: } } yy650: -#line 88 "../src/parse/lex_conf.re" +#line 85 "../src/parse/lex_conf.re" { opts.set_cond_set (lex_conf_string ()); return; } -#line 3105 "src/parse/lex_conf.cc" +#line 3102 "src/parse/lex_conf.cc" yy651: yych = (unsigned char)*++cur; if (yych == 'e') goto yy660; @@ -3121,7 +3118,7 @@ yy654: } #line 70 "../src/parse/lex_conf.re" { lex_conf_encoding_policy(opts); return; } -#line 3125 "src/parse/lex_conf.cc" +#line 3122 "src/parse/lex_conf.cc" yy656: yych = (unsigned char)*++cur; if (yych == 'n') goto yy664; @@ -3153,7 +3150,7 @@ yy662: } #line 52 "../src/parse/lex_conf.re" { opts.set_bCaseInsensitive (lex_conf_bool()); return; } -#line 3157 "src/parse/lex_conf.cc" +#line 3154 "src/parse/lex_conf.cc" yy664: yych = (unsigned char)*++cur; if (yych == 'a') goto yy673; @@ -3163,9 +3160,9 @@ yy665: if (yybm[0+yych] & 32) { goto yy3; } -#line 100 "../src/parse/lex_conf.re" +#line 97 "../src/parse/lex_conf.re" { opts.set_state_get_naked (lex_conf_bool()); return; } -#line 3169 "src/parse/lex_conf.cc" +#line 3166 "src/parse/lex_conf.cc" yy667: yych = (unsigned char)*++cur; if (yych == 'a') goto yy674; @@ -3179,14 +3176,14 @@ yy669: if (yybm[0+yych] & 32) { goto yy3; } -#line 102 "../src/parse/lex_conf.re" +#line 99 "../src/parse/lex_conf.re" { opts.set_state_set_naked (lex_conf_bool()); return; } -#line 3185 "src/parse/lex_conf.cc" +#line 3182 "src/parse/lex_conf.cc" yy671: ++cur; -#line 103 "../src/parse/lex_conf.re" +#line 100 "../src/parse/lex_conf.re" { opts.set_state_set_arg (lex_conf_string ()); return; } -#line 3190 "src/parse/lex_conf.cc" +#line 3187 "src/parse/lex_conf.cc" yy673: yych = (unsigned char)*++cur; if (yych == 'k') goto yy676; @@ -3221,27 +3218,27 @@ yy680: goto yy4; yy681: ++cur; -#line 89 "../src/parse/lex_conf.re" +#line 86 "../src/parse/lex_conf.re" { opts.set_cond_set_arg (lex_conf_string ()); return; } -#line 3227 "src/parse/lex_conf.cc" +#line 3224 "src/parse/lex_conf.cc" yy683: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 87 "../src/parse/lex_conf.re" +#line 84 "../src/parse/lex_conf.re" { opts.set_cond_get_naked (lex_conf_bool()); return; } -#line 3235 "src/parse/lex_conf.cc" +#line 3232 "src/parse/lex_conf.cc" yy685: yych = (unsigned char)*++cur; if (yybm[0+yych] & 32) { goto yy3; } -#line 90 "../src/parse/lex_conf.re" +#line 87 "../src/parse/lex_conf.re" { opts.set_cond_set_naked (lex_conf_bool()); return; } -#line 3243 "src/parse/lex_conf.cc" +#line 3240 "src/parse/lex_conf.cc" } -#line 180 "../src/parse/lex_conf.re" +#line 177 "../src/parse/lex_conf.re" } @@ -3249,7 +3246,7 @@ void Scanner::lex_conf_encoding_policy(Opt &opts) { lex_conf_assign (); -#line 3253 "src/parse/lex_conf.cc" +#line 3250 "src/parse/lex_conf.cc" { unsigned char yych; if ((lim - cur) < 10) YYFILL(10); @@ -3262,10 +3259,10 @@ void Scanner::lex_conf_encoding_policy(Opt &opts) } ++cur; yy690: -#line 187 "../src/parse/lex_conf.re" +#line 184 "../src/parse/lex_conf.re" { msg.fatal(cur_loc(), "bad configuration value (expected: 'ignore', 'substitute', 'fail')"); } -#line 3269 "src/parse/lex_conf.cc" +#line 3266 "src/parse/lex_conf.cc" yy691: yych = (unsigned char)*(mar = ++cur); if (yych == 'a') goto yy694; @@ -3306,9 +3303,9 @@ yy700: goto yy695; yy701: ++cur; -#line 191 "../src/parse/lex_conf.re" +#line 188 "../src/parse/lex_conf.re" { opts.set_encoding_policy(Enc::POLICY_FAIL); goto end; } -#line 3312 "src/parse/lex_conf.cc" +#line 3309 "src/parse/lex_conf.cc" yy703: yych = (unsigned char)*++cur; if (yych == 'r') goto yy705; @@ -3327,9 +3324,9 @@ yy706: goto yy695; yy707: ++cur; -#line 189 "../src/parse/lex_conf.re" +#line 186 "../src/parse/lex_conf.re" { opts.set_encoding_policy(Enc::POLICY_IGNORE); goto end; } -#line 3333 "src/parse/lex_conf.cc" +#line 3330 "src/parse/lex_conf.cc" yy709: yych = (unsigned char)*++cur; if (yych != 't') goto yy695; @@ -3340,11 +3337,11 @@ yy709: yych = (unsigned char)*++cur; if (yych != 'e') goto yy695; ++cur; -#line 190 "../src/parse/lex_conf.re" +#line 187 "../src/parse/lex_conf.re" { opts.set_encoding_policy(Enc::POLICY_SUBSTITUTE); goto end; } -#line 3346 "src/parse/lex_conf.cc" +#line 3343 "src/parse/lex_conf.cc" } -#line 192 "../src/parse/lex_conf.re" +#line 189 "../src/parse/lex_conf.re" end: lex_conf_semicolon(); @@ -3354,7 +3351,7 @@ void Scanner::lex_conf_input(Opt &opts) { lex_conf_assign (); -#line 3358 "src/parse/lex_conf.cc" +#line 3355 "src/parse/lex_conf.cc" { unsigned char yych; if ((lim - cur) < 7) YYFILL(7); @@ -3365,9 +3362,9 @@ void Scanner::lex_conf_input(Opt &opts) yy717: ++cur; yy718: -#line 201 "../src/parse/lex_conf.re" +#line 198 "../src/parse/lex_conf.re" { msg.fatal(cur_loc(), "bad configuration value (expected: 'default', 'custom')"); } -#line 3371 "src/parse/lex_conf.cc" +#line 3368 "src/parse/lex_conf.cc" yy719: yych = (unsigned char)*(mar = ++cur); if (yych == 'u') goto yy721; @@ -3412,18 +3409,18 @@ yy729: goto yy722; yy730: ++cur; -#line 203 "../src/parse/lex_conf.re" +#line 200 "../src/parse/lex_conf.re" { opts.set_input_api(INPUT_CUSTOM); goto end; } -#line 3418 "src/parse/lex_conf.cc" +#line 3415 "src/parse/lex_conf.cc" yy732: yych = (unsigned char)*++cur; if (yych != 't') goto yy722; ++cur; -#line 202 "../src/parse/lex_conf.re" +#line 199 "../src/parse/lex_conf.re" { opts.set_input_api(INPUT_DEFAULT); goto end; } -#line 3425 "src/parse/lex_conf.cc" +#line 3422 "src/parse/lex_conf.cc" } -#line 204 "../src/parse/lex_conf.re" +#line 201 "../src/parse/lex_conf.re" end: lex_conf_semicolon(); @@ -3433,7 +3430,7 @@ void Scanner::lex_conf_empty_class(Opt &opts) { lex_conf_assign (); -#line 3437 "src/parse/lex_conf.cc" +#line 3434 "src/parse/lex_conf.cc" { unsigned char yych; if ((lim - cur) < 11) YYFILL(11); @@ -3442,10 +3439,10 @@ void Scanner::lex_conf_empty_class(Opt &opts) if (yych == 'm') goto yy740; ++cur; yy738: -#line 213 "../src/parse/lex_conf.re" +#line 210 "../src/parse/lex_conf.re" { msg.fatal(cur_loc(), "bad configuration value (expected: 'match-empty', 'match-none', 'error')"); } -#line 3449 "src/parse/lex_conf.cc" +#line 3446 "src/parse/lex_conf.cc" yy739: yych = (unsigned char)*(mar = ++cur); if (yych == 'r') goto yy741; @@ -3482,9 +3479,9 @@ yy747: goto yy742; yy748: ++cur; -#line 217 "../src/parse/lex_conf.re" +#line 214 "../src/parse/lex_conf.re" { opts.set_empty_class_policy(EMPTY_CLASS_ERROR); goto end; } -#line 3488 "src/parse/lex_conf.cc" +#line 3485 "src/parse/lex_conf.cc" yy750: yych = (unsigned char)*++cur; if (yych != '-') goto yy742; @@ -3522,16 +3519,16 @@ yy758: goto yy742; yy759: ++cur; -#line 216 "../src/parse/lex_conf.re" +#line 213 "../src/parse/lex_conf.re" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_NONE); goto end; } -#line 3528 "src/parse/lex_conf.cc" +#line 3525 "src/parse/lex_conf.cc" yy761: ++cur; -#line 215 "../src/parse/lex_conf.re" +#line 212 "../src/parse/lex_conf.re" { opts.set_empty_class_policy(EMPTY_CLASS_MATCH_EMPTY); goto end; } -#line 3533 "src/parse/lex_conf.cc" +#line 3530 "src/parse/lex_conf.cc" } -#line 218 "../src/parse/lex_conf.re" +#line 215 "../src/parse/lex_conf.re" end: lex_conf_semicolon(); @@ -3549,7 +3546,7 @@ void Scanner::lex_conf_enc(Enc::type_t enc, Opt &opts) void Scanner::lex_conf_assign () { -#line 3553 "src/parse/lex_conf.cc" +#line 3550 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3596,9 +3593,9 @@ void Scanner::lex_conf_assign () } ++cur; yy766: -#line 235 "../src/parse/lex_conf.re" +#line 232 "../src/parse/lex_conf.re" { msg.fatal(cur_loc(), "missing '=' in configuration"); } -#line 3602 "src/parse/lex_conf.cc" +#line 3599 "src/parse/lex_conf.cc" yy767: yych = (unsigned char)*(mar = ++cur); if (yych <= 0x1F) { @@ -3615,9 +3612,9 @@ yy768: if (yybm[0+yych] & 128) { goto yy768; } -#line 236 "../src/parse/lex_conf.re" +#line 233 "../src/parse/lex_conf.re" { return; } -#line 3621 "src/parse/lex_conf.cc" +#line 3618 "src/parse/lex_conf.cc" yy771: ++cur; if (lim <= cur) YYFILL(1); @@ -3631,14 +3628,14 @@ yy771: cur = mar; goto yy766; } -#line 237 "../src/parse/lex_conf.re" +#line 234 "../src/parse/lex_conf.re" } void Scanner::lex_conf_semicolon () { -#line 3642 "src/parse/lex_conf.cc" +#line 3639 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3685,9 +3682,9 @@ void Scanner::lex_conf_semicolon () } ++cur; yy777: -#line 243 "../src/parse/lex_conf.re" +#line 240 "../src/parse/lex_conf.re" { msg.fatal(cur_loc(), "missing ending ';' in configuration"); } -#line 3691 "src/parse/lex_conf.cc" +#line 3688 "src/parse/lex_conf.cc" yy778: yych = (unsigned char)*(mar = ++cur); if (yybm[0+yych] & 128) { @@ -3696,9 +3693,9 @@ yy778: if (yych != ';') goto yy777; yy779: ++cur; -#line 244 "../src/parse/lex_conf.re" +#line 241 "../src/parse/lex_conf.re" { return; } -#line 3702 "src/parse/lex_conf.cc" +#line 3699 "src/parse/lex_conf.cc" yy781: ++cur; if (lim <= cur) YYFILL(1); @@ -3710,7 +3707,7 @@ yy781: cur = mar; goto yy777; } -#line 245 "../src/parse/lex_conf.re" +#line 242 "../src/parse/lex_conf.re" } @@ -3724,7 +3721,7 @@ int32_t Scanner::lex_conf_number () lex_conf_assign (); tok = cur; -#line 3728 "src/parse/lex_conf.cc" +#line 3725 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3771,9 +3768,9 @@ int32_t Scanner::lex_conf_number () } ++cur; yy787: -#line 258 "../src/parse/lex_conf.re" +#line 255 "../src/parse/lex_conf.re" { msg.fatal(cur_loc(), "bad configuration value (expected number)"); } -#line 3777 "src/parse/lex_conf.cc" +#line 3774 "src/parse/lex_conf.cc" yy788: yych = (unsigned char)*++cur; if (yych <= '0') goto yy787; @@ -3782,7 +3779,7 @@ yy788: yy789: ++cur; yy790: -#line 259 "../src/parse/lex_conf.re" +#line 256 "../src/parse/lex_conf.re" { int32_t n = 0; if (!s_to_i32_unsafe (tok, cur, n)) { @@ -3791,7 +3788,7 @@ yy790: lex_conf_semicolon (); return n; } -#line 3795 "src/parse/lex_conf.cc" +#line 3792 "src/parse/lex_conf.cc" yy791: ++cur; if (lim <= cur) YYFILL(1); @@ -3801,7 +3798,7 @@ yy791: } goto yy790; } -#line 267 "../src/parse/lex_conf.re" +#line 264 "../src/parse/lex_conf.re" } @@ -3811,7 +3808,7 @@ std::string Scanner::lex_conf_string () std::string s; tok = cur; -#line 3815 "src/parse/lex_conf.cc" +#line 3812 "src/parse/lex_conf.cc" { unsigned char yych; static const unsigned char yybm[] = { @@ -3867,9 +3864,9 @@ std::string Scanner::lex_conf_string () } } yy795: -#line 296 "../src/parse/lex_conf.re" +#line 293 "../src/parse/lex_conf.re" { goto end; } -#line 3873 "src/parse/lex_conf.cc" +#line 3870 "src/parse/lex_conf.cc" yy796: ++cur; if (lim <= cur) YYFILL(1); @@ -3877,15 +3874,15 @@ yy796: if (yybm[0+yych] & 128) { goto yy796; } -#line 292 "../src/parse/lex_conf.re" +#line 289 "../src/parse/lex_conf.re" { s = getstr(tok, cur); goto end; } -#line 3886 "src/parse/lex_conf.cc" +#line 3883 "src/parse/lex_conf.cc" yy799: ++cur; -#line 276 "../src/parse/lex_conf.re" +#line 273 "../src/parse/lex_conf.re" { const char quote = tok[0]; for (;;) { @@ -3902,9 +3899,9 @@ yy799: } } } -#line 3906 "src/parse/lex_conf.cc" +#line 3903 "src/parse/lex_conf.cc" } -#line 297 "../src/parse/lex_conf.re" +#line 294 "../src/parse/lex_conf.re" end: lex_conf_semicolon (); diff --git a/doc/manual/configurations/configurations.rst_ b/doc/manual/configurations/configurations.rst_ index bacf4095..ff6aad11 100644 --- a/doc/manual/configurations/configurations.rst_ +++ b/doc/manual/configurations/configurations.rst_ @@ -145,6 +145,12 @@ ``re2c:define:YYSTAGP = 'YYSTAGP';`` Replaces ``YYSTAGP`` identifier with the specified string. +``re2c:eof = -1;`` + Specifies the sentinel symbol used with EOF rule ``$`` to check for the end + of input in the generated lexer. Default value is ``-1`` (EOF rule is not + used). Other possible values include all valid code points. Only decimal + numbers are recognized. + ``re2c:flags:8`` or ``re2c:flags:utf-8`` Same as ``-8 --utf-8`` command-line option. diff --git a/src/parse/lex_conf.re b/src/parse/lex_conf.re index de2ec363..639d15f1 100644 --- a/src/parse/lex_conf.re +++ b/src/parse/lex_conf.re @@ -73,10 +73,7 @@ void Scanner::lex_conf(Opt &opts) "eof" { const int32_t eof = lex_conf_number(); - if (eof < 0) { - msg.fatal(cur_loc(), "EOF symbol cannot have negative value"); - } - opts.set_eof(static_cast(eof)); + opts.set_eof(eof < 0 ? NOEOF : static_cast(eof)); return; } diff --git a/test/eof/eof_07.c b/test/eof/eof_07.c index 5b862c5f..821338fe 100644 --- a/test/eof/eof_07.c +++ b/test/eof/eof_07.c @@ -1 +1 @@ -eof/eof_07.re:2:18: error: EOF symbol cannot have negative value +eof/eof_07.re:3:6: error: EOF rule found, but 're2c:eof' configuration is not set diff --git a/test/eof/eof_09.i.c b/test/eof/eof_09.i.c new file mode 100644 index 00000000..c107a259 --- /dev/null +++ b/test/eof/eof_09.i.c @@ -0,0 +1,88 @@ +/* Generated by re2c */ + +{ + YYCTYPE yych; +yy1_: + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy4; + default: + if (YYLIMIT <= YYCURSOR) { + if (YYFILL () == 0) goto yy1_; + goto yyeof; + } + goto yy2; + } +yy2: + ++YYCURSOR; +yy3: + { return FAIL; } +yy4: + ++YYCURSOR; + { return OK; } +yyeof: + { return EOF; } +} + + + +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy10; + default: goto yy8; + } +yy8: + ++YYCURSOR; + { return FAIL; } +yy10: + ++YYCURSOR; + { return OK; } +} + + + +{ + YYCTYPE yych; +yy13_: + yych = *YYCURSOR; + switch (yych) { + case 'b': goto yy16; + default: + if (YYLIMIT <= YYCURSOR) { + if (YYFILL () == 0) goto yy13_; + goto yyeof; + } + goto yy14; + } +yy14: + ++YYCURSOR; +yy15: + { return FAIL; } +yy16: + ++YYCURSOR; + { return OK; } +yyeof: + { return EOF; } +} + + + +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + switch (yych) { + case 'b': goto yy22; + default: goto yy20; + } +yy20: + ++YYCURSOR; + { return FAIL; } +yy22: + ++YYCURSOR; + { return OK; } +} + diff --git a/test/eof/eof_09.i.re b/test/eof/eof_09.i.re new file mode 100644 index 00000000..ceeffafa --- /dev/null +++ b/test/eof/eof_09.i.re @@ -0,0 +1,29 @@ +/*!re2c + re2c:eof = 0; + + * { return FAIL; } + $ { return EOF; } + [a] { return OK; } +*/ + +/*!re2c + re2c:eof = -1; + + * { return FAIL; } + [a] { return OK; } +*/ + +/*!re2c + re2c:eof = 42; + + * { return FAIL; } + $ { return EOF; } + [b] { return OK; } +*/ + +/*!re2c + re2c:eof = -1; + + * { return FAIL; } + [b] { return OK; } +*/ -- 2.40.0