From: Ulya Trofimovich Date: Tue, 7 Mar 2017 18:23:24 +0000 (+0000) Subject: Moved enum out of struct and added prefix 'TARGET_' to all members. X-Git-Tag: 1.0~39^2~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e0cc064c1c9acfb37eb68f626abd21ff39178aa;p=re2c Moved enum out of struct and added prefix 'TARGET_' to all members. --- diff --git a/re2c/bootstrap/src/ast/lex.cc b/re2c/bootstrap/src/ast/lex.cc index 35871776..35f1bede 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 Tue Mar 7 18:15:59 2017 */ +/* Generated by re2c 0.16 on Tue Mar 7 18:21:50 2017 */ #line 1 "../src/ast/lex.re" #include "src/util/c99_stdint.h" #include diff --git a/re2c/bootstrap/src/ast/lex_conf.cc b/re2c/bootstrap/src/ast/lex_conf.cc index ef6fd877..619df70c 100644 --- a/re2c/bootstrap/src/ast/lex_conf.cc +++ b/re2c/bootstrap/src/ast/lex_conf.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Tue Mar 7 17:49:54 2017 */ +/* Generated by re2c 0.16 on Tue Mar 7 18:21:20 2017 */ #line 1 "../src/ast/lex_conf.re" #include "src/util/c99_stdint.h" #include @@ -570,7 +570,7 @@ yy90: yy92: ++cur; #line 42 "../src/ast/lex_conf.re" - { opts.set_target(opt_t::DOT); lex_conf_semicolon(); return; } + { opts.set_target(TARGET_DOT); lex_conf_semicolon(); return; } #line 575 "src/ast/lex_conf.cc" yy94: ++cur; @@ -580,7 +580,7 @@ yy94: yy96: ++cur; #line 43 "../src/ast/lex_conf.re" - { opts.set_target(opt_t::SKELETON); lex_conf_semicolon(); return; } + { opts.set_target(TARGET_SKELETON); lex_conf_semicolon(); return; } #line 585 "src/ast/lex_conf.cc" yy98: ++cur; diff --git a/re2c/bootstrap/src/ast/parser.cc b/re2c/bootstrap/src/ast/parser.cc index 6e820275..d0f5f5ea 100644 --- a/re2c/bootstrap/src/ast/parser.cc +++ b/re2c/bootstrap/src/ast/parser.cc @@ -1981,7 +1981,7 @@ void parse(Scanner &input, Output &output) o.new_block(opts); o.wversion_time().wline_info(input.get_cline(), input.get_fname().c_str()); - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { emit_prolog(o); } @@ -2033,7 +2033,7 @@ void parse(Scanner &input, Output &output) o.wline_info (input.get_cline (), input.get_fname ().c_str ()); } - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { emit_epilog (o, output.skeletons); } diff --git a/re2c/bootstrap/src/conf/parse_opts.cc b/re2c/bootstrap/src/conf/parse_opts.cc index b4da720e..90045fa2 100644 --- a/re2c/bootstrap/src/conf/parse_opts.cc +++ b/re2c/bootstrap/src/conf/parse_opts.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 on Tue Mar 7 17:52:30 2017 */ +/* Generated by re2c 0.16 on Tue Mar 7 18:22:57 2017 */ #line 1 "../src/conf/parse_opts.re" #include "src/code/input_api.h" #include "src/conf/msg.h" @@ -951,7 +951,7 @@ yy210: yy212: ++YYCURSOR; #line 103 "../src/conf/parse_opts.re" - { opts.set_target (opt_t::DOT); goto opt_short; } + { opts.set_target (TARGET_DOT); goto opt_short; } #line 956 "src/conf/parse_opts.cc" yy214: ++YYCURSOR; @@ -961,7 +961,7 @@ yy214: yy216: ++YYCURSOR; #line 110 "../src/conf/parse_opts.re" - { opts.set_target (opt_t::SKELETON); goto opt_short; } + { opts.set_target (TARGET_SKELETON); goto opt_short; } #line 966 "src/conf/parse_opts.cc" yy218: ++YYCURSOR; @@ -2123,7 +2123,7 @@ yy512: yy513: ++YYCURSOR; #line 137 "../src/conf/parse_opts.re" - { opts.set_target (opt_t::DOT); goto opt; } + { opts.set_target (TARGET_DOT); goto opt; } #line 2128 "src/conf/parse_opts.cc" yy515: yych = (YYCTYPE)*++YYCURSOR; @@ -2173,7 +2173,7 @@ yy526: yy527: ++YYCURSOR; #line 148 "../src/conf/parse_opts.re" - { opts.set_target (opt_t::SKELETON); goto opt; } + { opts.set_target (TARGET_SKELETON); goto opt; } #line 2178 "src/conf/parse_opts.cc" yy529: yych = (YYCTYPE)*++YYCURSOR; diff --git a/re2c/src/ast/lex_conf.re b/re2c/src/ast/lex_conf.re index fc931ed8..edb14b38 100644 --- a/re2c/src/ast/lex_conf.re +++ b/re2c/src/ast/lex_conf.re @@ -39,8 +39,8 @@ void Scanner::lex_conf () /*!re2c * { fatal(get_column() - tchar, "unrecognized configuration"); } - "flags:" ("D" | "emit-dot") { opts.set_target(opt_t::DOT); lex_conf_semicolon(); return; } - "flags:" ("S" | "skeleton") { opts.set_target(opt_t::SKELETON); lex_conf_semicolon(); return; } + "flags:" ("D" | "emit-dot") { opts.set_target(TARGET_DOT); lex_conf_semicolon(); return; } + "flags:" ("S" | "skeleton") { opts.set_target(TARGET_SKELETON); lex_conf_semicolon(); return; } "flags:" ("b" | "bit-vectors") { opts.set_bFlag(lex_conf_bool()); return; } "flags:" ("c" | "start-conditions") { opts.set_cFlag(lex_conf_bool()); return; } diff --git a/re2c/src/ast/parser.ypp b/re2c/src/ast/parser.ypp index 94cd15a4..047049eb 100644 --- a/re2c/src/ast/parser.ypp +++ b/re2c/src/ast/parser.ypp @@ -426,7 +426,7 @@ void parse(Scanner &input, Output &output) o.new_block(opts); o.wversion_time().wline_info(input.get_cline(), input.get_fname().c_str()); - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { emit_prolog(o); } @@ -478,7 +478,7 @@ void parse(Scanner &input, Output &output) o.wline_info (input.get_cline (), input.get_fname ().c_str ()); } - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { emit_epilog (o, output.skeletons); } diff --git a/re2c/src/code/emit_action.cc b/re2c/src/code/emit_action.cc index 2be491ad..adb674ab 100644 --- a/re2c/src/code/emit_action.cc +++ b/re2c/src/code/emit_action.cc @@ -163,7 +163,7 @@ void emit_rule(OutputFile &o, uint32_t ind, const DFA &dfa, size_t rule_idx) gen_fintags(o, ind, dfa, rule); - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { emit_action(o, ind, dfa, rule_idx); } else { if (!cond.empty() && dfa.cond != cond) { diff --git a/re2c/src/code/emit_dfa.cc b/re2c/src/code/emit_dfa.cc index 78f55c0e..5b94574a 100644 --- a/re2c/src/code/emit_dfa.cc +++ b/re2c/src/code/emit_dfa.cc @@ -161,7 +161,7 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra head->action.set_initial(initial_label); - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { if (output.skeletons.insert (name).second) { emit_start(o, max_fill, name, key_size, def_rule, need_backup, @@ -170,7 +170,7 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra emit_body (o, i, used_labels, initial_label); emit_end(o, name, need_backup, oldstyle_ctxmarker); } - } else if (opts->target == opt_t::DOT) { + } else if (opts->target == TARGET_DOT) { emit_dot(o, isLastCond); } else { // Generate prolog diff --git a/re2c/src/code/go_construct.cc b/re2c/src/code/go_construct.cc index a0b04aa0..2ccbc5b1 100644 --- a/re2c/src/code/go_construct.cc +++ b/re2c/src/code/go_construct.cc @@ -263,7 +263,7 @@ void Go::init(const State *from, const opt_t *opts, bitmaps_t &bitmaps) const uint32_t dSpans = nSpans - hSpans - nBitmaps; const bool part_skip = opts->eager_skip && !skip; - if (opts->target == opt_t::DOT) + if (opts->target == TARGET_DOT) { type = DOT; info.dot = new Dot (span, nSpans, from); diff --git a/re2c/src/code/output.cc b/re2c/src/code/output.cc index 7494bc7d..4ef12934 100644 --- a/re2c/src/code/output.cc +++ b/re2c/src/code/output.cc @@ -88,7 +88,7 @@ std::ostream & OutputFile::stream () OutputFile &OutputFile::wraw(const char *s, const char *e) { - if (block().opts->target == opt_t::CODE) { + if (block().opts->target == TARGET_CODE) { insert_code(); stream().write(s, static_cast(e - s)); } @@ -107,7 +107,7 @@ OutputFile & OutputFile::wc_hex (uint32_t n) insert_code(); const opt_t *opts = block().opts; const Enc &e = opts->encoding; - prtChOrHex(stream(), n, e.szCodeUnit(), e.type() == Enc::EBCDIC, opts->target == opt_t::DOT); + prtChOrHex(stream(), n, e.szCodeUnit(), e.type() == Enc::EBCDIC, opts->target == TARGET_DOT); return *this; } @@ -116,7 +116,7 @@ OutputFile & OutputFile::wrange (uint32_t l, uint32_t u) insert_code(); const opt_t *opts = block().opts; const Enc &e = opts->encoding; - printSpan(stream(), l, u, e.szCodeUnit(), e.type() == Enc::EBCDIC, opts->target == opt_t::DOT); + printSpan(stream(), l, u, e.szCodeUnit(), e.type() == Enc::EBCDIC, opts->target == TARGET_DOT); return *this; } @@ -211,7 +211,7 @@ void OutputFile::insert_code () OutputFile &OutputFile::wdelay_tags(const ConfTags *cf) { - if (block().opts->target == opt_t::CODE) { + if (block().opts->target == TARGET_CODE) { OutputFragment *frag = new OutputFragment(OutputFragment::TAGS, 0); frag->tags = cf; blocks.back()->fragments.push_back(frag); @@ -244,7 +244,7 @@ OutputFile & OutputFile::wdelay_cond_table(uint32_t ind) OutputFile & OutputFile::wdelay_state_goto (uint32_t ind) { - if (block().opts->target == opt_t::CODE + if (block().opts->target == TARGET_CODE && block().opts->fFlag && !state_goto) { block().fragments.push_back (new OutputFragment (OutputFragment::STATE_GOTO, ind)); state_goto = true; @@ -254,7 +254,7 @@ OutputFile & OutputFile::wdelay_state_goto (uint32_t ind) OutputFile & OutputFile::wdelay_types () { - if (block().opts->target == opt_t::CODE) { + if (block().opts->target == TARGET_CODE) { warn_condition_order = false; // see note [condition order] block().fragments.push_back (new OutputFragment (OutputFragment::TYPES, 0)); } @@ -269,7 +269,7 @@ OutputFile & OutputFile::wdelay_yyaccept_init (uint32_t ind) OutputFile & OutputFile::wdelay_yymaxfill () { - if (block().opts->target == opt_t::CODE) { + if (block().opts->target == TARGET_CODE) { block().fragments.push_back (new OutputFragment (OutputFragment::YYMAXFILL, 0)); } return *this; @@ -694,7 +694,7 @@ void output_cond_goto(std::ostream &o, uint32_t ind, const size_t ncond = conds.size(); const std::string indstr = indent(ind, opts->indString); - if (opts->target == opt_t::DOT) { + if (opts->target == TARGET_DOT) { for (size_t i = 0; i < ncond; ++i) { const std::string &cond = conds[i]; o << "0 -> " << cond << " [label=\"state=" << cond << "\"]\n"; diff --git a/re2c/src/compile.cc b/re2c/src/compile.cc index 6e099e88..4f56d8b7 100644 --- a/re2c/src/compile.cc +++ b/re2c/src/compile.cc @@ -57,7 +57,7 @@ smart_ptr compile(const spec_t &spec, Output &output) // but prior to any other DFA transformations Skeleton skeleton(dfa, opts, defrule, name, cond, line); warn_undefined_control_flow(skeleton, warn); - if (opts->target == opt_t::SKELETON) { + if (opts->target == TARGET_SKELETON) { emit_data(skeleton); } diff --git a/re2c/src/conf/opt.cc b/re2c/src/conf/opt.cc index 8f51d9fc..56335372 100644 --- a/re2c/src/conf/opt.cc +++ b/re2c/src/conf/opt.cc @@ -36,7 +36,7 @@ void opt_t::fix () // with current target: reset them to default switch (target) { - case DOT: + case TARGET_DOT: // default code generation options sFlag = Opt::baseopt.sFlag; bFlag = Opt::baseopt.bFlag; @@ -45,7 +45,7 @@ void opt_t::fix () // default environment-insensitive formatting yybmHexTable = Opt::baseopt.yybmHexTable; // fallthrough - case SKELETON: + case TARGET_SKELETON: // default line information iFlag = Opt::baseopt.iFlag; // default environment-sensitive formatting @@ -216,10 +216,10 @@ void opt_t::fix () // force individual options switch (target) { - case DOT: + case TARGET_DOT: iFlag = true; break; - case SKELETON: + case TARGET_SKELETON: iFlag = true; input_api = INPUT_CUSTOM; indString = " "; diff --git a/re2c/src/conf/opt.h b/re2c/src/conf/opt.h index 0d290034..32481a0e 100644 --- a/re2c/src/conf/opt.h +++ b/re2c/src/conf/opt.h @@ -15,9 +15,16 @@ namespace re2c { +enum target_t +{ + TARGET_CODE, + TARGET_DOT, + TARGET_SKELETON +}; + #define RE2C_OPTS \ /* target */ \ - OPT1 (opt_t::target_t, target, CODE) \ + OPT1 (target_t, target, TARGET_CODE) \ /* output file */ \ OPT (std::string, output_file, "") \ /* fingerprint */ \ @@ -129,13 +136,6 @@ namespace re2c struct opt_t { - enum target_t - { - CODE, - DOT, - SKELETON - }; - #define OPT1 OPT #define OPT(type, name, value) type name; RE2C_OPTS diff --git a/re2c/src/conf/parse_opts.re b/re2c/src/conf/parse_opts.re index dc676503..fe7927ba 100644 --- a/re2c/src/conf/parse_opts.re +++ b/re2c/src/conf/parse_opts.re @@ -100,14 +100,14 @@ opt_short: "b" { opts.set_bFlag (true); goto opt_short; } "c" { opts.set_cFlag (true); goto opt_short; } "d" { opts.set_dFlag (true); goto opt_short; } - "D" { opts.set_target (opt_t::DOT); goto opt_short; } + "D" { opts.set_target (TARGET_DOT); goto opt_short; } "f" { opts.set_fFlag (true); goto opt_short; } "F" { opts.set_FFlag (true); goto opt_short; } "g" { opts.set_gFlag (true); goto opt_short; } "i" { opts.set_iFlag (true); goto opt_short; } "r" { opts.set_rFlag (true); goto opt_short; } "s" { opts.set_sFlag (true); goto opt_short; } - "S" { opts.set_target (opt_t::SKELETON); goto opt_short; } + "S" { opts.set_target (TARGET_SKELETON); goto opt_short; } "T" { opts.set_tags (true); goto opt_short; } "e" { opts.set_encoding(Enc::EBCDIC); goto opt_short; } "u" { opts.set_encoding(Enc::UTF32); goto opt_short; } @@ -134,7 +134,7 @@ opt_long: "bit-vectors" end { opts.set_bFlag (true); goto opt; } "start-conditions" end { opts.set_cFlag (true); goto opt; } "debug-output" end { opts.set_dFlag (true); goto opt; } - "emit-dot" end { opts.set_target (opt_t::DOT); goto opt; } + "emit-dot" end { opts.set_target (TARGET_DOT); goto opt; } "storable-state" end { opts.set_fFlag (true); goto opt; } "flex-syntax" end { opts.set_FFlag (true); goto opt; } "computed-gotos" end { opts.set_gFlag (true); goto opt; } @@ -145,7 +145,7 @@ opt_long: "no-version" end { opts.set_version (false); goto opt; } "case-insensitive" end { opts.set_bCaseInsensitive (true); goto opt; } "case-inverted" end { opts.set_bCaseInverted (true); goto opt; } - "skeleton" end { opts.set_target (opt_t::SKELETON); goto opt; } + "skeleton" end { opts.set_target (TARGET_SKELETON); 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; }