From 7f623ee597cf41439ebec5ab912994fc5cef696b Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Tue, 1 Jan 2019 13:24:10 +0000 Subject: [PATCH] Intrinsic options that do not have configurations should be immutable. --- re2c/bootstrap/src/conf/parse_opts.cc | 126 +++++++++++++------------- re2c/src/conf/opt.cc | 10 +- re2c/src/conf/opt.h | 12 +-- re2c/src/conf/parse_opts.re | 20 ++-- 4 files changed, 84 insertions(+), 84 deletions(-) diff --git a/re2c/bootstrap/src/conf/parse_opts.cc b/re2c/bootstrap/src/conf/parse_opts.cc index ecf75d3e..c5f7ddc6 100644 --- a/re2c/bootstrap/src/conf/parse_opts.cc +++ b/re2c/bootstrap/src/conf/parse_opts.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 1.1.1 on Tue Jan 1 12:30:10 2019 */ +/* Generated by re2c 1.1.1 on Tue Jan 1 13:21:42 2019 */ #line 1 "../src/conf/parse_opts.re" #include "src/code/input_api.h" #include "src/conf/msg.h" @@ -1482,7 +1482,7 @@ yy347: goto yy283; yy348: ++YYCURSOR; -#line 153 "../src/conf/parse_opts.re" +#line 150 "../src/conf/parse_opts.re" { opts.set_encoding(Enc::EBCDIC); goto opt; } #line 1488 "src/conf/parse_opts.cc" yy350: @@ -1801,7 +1801,7 @@ yy427: goto yy283; yy428: ++YYCURSOR; -#line 162 "../src/conf/parse_opts.re" +#line 159 "../src/conf/parse_opts.re" { NEXT_ARG("--input", opt_input); } #line 1807 "src/conf/parse_opts.cc" yy430: @@ -1870,7 +1870,7 @@ yy445: goto yy283; yy446: ++YYCURSOR; -#line 157 "../src/conf/parse_opts.re" +#line 154 "../src/conf/parse_opts.re" { opts.set_encoding(Enc::UTF8); goto opt; } #line 1876 "src/conf/parse_opts.cc" yy448: @@ -1972,7 +1972,7 @@ yy471: goto yy283; yy472: ++YYCURSOR; -#line 159 "../src/conf/parse_opts.re" +#line 156 "../src/conf/parse_opts.re" { NEXT_ARG("-o, --output", opt_output); } #line 1978 "src/conf/parse_opts.cc" yy474: @@ -2010,7 +2010,7 @@ yy481: goto yy283; yy482: ++YYCURSOR; -#line 156 "../src/conf/parse_opts.re" +#line 153 "../src/conf/parse_opts.re" { opts.set_encoding(Enc::UTF16); goto opt; } #line 2016 "src/conf/parse_opts.cc" yy484: @@ -2148,7 +2148,7 @@ yy517: goto yy283; yy518: ++YYCURSOR; -#line 154 "../src/conf/parse_opts.re" +#line 151 "../src/conf/parse_opts.re" { opts.set_encoding(Enc::UTF32); goto opt; } #line 2154 "src/conf/parse_opts.cc" yy520: @@ -2207,7 +2207,7 @@ yy532: } yy533: ++YYCURSOR; -#line 170 "../src/conf/parse_opts.re" +#line 172 "../src/conf/parse_opts.re" { globopts.dump_nfa = true; goto opt; } #line 2213 "src/conf/parse_opts.cc" yy535: @@ -2319,7 +2319,7 @@ yy563: goto yy283; yy564: ++YYCURSOR; -#line 175 "../src/conf/parse_opts.re" +#line 177 "../src/conf/parse_opts.re" { globopts.dump_adfa = true; goto opt; } #line 2325 "src/conf/parse_opts.cc" yy566: @@ -2457,8 +2457,8 @@ yy599: goto yy283; yy600: ++YYCURSOR; -#line 152 "../src/conf/parse_opts.re" - { opts.set_eager_skip(true); goto opt; } +#line 169 "../src/conf/parse_opts.re" + { globopts.eager_skip = true; goto opt; } #line 2463 "src/conf/parse_opts.cc" yy602: yych = (YYCTYPE)*++YYCURSOR; @@ -2520,7 +2520,7 @@ yy617: goto yy283; yy618: ++YYCURSOR; -#line 155 "../src/conf/parse_opts.re" +#line 152 "../src/conf/parse_opts.re" { opts.set_encoding(Enc::UCS2); goto opt; } #line 2526 "src/conf/parse_opts.cc" yy620: @@ -2570,7 +2570,7 @@ yy631: goto yy283; yy632: ++YYCURSOR; -#line 163 "../src/conf/parse_opts.re" +#line 160 "../src/conf/parse_opts.re" { NEXT_ARG("--empty-class", opt_empty_class); } #line 2576 "src/conf/parse_opts.cc" yy634: @@ -2608,7 +2608,7 @@ yy642: goto yy283; yy643: ++YYCURSOR; -#line 167 "../src/conf/parse_opts.re" +#line 162 "../src/conf/parse_opts.re" { goto opt; } #line 2614 "src/conf/parse_opts.cc" yy645: @@ -2617,7 +2617,7 @@ yy645: goto yy283; yy646: ++YYCURSOR; -#line 160 "../src/conf/parse_opts.re" +#line 157 "../src/conf/parse_opts.re" { NEXT_ARG("-t, --type-header", opt_header); } #line 2623 "src/conf/parse_opts.cc" yy648: @@ -2647,17 +2647,17 @@ yy654: goto yy283; yy655: ++YYCURSOR; -#line 172 "../src/conf/parse_opts.re" +#line 174 "../src/conf/parse_opts.re" { globopts.dump_dfa_det = true; goto opt; } #line 2653 "src/conf/parse_opts.cc" yy657: ++YYCURSOR; -#line 174 "../src/conf/parse_opts.re" +#line 176 "../src/conf/parse_opts.re" { globopts.dump_dfa_min = true; goto opt; } #line 2658 "src/conf/parse_opts.cc" yy659: ++YYCURSOR; -#line 171 "../src/conf/parse_opts.re" +#line 173 "../src/conf/parse_opts.re" { globopts.dump_dfa_raw = true; goto opt; } #line 2663 "src/conf/parse_opts.cc" yy661: @@ -2678,8 +2678,8 @@ yy664: goto yy283; yy665: ++YYCURSOR; -#line 150 "../src/conf/parse_opts.re" - { opts.set_lookahead(false); goto opt; } +#line 167 "../src/conf/parse_opts.re" + { globopts.lookahead = false; goto opt; } #line 2684 "src/conf/parse_opts.cc" yy667: yych = (YYCTYPE)*++YYCURSOR; @@ -2745,7 +2745,7 @@ yy683: goto yy283; yy684: ++YYCURSOR; -#line 165 "../src/conf/parse_opts.re" +#line 166 "../src/conf/parse_opts.re" { NEXT_ARG("--posix-closure", opt_posix_closure); } #line 2751 "src/conf/parse_opts.cc" yy686: @@ -2809,12 +2809,12 @@ yy702: goto yy283; yy703: ++YYCURSOR; -#line 173 "../src/conf/parse_opts.re" +#line 175 "../src/conf/parse_opts.re" { globopts.dump_dfa_tagopt = true; goto opt; } #line 2815 "src/conf/parse_opts.cc" yy705: ++YYCURSOR; -#line 161 "../src/conf/parse_opts.re" +#line 158 "../src/conf/parse_opts.re" { NEXT_ARG("--encoding-policy", opt_encoding_policy); } #line 2820 "src/conf/parse_opts.cc" yy707: @@ -2832,7 +2832,7 @@ yy709: #line 2833 "src/conf/parse_opts.cc" yy711: ++YYCURSOR; -#line 164 "../src/conf/parse_opts.re" +#line 165 "../src/conf/parse_opts.re" { NEXT_ARG("--dfa-minimization", opt_dfa_minimization); } #line 2838 "src/conf/parse_opts.cc" yy713: @@ -2845,8 +2845,8 @@ yy714: goto yy283; yy715: ++YYCURSOR; -#line 151 "../src/conf/parse_opts.re" - { opts.set_optimize_tags(false); goto opt; } +#line 168 "../src/conf/parse_opts.re" + { globopts.optimize_tags = false; goto opt; } #line 2851 "src/conf/parse_opts.cc" yy717: yych = (YYCTYPE)*++YYCURSOR; @@ -2858,7 +2858,7 @@ yy718: goto yy283; yy719: ++YYCURSOR; -#line 176 "../src/conf/parse_opts.re" +#line 178 "../src/conf/parse_opts.re" { globopts.dump_closure_stats = true; goto opt; } #line 2864 "src/conf/parse_opts.cc" yy721: @@ -2867,7 +2867,7 @@ yy721: { globopts.bNoGenerationDate = true; goto opt; } #line 2869 "src/conf/parse_opts.cc" } -#line 177 "../src/conf/parse_opts.re" +#line 179 "../src/conf/parse_opts.re" opt_output: @@ -2914,7 +2914,7 @@ opt_output: if (yych != '-') goto yy727; yy725: ++YYCURSOR; -#line 181 "../src/conf/parse_opts.re" +#line 183 "../src/conf/parse_opts.re" { ERROR("bad argument to option -o, --output: %s", *argv); } #line 2920 "src/conf/parse_opts.cc" yy727: @@ -2923,11 +2923,11 @@ yy727: goto yy727; } ++YYCURSOR; -#line 182 "../src/conf/parse_opts.re" +#line 184 "../src/conf/parse_opts.re" { opts.set_output_file (*argv); goto opt; } #line 2929 "src/conf/parse_opts.cc" } -#line 183 "../src/conf/parse_opts.re" +#line 185 "../src/conf/parse_opts.re" opt_header: @@ -2974,7 +2974,7 @@ opt_header: if (yych != '-') goto yy735; yy733: ++YYCURSOR; -#line 187 "../src/conf/parse_opts.re" +#line 189 "../src/conf/parse_opts.re" { ERROR("bad argument to option -t, --type-header: %s", *argv); } #line 2980 "src/conf/parse_opts.cc" yy735: @@ -2983,11 +2983,11 @@ yy735: goto yy735; } ++YYCURSOR; -#line 188 "../src/conf/parse_opts.re" +#line 190 "../src/conf/parse_opts.re" { opts.set_header_file (*argv); goto opt; } #line 2989 "src/conf/parse_opts.cc" } -#line 189 "../src/conf/parse_opts.re" +#line 191 "../src/conf/parse_opts.re" opt_incpath: @@ -3034,7 +3034,7 @@ opt_incpath: if (yych != '-') goto yy743; yy741: ++YYCURSOR; -#line 193 "../src/conf/parse_opts.re" +#line 195 "../src/conf/parse_opts.re" { ERROR("bad argument to option -I: %s", *argv); } #line 3040 "src/conf/parse_opts.cc" yy743: @@ -3043,11 +3043,11 @@ yy743: goto yy743; } ++YYCURSOR; -#line 194 "../src/conf/parse_opts.re" +#line 196 "../src/conf/parse_opts.re" { globopts.incpaths.push_back(*argv); goto opt; } #line 3049 "src/conf/parse_opts.cc" } -#line 195 "../src/conf/parse_opts.re" +#line 197 "../src/conf/parse_opts.re" opt_encoding_policy: @@ -3064,7 +3064,7 @@ opt_encoding_policy: } ++YYCURSOR; yy750: -#line 199 "../src/conf/parse_opts.re" +#line 201 "../src/conf/parse_opts.re" { ERROR("bad argument to option --encoding-policy " "(expected: ignore | substitute | fail): %s", *argv); @@ -3122,7 +3122,7 @@ yy763: goto yy755; yy764: ++YYCURSOR; -#line 205 "../src/conf/parse_opts.re" +#line 207 "../src/conf/parse_opts.re" { opts.set_encoding_policy (Enc::POLICY_FAIL); goto opt; } #line 3128 "src/conf/parse_opts.cc" yy766: @@ -3143,7 +3143,7 @@ yy769: goto yy755; yy770: ++YYCURSOR; -#line 203 "../src/conf/parse_opts.re" +#line 205 "../src/conf/parse_opts.re" { opts.set_encoding_policy (Enc::POLICY_IGNORE); goto opt; } #line 3149 "src/conf/parse_opts.cc" yy772: @@ -3156,11 +3156,11 @@ yy772: yych = (YYCTYPE)*++YYCURSOR; if (yych >= 0x01) goto yy755; ++YYCURSOR; -#line 204 "../src/conf/parse_opts.re" +#line 206 "../src/conf/parse_opts.re" { opts.set_encoding_policy (Enc::POLICY_SUBSTITUTE); goto opt; } #line 3162 "src/conf/parse_opts.cc" } -#line 206 "../src/conf/parse_opts.re" +#line 208 "../src/conf/parse_opts.re" opt_input: @@ -3175,7 +3175,7 @@ opt_input: yy780: ++YYCURSOR; yy781: -#line 210 "../src/conf/parse_opts.re" +#line 212 "../src/conf/parse_opts.re" { ERROR("bad argument to option --input " "(expected: default | custom): %s", *argv); @@ -3233,18 +3233,18 @@ yy794: goto yy785; yy795: ++YYCURSOR; -#line 215 "../src/conf/parse_opts.re" +#line 217 "../src/conf/parse_opts.re" { opts.set_input_api(INPUT_CUSTOM); goto opt; } #line 3239 "src/conf/parse_opts.cc" yy797: yych = (YYCTYPE)*++YYCURSOR; if (yych >= 0x01) goto yy785; ++YYCURSOR; -#line 214 "../src/conf/parse_opts.re" +#line 216 "../src/conf/parse_opts.re" { opts.set_input_api(INPUT_DEFAULT); goto opt; } #line 3246 "src/conf/parse_opts.cc" } -#line 216 "../src/conf/parse_opts.re" +#line 218 "../src/conf/parse_opts.re" opt_empty_class: @@ -3257,7 +3257,7 @@ opt_empty_class: if (yych == 'm') goto yy805; ++YYCURSOR; yy803: -#line 220 "../src/conf/parse_opts.re" +#line 222 "../src/conf/parse_opts.re" { ERROR("bad argument to option --empty-class " "(expected: match-empty | match-none | error): %s", *argv); @@ -3307,7 +3307,7 @@ yy814: goto yy807; yy815: ++YYCURSOR; -#line 226 "../src/conf/parse_opts.re" +#line 228 "../src/conf/parse_opts.re" { opts.set_empty_class_policy (EMPTY_CLASS_ERROR); goto opt; } #line 3313 "src/conf/parse_opts.cc" yy817: @@ -3353,16 +3353,16 @@ yy826: goto yy807; yy827: ++YYCURSOR; -#line 225 "../src/conf/parse_opts.re" +#line 227 "../src/conf/parse_opts.re" { opts.set_empty_class_policy (EMPTY_CLASS_MATCH_NONE); goto opt; } #line 3359 "src/conf/parse_opts.cc" yy829: ++YYCURSOR; -#line 224 "../src/conf/parse_opts.re" +#line 226 "../src/conf/parse_opts.re" { opts.set_empty_class_policy (EMPTY_CLASS_MATCH_EMPTY); goto opt; } #line 3364 "src/conf/parse_opts.cc" } -#line 227 "../src/conf/parse_opts.re" +#line 229 "../src/conf/parse_opts.re" opt_dfa_minimization: @@ -3375,7 +3375,7 @@ opt_dfa_minimization: if (yych == 't') goto yy836; ++YYCURSOR; yy834: -#line 231 "../src/conf/parse_opts.re" +#line 233 "../src/conf/parse_opts.re" { ERROR("bad argument to option --dfa-minimization " "(expected: table | moore): %s", *argv); @@ -3425,16 +3425,16 @@ yy845: goto yy838; yy846: ++YYCURSOR; -#line 236 "../src/conf/parse_opts.re" - { opts.set_dfa_minimization (DFA_MINIMIZATION_MOORE); goto opt; } +#line 238 "../src/conf/parse_opts.re" + { globopts.dfa_minimization = DFA_MINIMIZATION_MOORE; goto opt; } #line 3431 "src/conf/parse_opts.cc" yy848: ++YYCURSOR; -#line 235 "../src/conf/parse_opts.re" - { opts.set_dfa_minimization (DFA_MINIMIZATION_TABLE); goto opt; } +#line 237 "../src/conf/parse_opts.re" + { globopts.dfa_minimization = DFA_MINIMIZATION_TABLE; goto opt; } #line 3436 "src/conf/parse_opts.cc" } -#line 237 "../src/conf/parse_opts.re" +#line 239 "../src/conf/parse_opts.re" opt_posix_closure: @@ -3446,7 +3446,7 @@ opt_posix_closure: if (yych == 'g') goto yy854; ++YYCURSOR; yy853: -#line 241 "../src/conf/parse_opts.re" +#line 243 "../src/conf/parse_opts.re" { ERROR("bad argument to option --posix_closure " "(expected: gor1 | gtop): %s", *argv); @@ -3485,16 +3485,16 @@ yy861: goto yy856; yy862: ++YYCURSOR; -#line 245 "../src/conf/parse_opts.re" - { opts.set_posix_closure (POSIX_CLOSURE_GOR1); goto opt; } +#line 247 "../src/conf/parse_opts.re" + { globopts.posix_closure = POSIX_CLOSURE_GOR1; goto opt; } #line 3491 "src/conf/parse_opts.cc" yy864: ++YYCURSOR; -#line 246 "../src/conf/parse_opts.re" - { opts.set_posix_closure (POSIX_CLOSURE_GTOP); goto opt; } +#line 248 "../src/conf/parse_opts.re" + { globopts.posix_closure = POSIX_CLOSURE_GTOP; goto opt; } #line 3496 "src/conf/parse_opts.cc" } -#line 247 "../src/conf/parse_opts.re" +#line 249 "../src/conf/parse_opts.re" end: diff --git a/re2c/src/conf/opt.cc b/re2c/src/conf/opt.cc index 2925ff4a..223a16cd 100644 --- a/re2c/src/conf/opt.cc +++ b/re2c/src/conf/opt.cc @@ -10,6 +10,10 @@ void conopt_t::fix() fFlag = false; } + if (!lookahead) { + eager_skip = true; + } + // append directory separator '/' to all paths that do not have it for (size_t i = 0; i < incpaths.size(); ++i) { std::string &p = incpaths[i]; @@ -65,7 +69,6 @@ void mutopt_t::fix(const conopt_t *globopts) state_set_naked = Opt::baseopt.state_set_naked; tags_prefix = Opt::baseopt.tags_prefix; tags_expression = Opt::baseopt.tags_expression; - optimize_tags = Opt::baseopt.optimize_tags; yyfilllabel = Opt::baseopt.yyfilllabel; yynext = Opt::baseopt.yynext; yyaccept = Opt::baseopt.yyaccept; @@ -150,8 +153,6 @@ void mutopt_t::fix(const conopt_t *globopts) { tags_prefix = Opt::baseopt.tags_prefix; tags_expression = Opt::baseopt.tags_expression; - lookahead = Opt::baseopt.lookahead; - optimize_tags = Opt::baseopt.optimize_tags; } if (!bFlag) { @@ -231,9 +232,6 @@ void mutopt_t::fix(const conopt_t *globopts) bFlag = true; sFlag = true; } - if (!lookahead) { - eager_skip = true; - } if (eof != NOEOF) { if (bFlag || gFlag) { fatal ("configuration 're2c:eof' cannot be used with options " diff --git a/re2c/src/conf/opt.h b/re2c/src/conf/opt.h index bb7a06c5..67603d52 100644 --- a/re2c/src/conf/opt.h +++ b/re2c/src/conf/opt.h @@ -52,6 +52,12 @@ const uint32_t NOEOF = ~0u - 1; CONSTOPT (bool, FFlag, false) \ /* include paths */ \ CONSTOPT (std::vector, incpaths, std::vector()) \ + /* internals */ \ + CONSTOPT (dfa_minimization_t, dfa_minimization, DFA_MINIMIZATION_MOORE) \ + CONSTOPT (posix_closure_t, posix_closure, POSIX_CLOSURE_GOR1) \ + CONSTOPT (bool, lookahead, true) \ + CONSTOPT (bool, eager_skip, false) \ + CONSTOPT (bool, optimize_tags, true) \ /* debug */ \ CONSTOPT (bool, dump_nfa, false) \ CONSTOPT (bool, dump_dfa_raw, false) \ @@ -152,12 +158,6 @@ const uint32_t NOEOF = ~0u - 1; MUTOPT (std::string, labelPrefix, "yy") \ MUTOPT (std::string, startlabel, "") \ MUTOPT (bool, startlabel_force, false) \ - /* internals */ \ - MUTOPT (dfa_minimization_t, dfa_minimization, DFA_MINIMIZATION_MOORE) \ - MUTOPT (posix_closure_t, posix_closure, POSIX_CLOSURE_GOR1) \ - MUTOPT (bool, lookahead, true) \ - MUTOPT (bool, eager_skip, false) \ - MUTOPT (bool, optimize_tags, true) \ /* end */ struct conopt_t diff --git a/re2c/src/conf/parse_opts.re b/re2c/src/conf/parse_opts.re index d3fd0896..311bf0f3 100644 --- a/re2c/src/conf/parse_opts.re +++ b/re2c/src/conf/parse_opts.re @@ -147,9 +147,6 @@ opt_long: "case-inverted" end { opts.set_bCaseInverted (true); goto opt; } "tags" end { opts.set_tags (true); goto opt; } "posix-captures" end { opts.set_posix_captures(true); goto opt; } - "no-lookahead" end { opts.set_lookahead(false); goto opt; } - "no-optimize-tags" end { opts.set_optimize_tags(false); goto opt; } - "eager-skip" end { opts.set_eager_skip(true); goto opt; } "ecb" end { opts.set_encoding(Enc::EBCDIC); goto opt; } "unicode" end { opts.set_encoding(Enc::UTF32); goto opt; } "wide-chars" end { opts.set_encoding(Enc::UCS2); goto opt; } @@ -161,11 +158,16 @@ opt_long: "encoding-policy" end { NEXT_ARG("--encoding-policy", opt_encoding_policy); } "input" end { NEXT_ARG("--input", opt_input); } "empty-class" end { NEXT_ARG("--empty-class", opt_empty_class); } - "dfa-minimization" end { NEXT_ARG("--dfa-minimization", opt_dfa_minimization); } - "posix-closure" end { NEXT_ARG("--posix-closure", opt_posix_closure); } "single-pass" end { goto opt; } // deprecated + // internals + "dfa-minimization" end { NEXT_ARG("--dfa-minimization", opt_dfa_minimization); } + "posix-closure" end { NEXT_ARG("--posix-closure", opt_posix_closure); } + "no-lookahead" end { globopts.lookahead = false; goto opt; } + "no-optimize-tags" end { globopts.optimize_tags = false; goto opt; } + "eager-skip" end { globopts.eager_skip = true; goto opt; } + // debug options "dump-nfa" end { globopts.dump_nfa = true; goto opt; } "dump-dfa-raw" end { globopts.dump_dfa_raw = true; goto opt; } @@ -232,8 +234,8 @@ opt_dfa_minimization: ERROR("bad argument to option --dfa-minimization " "(expected: table | moore): %s", *argv); } - "table" end { opts.set_dfa_minimization (DFA_MINIMIZATION_TABLE); goto opt; } - "moore" end { opts.set_dfa_minimization (DFA_MINIMIZATION_MOORE); goto opt; } + "table" end { globopts.dfa_minimization = DFA_MINIMIZATION_TABLE; goto opt; } + "moore" end { globopts.dfa_minimization = DFA_MINIMIZATION_MOORE; goto opt; } */ opt_posix_closure: @@ -242,8 +244,8 @@ opt_posix_closure: ERROR("bad argument to option --posix_closure " "(expected: gor1 | gtop): %s", *argv); } - "gor1" end { opts.set_posix_closure (POSIX_CLOSURE_GOR1); goto opt; } - "gtop" end { opts.set_posix_closure (POSIX_CLOSURE_GTOP); goto opt; } + "gor1" end { globopts.posix_closure = POSIX_CLOSURE_GOR1; goto opt; } + "gtop" end { globopts.posix_closure = POSIX_CLOSURE_GTOP; goto opt; } */ end: -- 2.40.0