From: Ulya Trofimovich Date: Sat, 22 Oct 2016 11:07:58 +0000 (+0100) Subject: Introduced tag versioning. X-Git-Tag: 1.0~39^2~251 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5a5b8cfe71e6d209ef25c97a722595f2035aae7;p=re2c Introduced tag versioning. Instead of treating tag as boolean variable (true - present, false - absent) we now allow it to have many versions. Special version value 'TAGVER_ZERO' denotes tag absense (corresponds to 'false'). For now, each tag has exactly one version except 'TAGVER_ZERO': tag's number plus one. We need tag versions because with only two values it's impossible to expess more subtle states, e.g. initialized / uninitialized. Tag versions will also allow to treat fallback tags like any other tags (in particular, allow them participate in deduplication). In future, when we add nondeterministic tags, versions will be used to implement tag copies. --- diff --git a/re2c/src/codegen/emit.h b/re2c/src/codegen/emit.h index a96575c1..d543ffa2 100644 --- a/re2c/src/codegen/emit.h +++ b/re2c/src/codegen/emit.h @@ -17,10 +17,10 @@ void gen_goto_case(OutputFile &o, uint32_t ind, bool &readCh, void gen_goto_if(OutputFile &o, uint32_t ind, bool &readCh, const State *to, const DFA &dfa, const tagcmd_t &tags, bool restore_fallback); void gen_settags(code_lines_t &code, const DFA &dfa, const tagcmd_t &tags, bool restore_fallback); -std::string vartag_name(const std::string *name, size_t rule); -std::string vartag_expr(const std::string *name, size_t rule); -std::string vartag_name_fallback(const Tag &tag); -std::string vartag_expr_fallback(const Tag &tag); +std::string vartag_name(tagver_t ver); +std::string vartag_expr(tagver_t ver); +std::string vartag_name_fallback(tagver_t ver); +std::string vartag_expr_fallback(tagver_t ver); } // namespace re2c diff --git a/re2c/src/codegen/emit_action.cc b/re2c/src/codegen/emit_action.cc index f25ba1c3..08613ad8 100644 --- a/re2c/src/codegen/emit_action.cc +++ b/re2c/src/codegen/emit_action.cc @@ -386,7 +386,7 @@ void gen_settags(code_lines_t &code, const DFA &dfa, const tagcmd_t &cmd, bool restore_fallback) { const bool generic = opts->input_api.type() == InputAPI::CUSTOM; - const bool + const tagver_t *set = dfa.tagpool[cmd.set], *copy = dfa.tagpool[cmd.copy]; const std::valarray &tags = dfa.tags; @@ -405,11 +405,11 @@ void gen_settags(code_lines_t &code, const DFA &dfa, // copy for (size_t i = 0; i < ntags; ++i) { - if (copy[i]) { - const Tag &tag = tags[i]; + const tagver_t v = copy[i]; + if (v != TAGVER_ZERO) { std::string - x = vartag_expr(tag.name, tag.rule), - y = vartag_expr_fallback(tag); + x = vartag_expr(v), + y = vartag_expr_fallback(v); if (restore_fallback) std::swap(x, y); line = generic ? opts->yycopytag + " (" + y + ", " + x + ");\n" @@ -421,19 +421,18 @@ void gen_settags(code_lines_t &code, const DFA &dfa, // set if (generic) { for (size_t i = 0; i < ntags; ++i) { - if (set[i]) { - const Tag &tag = tags[i]; - line = opts->yybackuptag + " (" - + vartag_expr(tag.name, tag.rule) + ");\n"; + const tagver_t v = set[i]; + if (v != TAGVER_ZERO) { + line = opts->yybackuptag + " (" + vartag_expr(v) + ");\n"; code.push_back(line); } } } else if (cmd.set != ZERO_TAGS) { line = ""; for (size_t i = 0; i < ntags; ++i) { - if (set[i]) { - const Tag &tag = tags[i]; - line += vartag_expr(tag.name, tag.rule) + " = "; + const tagver_t v = set[i]; + if (v != TAGVER_ZERO) { + line += vartag_expr(v) + " = "; } } line += opts->yycursor + ";\n"; @@ -445,6 +444,7 @@ void gen_fintags(OutputFile &o, uint32_t ind, const DFA &dfa, const Rule &rule) { const bool generic = opts->input_api.type() == InputAPI::CUSTOM; const std::valarray &tags = dfa.tags; + const tagver_t *vers = dfa.tagpool[rule.tags]; // trailing context if (rule.trail != Tag::NONE) { @@ -460,8 +460,7 @@ void gen_fintags(OutputFile &o, uint32_t ind, const DFA &dfa, const Rule &rule) o.wstring(opts->yycursor).ws(" = ").wstring(opts->yyctxmarker); } } else { - const Tag &orig = tags[tag.var.orig]; - const std::string expr = vartag_expr(orig.name, orig.rule); + const std::string expr = vartag_expr(vers[rule.trail]); if (generic) { o.wstring(opts->yyrestoretag).ws(" (").wstring(expr).ws(")"); } else { @@ -484,17 +483,15 @@ void gen_fintags(OutputFile &o, uint32_t ind, const DFA &dfa, const Rule &rule) // to '(YYCURSOR - tag)' o.wstring(opts->yycursor).ws(" - ").wu64(tag.fix.dist); } else { - const Tag &orig = tags[tags[tag.fix.base].var.orig]; - o.wstring(vartag_expr(orig.name, orig.rule)) - .ws(" - ").wu64(tag.fix.dist); + const tagver_t v = vers[tag.fix.base]; + o.wstring(vartag_expr(v)).ws(" - ").wu64(tag.fix.dist); } o.ws(";\n"); continue; } // variable - const Tag &orig = tags[tag.var.orig]; - const std::string expr = vartag_expr(orig.name, orig.rule); + const std::string expr = vartag_expr(vers[t]); o.wind(ind); if (generic) { o.wstring(opts->yycopytag).ws(" (").wstring(*tag.name) diff --git a/re2c/src/codegen/emit_dfa.cc b/re2c/src/codegen/emit_dfa.cc index 811b9733..d103e3dc 100644 --- a/re2c/src/codegen/emit_dfa.cc +++ b/re2c/src/codegen/emit_dfa.cc @@ -147,18 +147,19 @@ void DFA::emit(Output & output, uint32_t& ind, bool isLastCond, bool& bPrologBra if (!oldstyle_ctxmarker) { const size_t ntags = tags.size(); for (size_t i = 0; i < ntags; ++i) { - const Tag &t = tags[i]; - if (t.type == Tag::VAR && t.var.orig == i) { - tagnames.insert(vartag_name(t.name, t.rule)); - } - if (t.name != NULL) { - tagvars.insert(*t.name); + const std::string *name = tags[i].name; + if (name) { + tagvars.insert(*name); } } - const bool *copy = tagpool[copy_tags]; + for (tagver_t v = 1; v <= maxtagver; ++v) { + tagnames.insert(vartag_name(v)); + } + const tagver_t *copy = tagpool[copy_tags]; for (size_t i = 0; i < ntags; ++i) { - if (copy[i]) { - tagnames.insert(vartag_name_fallback(tags[i])); + const tagver_t v = copy[i]; + if (v != TAGVER_ZERO) { + tagnames.insert(vartag_name_fallback(v)); } } ob.tags.insert(tagnames.begin(), tagnames.end()); @@ -372,34 +373,32 @@ void genCondGoto(OutputFile & o, uint32_t ind, const std::vector & bWroteCondCheck = true; } -std::string vartag_name(const std::string *name, size_t rule) +std::string vartag_name(tagver_t ver) { std::ostringstream s; - s << opts->tags_prefix << rule; - if (name != NULL) { - s << *name; - } + s << opts->tags_prefix << ver; return s.str(); } -std::string vartag_expr(const std::string *name, size_t rule) +std::string vartag_expr(tagver_t ver) { - const std::string s = vartag_name(name, rule); + const std::string s = vartag_name(ver); std::string e = opts->tags_expression; strrreplace(e, "@@", s); return e; } -std::string vartag_name_fallback(const Tag &tag) +std::string vartag_name_fallback(tagver_t ver) { - const std::string name = (tag.name == NULL ? "" : *tag.name) + "_"; - return vartag_name(&name, tag.rule); + return vartag_name(ver) + "_"; } -std::string vartag_expr_fallback(const Tag &tag) +std::string vartag_expr_fallback(tagver_t ver) { - const std::string name = (tag.name == NULL ? "" : *tag.name) + "_"; - return vartag_expr(&name, tag.rule); + const std::string s = vartag_name_fallback(ver); + std::string e = opts->tags_expression; + strrreplace(e, "@@", s); + return e; } } // end namespace re2c diff --git a/re2c/src/codegen/go_emit.cc b/re2c/src/codegen/go_emit.cc index 7970c997..4dc48c88 100644 --- a/re2c/src/codegen/go_emit.cc +++ b/re2c/src/codegen/go_emit.cc @@ -218,11 +218,11 @@ void Dot::emit(OutputFile &o, const DFA &dfa) for (uint32_t j = 0; j < c.ranges.size(); ++j) { o.wrange(c.ranges[j].first, c.ranges[j].second); } - const bool *tags = dfa.tagpool[c.tags.set]; + const tagver_t *tags = dfa.tagpool[c.tags.set]; for (size_t j = 0; j < dfa.tagpool.ntags; ++j) { - if (tags[j]) { - const Tag &t = dfa.tags[dfa.tags[j].var.orig]; - o.ws("<").wstring(vartag_name(t.name, t.rule)).ws(">"); + const tagver_t v = tags[j]; + if (v != TAGVER_ZERO) { + o.ws("<").wstring(vartag_name(v)).ws(">"); } } o.ws("\"]\n"); diff --git a/re2c/src/ir/adfa/adfa.cc b/re2c/src/ir/adfa/adfa.cc index aac23a96..13a240ad 100644 --- a/re2c/src/ir/adfa/adfa.cc +++ b/re2c/src/ir/adfa/adfa.cc @@ -23,6 +23,7 @@ DFA::DFA , const std::string &n , const std::string &c , uint32_t l + , tagver_t maxver ) : accepts () , skeleton (skel) @@ -41,6 +42,7 @@ DFA::DFA , need_backup (false) , need_accept (false) , oldstyle_ctxmarker (false) + , maxtagver (maxver) { const size_t nstates = dfa.states.size(); const size_t nchars = dfa.nchars; diff --git a/re2c/src/ir/adfa/adfa.h b/re2c/src/ir/adfa/adfa.h index 3a0f18ca..1cac4c96 100644 --- a/re2c/src/ir/adfa/adfa.h +++ b/re2c/src/ir/adfa/adfa.h @@ -74,6 +74,7 @@ struct DFA bool need_backup; bool need_accept; bool oldstyle_ctxmarker; + tagver_t maxtagver; DFA ( const dfa_t &dfa , const std::vector &fill @@ -82,11 +83,12 @@ struct DFA , const std::string &n , const std::string &c , uint32_t l + , tagver_t maxver ); ~DFA (); void reorder(); void prepare(); - void calc_stats(uint32_t line, size_t used_tags); + void calc_stats(uint32_t line); void emit (Output &, uint32_t &, bool, bool &); private: diff --git a/re2c/src/ir/adfa/prepare.cc b/re2c/src/ir/adfa/prepare.cc index 61eb5872..c1f5da18 100644 --- a/re2c/src/ir/adfa/prepare.cc +++ b/re2c/src/ir/adfa/prepare.cc @@ -190,7 +190,7 @@ void DFA::prepare () } } -void DFA::calc_stats(uint32_t line, size_t used_tags) +void DFA::calc_stats(uint32_t line) { // calculate 'YYMAXFILL' max_fill = 0; @@ -214,13 +214,13 @@ void DFA::calc_stats(uint32_t line, size_t used_tags) // re2c should use old-style YYCTXMARKER for backwards compatibility. // Note that with generic API fixed-length contexts are forbidden, // which may cause additional overlaps. - oldstyle_ctxmarker = used_tags == 1 + oldstyle_ctxmarker = maxtagver == 1 && copy_tags == ZERO_TAGS && !opts->tags; // error if tags are not enabled, but we need them if (!opts->tags - && (used_tags > 1 || copy_tags != ZERO_TAGS)) { + && (maxtagver > 1 || copy_tags != ZERO_TAGS)) { error("line %u: overlapping trailing contexts need " "multiple context markers, use '-t, --tags' " "option and '/*!tags:re2c ... */' directive", diff --git a/re2c/src/ir/compile.cc b/re2c/src/ir/compile.cc index 6d17b1d3..afd431da 100644 --- a/re2c/src/ir/compile.cc +++ b/re2c/src/ir/compile.cc @@ -69,7 +69,7 @@ static smart_ptr compile_rules( insert_fallback_tags(dfa); // try to minimize the number of tag variables - const size_t used_tags = deduplicate_tags(dfa); + const tagver_t maxtagver = deduplicate_tags(dfa); minimization(dfa); @@ -78,7 +78,7 @@ static smart_ptr compile_rules( fillpoints(dfa, fill); // ADFA stands for 'DFA with actions' - DFA *adfa = new DFA(dfa, fill, skeleton, cs, name, cond, line); + DFA *adfa = new DFA(dfa, fill, skeleton, cs, name, cond, line, maxtagver); // see note [reordering DFA states] adfa->reorder(); @@ -87,7 +87,7 @@ static smart_ptr compile_rules( adfa->prepare(); // finally gather overall DFA statistics - adfa->calc_stats(line, used_tags); + adfa->calc_stats(line); // accumulate global statistics from this particular DFA output.max_fill = std::max (output.max_fill, adfa->max_fill); diff --git a/re2c/src/ir/dfa/closure.cc b/re2c/src/ir/dfa/closure.cc index c7a09fa5..ddb1373e 100644 --- a/re2c/src/ir/dfa/closure.cc +++ b/re2c/src/ir/dfa/closure.cc @@ -6,7 +6,7 @@ namespace re2c { -static void closure_one(closure_t &clos, Tagpool &tagpool, nfa_state_t *n, bool *tags, bool *badtags); +static void closure_one(closure_t &clos, Tagpool &tagpool, nfa_state_t *n, tagver_t *tags, bool *badtags); static void check_tags(const Tagpool &tagpool, size_t oldidx, size_t newidx, bool *badtags); static bool compare_by_rule(const clos_t &c1, const clos_t &c2); static void prune_final_items(closure_t &clos, std::valarray &rules); @@ -17,8 +17,8 @@ size_t closure(const closure_t &clos1, closure_t &clos2, { // build tagged epsilon-closure of the given set of NFA states clos2.clear(); - bool *tags = tagpool.buffer1; - std::fill(tags, tags + tagpool.ntags, false); + tagver_t *tags = tagpool.buffer1; + std::fill(tags, tags + tagpool.ntags, TAGVER_ZERO); for (cclositer_t c = clos1.begin(); c != clos1.end(); ++c) { closure_one(clos2, tagpool, c->state, tags, badtags); } @@ -47,7 +47,7 @@ size_t closure(const closure_t &clos1, closure_t &clos2, * ambiguous. All tags are merged together; ambiguity is reported. */ void closure_one(closure_t &clos, Tagpool &tagpool, - nfa_state_t *n, bool *tags, bool *badtags) + nfa_state_t *n, tagver_t *tags, bool *badtags) { // trace the first iteration of each loop: // epsilon-loops may add ney tags and reveal conflicts @@ -63,8 +63,8 @@ void closure_one(closure_t &clos, Tagpool &tagpool, break; case nfa_state_t::TAG: { const size_t t = n->tag.info; - const bool old = tags[t]; - tags[t] = true; + const tagver_t old = tags[t]; + tags[t] = static_cast(t + 1); closure_one(clos, tagpool, n->tag.out, tags, badtags); tags[t] = old; break; @@ -96,11 +96,11 @@ void closure_one(closure_t &clos, Tagpool &tagpool, */ void check_tags(const Tagpool &tagpool, size_t oldidx, size_t newidx, bool *badtags) { - const bool + const tagver_t *oldtags = tagpool[oldidx], *newtags = tagpool[newidx]; for (size_t i = 0; i < tagpool.ntags; ++i) { - badtags[i] |= oldtags[i] ^ newtags[i]; + badtags[i] |= oldtags[i] != newtags[i]; } } @@ -167,12 +167,12 @@ void prune_final_items(closure_t &clos, std::valarray &rules) size_t merge_and_check_tags(const closure_t &clos, Tagpool &tagpool, const std::valarray &rules, bool *badtags) { - bool *tags = tagpool.buffer1; - std::fill(tags, tags + tagpool.ntags, false); + tagver_t *tags = tagpool.buffer1; + std::fill(tags, tags + tagpool.ntags, TAGVER_ZERO); size_t r = 0, lt = 0, ht; for (cclositer_t c = clos.begin(), e = clos.end(); c != e;) { - const bool *x = tagpool[c->tagidx]; + const tagver_t *x = tagpool[c->tagidx]; // find next rule that occurs in closure for (; r < c->state->rule; lt = rules[r].htag, ++r); @@ -180,14 +180,14 @@ size_t merge_and_check_tags(const closure_t &clos, Tagpool &tagpool, // merge tags of the 1st item belonging to this rule for (size_t t = lt; t < ht; ++t) { - tags[t] |= x[t]; + tags[t] = x[t]; } // check the remaining items with this for tag nondeterminism: // if some tag differs from that of the 1st item, then it is // nondeterministic (don't merge it, only note the conflict) for (++c; c != e && c->state->rule == r; ++c) { - const bool *y = tagpool[c->tagidx]; + const tagver_t *y = tagpool[c->tagidx]; for (size_t t = lt; t < ht; ++t) { badtags[t] |= y[t] != x[t]; } diff --git a/re2c/src/ir/dfa/dfa.h b/re2c/src/ir/dfa/dfa.h index 25616143..f38539ef 100644 --- a/re2c/src/ir/dfa/dfa.h +++ b/re2c/src/ir/dfa/dfa.h @@ -70,7 +70,7 @@ void minimization(dfa_t &dfa); void fillpoints(const dfa_t &dfa, std::vector &fill); void cutoff_dead_rules(dfa_t &dfa, size_t defrule, const std::string &cond); void insert_fallback_tags(dfa_t &dfa); -size_t deduplicate_tags(dfa_t &dfa); +tagver_t deduplicate_tags(dfa_t &dfa); } // namespace re2c diff --git a/re2c/src/ir/dfa/fallback_tags.cc b/re2c/src/ir/dfa/fallback_tags.cc index fe667989..1f3759ab 100644 --- a/re2c/src/ir/dfa/fallback_tags.cc +++ b/re2c/src/ir/dfa/fallback_tags.cc @@ -3,7 +3,7 @@ namespace re2c { -static void find_overwritten_tags(const dfa_t &dfa, size_t state, bool *been, bool *owrt); +static void find_overwritten_tags(const dfa_t &dfa, size_t state, bool *been, tagver_t *owrt); /* note [fallback tags] * @@ -34,7 +34,7 @@ static void find_overwritten_tags(const dfa_t &dfa, size_t state, bool *been, bo */ void find_overwritten_tags(const dfa_t &dfa, size_t state, - bool *been, bool *owrt) + bool *been, tagver_t *owrt) { if (been[state]) return; been[state] = true; @@ -43,9 +43,12 @@ void find_overwritten_tags(const dfa_t &dfa, size_t state, const size_t ntags = dfa.tags.size(); for (size_t c = 0; c < dfa.nchars; ++c) { - const bool *tags = dfa.tagpool[s->tags[c].set]; + const tagver_t *tags = dfa.tagpool[s->tags[c].set]; for (size_t t = 0; t < ntags; ++t) { - owrt[t] |= tags[t]; + const tagver_t v = tags[t]; + if (v != TAGVER_ZERO) { + owrt[t] = v; + } } size_t dest = s->arcs[c]; @@ -64,25 +67,29 @@ void insert_fallback_tags(dfa_t &dfa) nstates = dfa.states.size(), ntags = dfa.tags.size(); bool *been = new bool[nstates]; - bool *total = dfa.tagpool.buffer2; - std::fill(total, total + ntags, false); + tagver_t *total = dfa.tagpool.buffer2; + std::fill(total, total + ntags, TAGVER_ZERO); for (size_t i = 0; i < nstates; ++i) { dfa_state_t *s = dfa.states[i]; if (!s->fallback) continue; - bool *owrt = dfa.tagpool.buffer1; - std::fill(owrt, owrt + ntags, false); + tagver_t *owrt = dfa.tagpool.buffer1; + std::fill(owrt, owrt + ntags, TAGVER_ZERO); std::fill(been, been + nstates, false); find_overwritten_tags(dfa, i, been, owrt); - const bool + const tagver_t *fin = dfa.tagpool[dfa.rules[s->rule].tags], *upd = dfa.tagpool[s->rule_tags.set]; for (size_t t = 0; t < ntags; ++t) { - owrt[t] &= fin[t] && !upd[t]; - total[t] |= owrt[t]; + if (fin[t] == TAGVER_ZERO || upd[t] != TAGVER_ZERO) { + owrt[t] = TAGVER_ZERO; + } + if (owrt[t] != TAGVER_ZERO) { + total[t] = owrt[t]; + } } const size_t copy = dfa.tagpool.insert(owrt); diff --git a/re2c/src/ir/dfa/tag_deduplication.cc b/re2c/src/ir/dfa/tag_deduplication.cc index 95243dff..496f41bc 100644 --- a/re2c/src/ir/dfa/tag_deduplication.cc +++ b/re2c/src/ir/dfa/tag_deduplication.cc @@ -6,6 +6,17 @@ namespace re2c { +static void unpack(size_t nver, bool *vers, size_t ntag, const tagver_t *tags) +{ + memset(vers, 0, nver * sizeof(bool)); + for (size_t t = 0; t < ntag; ++t) { + const tagver_t v = tags[t]; + if (v != TAGVER_ZERO) { + vers[v] = true; + } + } +} + static void forwprop(const dfa_t &dfa, bool *been, size_t state, bool *live, const bool *need) { @@ -14,29 +25,32 @@ static void forwprop(const dfa_t &dfa, bool *been, size_t state, const size_t nsym = dfa.nchars, - ntag = dfa.tags.size(); + nver = dfa.tags.size() + 1; const dfa_state_t *s = dfa.states[state]; for (size_t c = 0; c < nsym; ++c) { const size_t dest = s->arcs[c]; if (dest != dfa_t::NIL && dfa.states[dest]->fallthru) { - bool *l = &live[(state * nsym + c) * ntag]; - for (size_t t = 0; t < ntag; ++t) { - l[t] |= need[t]; + bool *l = &live[(state * nsym + c) * nver]; + for (size_t v = 0; v < nver; ++v) { + l[v] |= need[v]; } forwprop(dfa, been, dest, live, need); } } } -static void liveness(const dfa_t &dfa, bool *live) +static void liveness_analysis(const dfa_t &dfa, bool *live) { const size_t nstate = dfa.states.size(), nsym = dfa.nchars, narc = nstate * nsym, - ntag = dfa.tags.size(); - bool *l0 = dfa.tagpool.buffer1; + ntag = dfa.tags.size(), + nver = ntag + 1; + bool *buf1 = new bool[nver]; + bool *buf2 = new bool[nver]; + bool *been = new bool[nstate]; /* note [control flow equations for tag liveness] * @@ -50,7 +64,7 @@ static void liveness(const dfa_t &dfa, bool *live) * - all outgoing arcs from state s2 * - if state s2 is final, corresponding rule action */ - memset(live, 0, narc * ntag * sizeof(bool)); + memset(live, 0, narc * nver * sizeof(bool)); for (bool loop = true; loop;) { loop = false; @@ -59,29 +73,33 @@ static void liveness(const dfa_t &dfa, bool *live) if (i == dfa_t::NIL) continue; const dfa_state_t *s = dfa.states[i]; - bool *l = &live[a * ntag]; - memcpy(l0, l, ntag * sizeof(bool)); - memset(l, 0, ntag * sizeof(bool)); + memset(buf1, 0, nver * sizeof(bool)); if (s->rule != Rule::NONE) { - const bool + const tagver_t *use = dfa.tagpool[dfa.rules[s->rule].tags], *def = dfa.tagpool[s->rule_tags.set]; for (size_t t = 0; t < ntag; ++t) { - l[t] |= use[t] && !def[t]; + const tagver_t u = use[t], d = def[t]; + if (u != TAGVER_ZERO && d == TAGVER_ZERO) { + buf1[u] = true; + } } } for (size_t c = 0; c < nsym; ++c) { - const bool - *use = &live[(i * nsym + c) * ntag], - *def = dfa.tagpool[s->tags[c].set]; - for (size_t t = 0; t < ntag; ++t) { - l[t] |= use[t] && !def[t]; + const bool *use = &live[(i * nsym + c) * nver]; + unpack(nver, buf2, ntag, dfa.tagpool[s->tags[c].set]); + for (size_t v = 0; v < nver; ++v) { + buf1[v] |= use[v] && !buf2[v]; } } - loop |= memcmp(l, l0, ntag * sizeof(bool)) != 0; + bool *liv = &live[a * nver]; + if (memcmp(liv, buf1, nver * sizeof(bool)) != 0) { + memcpy(liv, buf1, nver * sizeof(bool)); + loop = true; + } } } @@ -91,29 +109,36 @@ static void liveness(const dfa_t &dfa, bool *live) * state (see note [fallback states]) and until there remain * any fallthrough paths from current state. */ - bool *been = new bool[nstate]; for (size_t i = 0; i < nstate; ++i) { const dfa_state_t *s = dfa.states[i]; if (s->fallback) { - const bool + const tagver_t *use = dfa.tagpool[dfa.rules[s->rule].tags], *def = dfa.tagpool[s->rule_tags.set]; + memset(buf1, 0, nver * sizeof(bool)); for (size_t t = 0; t < ntag; ++t) { - l0[t] = use[t] && !def[t]; + const tagver_t u = use[t], d = def[t]; + if (u != TAGVER_ZERO && d == TAGVER_ZERO) { + buf1[u] = true; + } } - std::fill(been, been + nstate, false); - forwprop(dfa, been, i, live, l0); + memset(been, 0, nstate * sizeof(bool)); + forwprop(dfa, been, i, live, buf1); } } + + delete[] buf1; + delete[] buf2; delete[] been; } -static void mask_dead(dfa_t &dfa, const bool *live) +static void dead_code_elimination(dfa_t &dfa, const bool *live) { const size_t nsym = dfa.nchars, narc = dfa.states.size() * nsym, - ntag = dfa.tags.size(); + ntag = dfa.tags.size(), + nver = ntag + 1; for (size_t a = 0; a < narc; ++a) { const size_t @@ -124,12 +149,13 @@ static void mask_dead(dfa_t &dfa, const bool *live) size_t *p = &s->tags[c].set; if (*p != ZERO_TAGS) { - const bool - *liv = &live[a * ntag], - *set = dfa.tagpool[*p]; - bool *set_liv = dfa.tagpool.buffer1; + const bool *liv = &live[a * nver]; + const tagver_t *set = dfa.tagpool[*p]; + tagver_t *set_liv = dfa.tagpool.buffer1; for (size_t t = 0; t < ntag; ++t) { - set_liv[t] = set[t] && liv[t]; + const tagver_t v = set[t]; + set_liv[t] = v != TAGVER_ZERO && liv[v] + ? v : TAGVER_ZERO; } *p = dfa.tagpool.insert(set_liv); } @@ -138,61 +164,53 @@ static void mask_dead(dfa_t &dfa, const bool *live) // tags that are updated here are pairwise incompatible // with all tags that are alive, but not updated here -static void interfere(bool *intrf, size_t ntag, +static void interfere(bool *interf, size_t nver, const bool *live, const bool *tags) { - for (size_t i = 0; i < ntag; ++i) { + for (size_t i = 0; i < nver; ++i) { if (live[i] && !tags[i]) { - for (size_t j = 0; j < ntag; ++j) { + for (size_t j = 0; j < nver; ++j) { if (tags[j]) { - intrf[i * ntag + j] = intrf[j * ntag + i] = true; + interf[i * nver + j] = interf[j * nver + i] = true; } } } } } -static void interference(const dfa_t &dfa, - const bool *live, bool *intrf) +static void interference_table(const dfa_t &dfa, + const bool *live, bool *interf) { const size_t nstate = dfa.states.size(), ntag = dfa.tags.size(), + nver = ntag + 1, nsym = dfa.nchars; + bool *buf1 = new bool[nver]; + bool *buf2 = new bool[nver]; - memset(intrf, 0, ntag * ntag * sizeof(bool)); + memset(interf, 0, nver * nver * sizeof(bool)); for (size_t i = 0; i < nstate; ++i) { const dfa_state_t *s = dfa.states[i]; if (s->rule != Rule::NONE) { - const bool - *liv = dfa.tagpool[dfa.rules[s->rule].tags], - *set = dfa.tagpool[s->rule_tags.set]; - interfere(intrf, ntag, liv, set); + unpack(nver, buf1, ntag, dfa.tagpool[dfa.rules[s->rule].tags]); + unpack(nver, buf2, ntag, dfa.tagpool[s->rule_tags.set]); + interfere(interf, nver, buf1, buf2); } for (size_t c = 0; c < nsym; ++c) { const size_t x = s->tags[c].set; if (x != ZERO_TAGS) { - const bool - *liv = &live[(i * nsym + c) * ntag], - *set = dfa.tagpool[x]; - interfere(intrf, ntag, liv, set); + const bool *liv = &live[(i * nsym + c) * nver]; + unpack(nver, buf1, ntag, dfa.tagpool[x]); + interfere(interf, nver, liv, buf1); } } } - // fixed tags should not participate in deduplication, so - // each fixed tag is incompatible with all other tags - for (size_t i = 0; i < ntag; ++i) { - if (dfa.tags[i].type == Tag::FIX) { - for (size_t j = 0; j < ntag; ++j) { - intrf[i * ntag + j] - = intrf[j * ntag + i] - = j != i; - } - } - } + delete[] buf1; + delete[] buf2; } /* We have a binary relation on the set of all tags @@ -206,110 +224,148 @@ static void interference(const dfa_t &dfa, * We build just some cover (not necessarily minimal). * The algorithm takes quadratic (in the number of tags) time. */ -static size_t equivalence_classes(const dfa_t &dfa, - const bool *intrf, size_t *represent) +static tagver_t version_allocation(const dfa_t &dfa, + const bool *interf, tagver_t *ver2new) { - static const size_t END = std::numeric_limits::max(); - const size_t ntags = dfa.tags.size(); - std::vector - head(ntags, END), // list of representatives - next(ntags, END); // list of tags mapped to the same representative - - // skip the 1st tag, it maps to itself - memset(represent, 0, ntags * sizeof(size_t)); - for (size_t c = 1; c < ntags; ++c) { - size_t h; - for (h = 0; h != END; h = head[h]) { - size_t n; + const size_t + END = std::numeric_limits::max(), + nver = dfa.tags.size() + 1; + size_t *head = new size_t[nver]; // list of class representatives + size_t *next = new size_t[nver]; // list of class members + size_t h0 = END, h, n; + + std::fill(head, head + nver, END); + std::fill(next, next + nver, END); + for (size_t v = 0; v < nver; ++v) { + const bool *interfv = &interf[v * nver]; + + // try all existing classes + for (h = h0; h != END; h = head[h]) { + + // check interference with class members for (n = h; n != END; n = next[n]) { - if (intrf[c * ntags + n]) { - break; - } + if (interfv[n]) break; } + + // no interference; add to class if (n == END) { - represent[c] = h; - next[c] = next[h]; - next[h] = c; + next[v] = next[h]; + next[h] = v; break; } } + + // make new equivalence class if (h == END) { - represent[c] = c; - head[c] = head[0]; - head[0] = c; + head[v] = h0; + h0 = v; } } - size_t nreps = 0; - for (size_t i = 0; i < ntags; ++i) { - if (dfa.tags[i].type == Tag::VAR && represent[i] == i) { - ++nreps; + tagver_t maxver = 0; + for (h = h0; h != END; h = head[h]) { + ++maxver; + for (n = h; n != END; n = next[n]) { + ver2new[n] = maxver; } } - return nreps; + + delete[] head; + delete[] next; + + return maxver; } -static void subst(Tagpool &tagpool, size_t *ptags, const size_t *represent) +static void rename(Tagpool &tagpool, size_t &tags, + const tagver_t *ver2new, bool unify) { + if (tags == ZERO_TAGS) return; + + const tagver_t *oldver = tagpool[tags]; + tagver_t *newver = tagpool.buffer1; const size_t ntag = tagpool.ntags; - const bool *tags = tagpool[*ptags]; - bool *subs = tagpool.buffer1; - memset(subs, 0, ntag * sizeof(bool)); + for (size_t t = 0; t < ntag; ++t) { - if (tags[t]) { - subs[represent[t]] = true; - } + const tagver_t v = oldver[t]; + newver[t] = v != TAGVER_ZERO + ? ver2new[v] + : v; + } + + // for transition tags, we don't care how versions map to + // tags: identical sets of versions should compare equal + // this doesn't apply to final tag versions in rules + if (unify) { + tagver_t *e = newver + ntag; + std::sort(newver, e); + std::fill(std::unique(newver, e), e, TAGVER_ZERO); } - *ptags = tagpool.insert(subs); + + tags = tagpool.insert(newver); } -static void substitute(dfa_t &dfa, const size_t *represent) +static void version_renaming(dfa_t &dfa, + const tagver_t *ver2new, tagver_t maxver) { + const tagver_t oldmax = static_cast(dfa.tags.size()); + if (maxver >= oldmax) { + assert(maxver == oldmax); + return; + } + + Tagpool &tagpool = dfa.tagpool; const size_t nstates = dfa.states.size(), - ntags = dfa.tags.size(); + nrule = dfa.rules.size(); for (size_t i = 0; i < nstates; ++i) { dfa_state_t *s = dfa.states[i]; for (size_t c = 0; c < dfa.nchars; ++c) { - subst(dfa.tagpool, &s->tags[c].set, represent); - subst(dfa.tagpool, &s->tags[c].copy, represent); + rename(tagpool, s->tags[c].set, ver2new, true); + rename(tagpool, s->tags[c].copy, ver2new, true); } - subst(dfa.tagpool, &s->rule_tags.set, represent); - subst(dfa.tagpool, &s->rule_tags.copy, represent); + rename(tagpool, s->rule_tags.set, ver2new, true); + rename(tagpool, s->rule_tags.copy, ver2new, true); } - subst(dfa.tagpool, &dfa.copy_tags, represent); + rename(dfa.tagpool, dfa.copy_tags, ver2new, true); + for (size_t i = 0; i < nrule; ++i) { + rename(tagpool, dfa.rules[i].tags, ver2new, false); + } +} - for (size_t i = 0; i < ntags; ++i) { - Tag &t = dfa.tags[i]; - if (t.type == Tag::VAR) { - t.var.orig = represent[i]; +static size_t count_vartags(const std::valarray &tags) +{ + size_t nvar = 0, ntag = tags.size(); + for (size_t t = 0; t < ntag; ++t) { + if (tags[t].type == Tag::VAR) { + ++nvar; } } + return nvar; } -size_t deduplicate_tags(dfa_t &dfa) +tagver_t deduplicate_tags(dfa_t &dfa) { - const size_t ntag = dfa.tags.size(); - if (ntag == 0) return 0; - - bool *live = new bool[dfa.states.size() * dfa.nchars * ntag]; - bool *interfere = new bool[ntag * ntag]; - size_t *represent = new size_t[ntag]; - - liveness(dfa, live); - mask_dead(dfa, live); - interference(dfa, live, interfere); - const size_t nrep = equivalence_classes(dfa, interfere, represent); - if (nrep < ntag) { - substitute(dfa, represent); - } + if (count_vartags(dfa.tags) == 0) return 0; + + const size_t + narc = dfa.states.size() * dfa.nchars, + nver = dfa.tags.size() + 1; + bool *live = new bool[narc * nver]; + bool *interf = new bool[nver * nver]; + tagver_t *rename = new tagver_t[nver]; + + liveness_analysis(dfa, live); + dead_code_elimination(dfa, live); + interference_table(dfa, live, interf); + const tagver_t maxver = version_allocation(dfa, interf, rename); + version_renaming(dfa, rename, maxver); delete[] live; - delete[] interfere; - delete[] represent; + delete[] interf; + delete[] rename; - return nrep; + return maxver; } } // namespace re2c diff --git a/re2c/src/ir/nfa/init_rules.cc b/re2c/src/ir/nfa/init_rules.cc index 7e43a2f4..d884cb17 100644 --- a/re2c/src/ir/nfa/init_rules.cc +++ b/re2c/src/ir/nfa/init_rules.cc @@ -50,12 +50,14 @@ void init_rules(const std::vector ®exps, rule.htag = t; // mark *all* variable tags, including trailing context - bool *mask = new bool[nt](); + tagver_t *vers = tagpool.buffer1; + std::fill(vers, vers + nt, TAGVER_ZERO); for (size_t i = rule.ltag; i < rule.htag; ++i) { - mask[i] = tags[i].type == Tag::VAR; + if (tags[i].type == Tag::VAR) { + vers[i] = static_cast(i + 1); + } } - rule.tags = tagpool.insert(mask); - delete[] mask; + rule.tags = tagpool.insert(vers); // tags in trailing context are forbidden (they make no sense), // and since tags are constructed in reversed order, this implies diff --git a/re2c/src/ir/nfa/make_tags.cc b/re2c/src/ir/nfa/make_tags.cc index 8baef4e5..7d055f45 100644 --- a/re2c/src/ir/nfa/make_tags.cc +++ b/re2c/src/ir/nfa/make_tags.cc @@ -34,11 +34,9 @@ static void make_tags_var(size_t nrule, dist = VARDIST; make_tags_var(nrule, tags, tagidx, re->iter, dist); break; - case RegExp::TAG: { - const size_t orig = tagidx; - init_var_tag(tags[tagidx++], nrule, re->tag, orig); + case RegExp::TAG: + init_var_tag(tags[tagidx++], nrule, re->tag); break; - } } } @@ -61,7 +59,7 @@ static void make_tags_var_fix(size_t nrule, const std::string *name = re->tag; if (dist == VARDIST) { base = tagidx; - init_var_tag(tags[tagidx++], nrule, name, base); + init_var_tag(tags[tagidx++], nrule, name); dist = 0; } else { init_fix_tag(tags[tagidx++], nrule, name, base, dist); diff --git a/re2c/src/ir/skeleton/path.h b/re2c/src/ir/skeleton/path.h index b0733c6f..34c3cc3c 100644 --- a/re2c/src/ir/skeleton/path.h +++ b/re2c/src/ir/skeleton/path.h @@ -45,26 +45,23 @@ public: tail = arcs.rbegin(), head = arcs.rend(); for (; tail != head; ++tail) { - const size_t rule_idx = skel.nodes[*tail].rule; - if (rule_idx == Rule::NONE) { - continue; - } + const Node &node = skel.nodes[*tail]; + if (node.rule == Rule::NONE) continue; + size_t len = static_cast(head - tail) - 1; - const size_t trail = skel.rules[rule_idx].trail; - if (trail == Tag::NONE) { - return len; - } + const size_t trail = node.trail; + if (trail == Tag::NONE) return len; + const Tag &tag = skel.tags[trail]; - switch (tag.type) { - case Tag::VAR: - for (; tail != head; ++tail) { - if (skel.nodes[*tail].tags[trail]) { - return static_cast(head - tail) - 1; - } + if (tag.type == Tag::FIX) { + return len - tag.fix.dist; + } else { + for (; tail != head; ++tail) { + if (skel.tagpool[skel.nodes[*tail].tags][trail] == node.trver) { + return static_cast(head - tail) - 1; } - assert(false); - case Tag::FIX: - return len - tag.fix.dist; + } + assert(false); } } return 0; diff --git a/re2c/src/ir/skeleton/skeleton.cc b/re2c/src/ir/skeleton/skeleton.cc index 0ebae734..01149d1d 100644 --- a/re2c/src/ir/skeleton/skeleton.cc +++ b/re2c/src/ir/skeleton/skeleton.cc @@ -12,19 +12,18 @@ Node::Node() : arcs() , arcsets() , rule(Rule::NONE) - , tags(NULL) + , trail(Tag::NONE) + , trver(TAGVER_ZERO) + , tags(ZERO_TAGS) {} -Node::~Node() -{ - delete[] tags; -} - -void Node::init(const bool *ts, size_t r, +void Node::init(size_t ts, size_t r, size_t tr, tagver_t tv, const std::vector > &a) { rule = r; tags = ts; + trail = tr; + trver = tv; uint32_t lb = 0; std::vector >::const_iterator @@ -68,9 +67,9 @@ Skeleton::Skeleton( , nodes_count(dfa.states.size() + 1) // +1 for default state , nodes(new Node[nodes_count]) , sizeof_key(8) - , rules(dfa.rules) , defrule(def) , tags(dfa.tags) + , tagpool(dfa.tagpool) { const size_t nc = cs.size() - 1; @@ -94,25 +93,36 @@ Skeleton::Skeleton( // in skeleton we are only interested in trailing contexts // which may be attributed to states rather than transitions // trailing context also cannot have fallback tag - Tagpool &tagpool = dfa.tagpool; - const size_t ntag = tagpool.ntags; - bool *tags = new bool[ntag]; - memcpy(tags, tagpool[s->rule_tags.set], ntag * sizeof(bool)); + const size_t ntag = tags.size(); + tagver_t *buf = tagpool.buffer1; + memcpy(buf, tagpool[s->rule_tags.set], ntag * sizeof(tagver_t)); for (size_t c = 0; c < nc; ++c) { - const size_t x = s->tags[c].set; - if (x == ZERO_TAGS) continue; - const bool *set = tagpool[x]; + const tagver_t *set = tagpool[s->tags[c].set]; for (size_t t = 0; t < ntag; ++t) { - tags[t] |= set[t]; + const tagver_t v = set[t]; + if (buf[t] == TAGVER_ZERO) { + buf[t] = v; + } else if (v != TAGVER_ZERO) { + assert(buf[t] == v); + } + } + } + + size_t trail = Tag::NONE; + tagver_t trver = TAGVER_ZERO; + if (s->rule != Rule::NONE) { + trail = dfa.rules[s->rule].trail; + if (trail != Tag::NONE) { + trver = tagpool[dfa.rules[s->rule].tags][trail]; } } - nodes[i].init(tags, s->rule, arcs); + nodes[i].init(tagpool.insert(buf), s->rule, trail, trver, arcs); } // initialize size of key const size_t maxlen = maxpath(*this); - const size_t maxrule = rules.size() + 1; // +1 for none-rule + const size_t maxrule = dfa.rules.size() + 1; // +1 for none-rule const size_t max = std::max(maxlen, maxrule); if (max <= std::numeric_limits::max()) { sizeof_key = 1; diff --git a/re2c/src/ir/skeleton/skeleton.h b/re2c/src/ir/skeleton/skeleton.h index cbe5c6f7..c7562659 100644 --- a/re2c/src/ir/skeleton/skeleton.h +++ b/re2c/src/ir/skeleton/skeleton.h @@ -36,11 +36,12 @@ struct Node arcs_t arcs; arcsets_t arcsets; size_t rule; - const bool *tags; + size_t trail; + tagver_t trver; + size_t tags; Node(); - ~Node(); - void init(const bool *ts, size_t r, + void init(size_t ts, size_t r, size_t tr, tagver_t tv, const std::vector > &arcs); bool end() const; @@ -57,9 +58,9 @@ struct Skeleton Node *nodes; size_t sizeof_key; - std::valarray &rules; const size_t defrule; const std::valarray &tags; + Tagpool &tagpool; Skeleton(const dfa_t &dfa, const charset_t &cs, size_t def, const std::string &dfa_name, const std::string &dfa_cond, diff --git a/re2c/src/ir/tag.cc b/re2c/src/ir/tag.cc index 7c33bfce..39d8abb7 100644 --- a/re2c/src/ir/tag.cc +++ b/re2c/src/ir/tag.cc @@ -15,9 +15,9 @@ struct eqtag_t size_t ntags; explicit eqtag_t(size_t n): ntags(n) {} - inline bool operator()(const bool *x, const bool *y) + inline tagver_t operator()(const tagver_t *x, const tagver_t *y) { - return memcmp(x, y, ntags * sizeof(bool)) == 0; + return memcmp(x, y, ntags * sizeof(tagver_t)) == 0; } }; @@ -27,14 +27,14 @@ Tag::Tag() : type(VAR) , rule(Rule::NONE) , name(NULL) + , fix() {} -void init_var_tag(Tag &tag, size_t r, const std::string *n, size_t o) +void init_var_tag(Tag &tag, size_t r, const std::string *n) { tag.type = Tag::VAR; tag.rule = r; tag.name = n; - tag.var.orig = o; } void init_fix_tag(Tag &tag, size_t r, const std::string *n, size_t b, size_t d) @@ -48,13 +48,13 @@ void init_fix_tag(Tag &tag, size_t r, const std::string *n, size_t b, size_t d) Tagpool::Tagpool(size_t n) : lookup() - , buffer(new bool[n * 3]) + , buffer(new tagver_t[n * 3]) , ntags(n) , buffer1(&buffer[n * 1]) , buffer2(&buffer[n * 2]) { // all-zero tag configuration must have static number zero - std::fill(buffer, buffer + ntags, false); + std::fill(buffer, buffer + ntags, TAGVER_ZERO); assert(ZERO_TAGS == insert(buffer)); } @@ -63,13 +63,13 @@ Tagpool::~Tagpool() delete[] buffer; const size_t n = lookup.size(); for (size_t i = 0; i < n; ++i) { - free(const_cast(lookup[i])); + free(const_cast(lookup[i])); } } -size_t Tagpool::insert(const bool *tags) +size_t Tagpool::insert(const tagver_t *tags) { - const size_t size = ntags * sizeof(bool); + const size_t size = ntags * sizeof(tagver_t); const uint32_t hash = hash32(0, tags, size); eqtag_t eq(ntags); @@ -78,12 +78,12 @@ size_t Tagpool::insert(const bool *tags) return idx; } - bool *copy = static_cast(malloc(size)); + tagver_t *copy = static_cast(malloc(size)); memcpy(copy, tags, size); return lookup.push(hash, copy); } -const bool *Tagpool::operator[](size_t idx) const +const tagver_t *Tagpool::operator[](size_t idx) const { return lookup[idx]; } diff --git a/re2c/src/ir/tag.h b/re2c/src/ir/tag.h index a046d32c..7e66bb8d 100644 --- a/re2c/src/ir/tag.h +++ b/re2c/src/ir/tag.h @@ -9,6 +9,10 @@ namespace re2c { +typedef int32_t tagver_t; + +static const tagver_t TAGVER_ZERO = 0; // absense of tag + struct Tag { static const size_t NONE; @@ -16,24 +20,17 @@ struct Tag enum {VAR, FIX} type; size_t rule; const std::string *name; - union + struct { - struct - { - size_t orig; - } var; - struct - { - size_t base; - size_t dist; - } fix; - }; + size_t base; + size_t dist; + } fix; Tag(); FORBID_COPY(Tag); }; -void init_var_tag(Tag &tag, size_t r, const std::string *n, size_t o); +void init_var_tag(Tag &tag, size_t r, const std::string *n); void init_fix_tag(Tag &tag, size_t r, const std::string *n, size_t b, size_t d); static const size_t ZERO_TAGS = 0; @@ -41,19 +38,19 @@ static const size_t ZERO_TAGS = 0; struct Tagpool { private: - typedef lookup_t taglookup_t; + typedef lookup_t taglookup_t; taglookup_t lookup; - bool *buffer; + tagver_t *buffer; public: const size_t ntags; - bool *buffer1; - bool *buffer2; + tagver_t *buffer1; + tagver_t *buffer2; explicit Tagpool(size_t n); ~Tagpool(); - size_t insert(const bool *tags); - const bool *operator[](size_t idx) const; + size_t insert(const tagver_t *tags); + const tagver_t *operator[](size_t idx) const; FORBID_COPY(Tagpool); }; diff --git a/re2c/test/scanner_re2c_default.--emit-dot.c b/re2c/test/scanner_re2c_default.--emit-dot.c index 89f6da4e..0cdd3b21 100644 --- a/re2c/test/scanner_re2c_default.--emit-dot.c +++ b/re2c/test/scanner_re2c_default.--emit-dot.c @@ -102,7 +102,7 @@ digraph re2c { 49 -> 50 50 -> 13 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] 50 -> 49 [label="[0x09][ ]"] -50 -> 57 [label="[1-9]"] +50 -> 57 [label="[1-9]"] 51 -> 13 [label="[0x00-s][u-0xFF]"] 51 -> 59 [label="[t]"] 52 -> 13 [label="[0x00-q][s-0xFF]"] @@ -327,10 +327,10 @@ digraph re2c { 165 -> 166 166 [label="scanner_re2c_default.--emit-dot.re:331"] 167 -> 144 [label="[0x00-0x08][0x0A-0x1F][!-9][;-<][>-z][|-0xFF]"] -167 -> 193 [label="[0x09][ ]"] -167 -> 195 [label="[:]"] -167 -> 196 [label="[=]"] -167 -> 197 [label="[{]"] +167 -> 193 [label="[0x09][ ]"] +167 -> 195 [label="[:]"] +167 -> 196 [label="[=]"] +167 -> 197 [label="[{]"] 168 -> 169 169 [label="scanner_re2c_default.--emit-dot.re:403"] 170 -> 202 @@ -338,8 +338,8 @@ digraph re2c { 172 [label="scanner_re2c_default.--emit-dot.re:397"] 173 -> 174 174 -> 168 [label="[0x00-0x08][0x0A-0x1F][!-+][--/][:-<][?-@][[-^][`][{-0xFF]"] -174 -> 170 [label="[0x09][ ]"] -174 -> 171 [label="[,][=->]"] +174 -> 170 [label="[0x09][ ]"] +174 -> 171 [label="[,][=->]"] 174 -> 173 [label="[0-9][A-Z][_][a-z]"] 175 -> 176 176 -> 175 [label="[0x00-0x09][0x0B-[][^-0xFF]"] @@ -437,7 +437,7 @@ digraph re2c { 229 -> 230 230 -> 144 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] 230 -> 229 [label="[0x09][ ]"] -230 -> 233 [label="[1-9]"] +230 -> 233 [label="[1-9]"] 231 -> 144 [label="[0x00-@][[-^][`][{-0xFF]"] 231 -> 226 [label="[A-Z][_][a-z]"] 232 -> 144 [label="[0x00-@][[-^][`][{-0xFF]"] @@ -538,7 +538,7 @@ digraph re2c { 280 -> 281 281 -> 265 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] 281 -> 280 [label="[0x09][ ]"] -281 -> 282 [label="[1-9]"] +281 -> 282 [label="[1-9]"] 282 -> 283 283 -> 265 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:-0xFF]"] 283 -> 284 [label="[0x09][ ]"] @@ -603,7 +603,7 @@ digraph re2c { 314 -> 315 315 -> 303 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] 315 -> 314 [label="[0x09][ ]"] -315 -> 316 [label="[1-9]"] +315 -> 316 [label="[1-9]"] 316 -> 317 317 -> 303 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:-0xFF]"] 317 -> 318 [label="[0x09][ ]"] diff --git a/re2c/test/tags/bug121_fix_multiple.i--tags--input(custom).c b/re2c/test/tags/bug121_fix_multiple.i--tags--input(custom).c index 6f2d86c9..983f0684 100644 --- a/re2c/test/tags/bug121_fix_multiple.i--tags--input(custom).c +++ b/re2c/test/tags/bug121_fix_multiple.i--tags--input(custom).c @@ -25,7 +25,7 @@ yy4: yych = YYPEEK (); switch (yych) { case 'b': - YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); goto yy5; default: goto yy3; } @@ -50,12 +50,12 @@ yy7: yych = YYPEEK (); switch (yych) { case 'b': - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); goto yy9; default: goto yy8; } yy8: - YYRESTORETAG (yyt1); + YYRESTORETAG (yyt2); { 1 } yy9: YYSKIP (); @@ -66,7 +66,7 @@ yy9: } yy10: YYSKIP (); - YYRESTORETAG (yyt0); + YYRESTORETAG (yyt1); { 0 } } diff --git a/re2c/test/tags/bug121_var_multiple.i--tags--input(custom).c b/re2c/test/tags/bug121_var_multiple.i--tags--input(custom).c index 8a0d2335..e7f61699 100644 --- a/re2c/test/tags/bug121_var_multiple.i--tags--input(custom).c +++ b/re2c/test/tags/bug121_var_multiple.i--tags--input(custom).c @@ -16,13 +16,13 @@ yy2: { d } yy4: YYSKIP (); - YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); switch ((yych = YYPEEK ())) { case 'b': goto yy6; default: goto yy5; } yy5: - YYRESTORETAG (yyt1); + YYRESTORETAG (yyt2); { 1 } yy6: YYSKIP (); @@ -30,7 +30,7 @@ yy6: yych = YYPEEK (); switch (yych) { case 'c': - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); goto yy9; default: goto yy8; } @@ -62,7 +62,7 @@ yy11: default: goto yy13; } yy13: - YYRESTORETAG (yyt0); + YYRESTORETAG (yyt1); { 0 } } diff --git a/re2c/test/tags/bug121_var_multiple.i--tags.c b/re2c/test/tags/bug121_var_multiple.i--tags.c index 5309365a..96f2a840 100644 --- a/re2c/test/tags/bug121_var_multiple.i--tags.c +++ b/re2c/test/tags/bug121_var_multiple.i--tags.c @@ -16,19 +16,19 @@ yy2: { d } yy4: ++YYCURSOR; - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; switch ((yych = *YYCURSOR)) { case 'b': goto yy6; default: goto yy5; } yy5: - YYCURSOR = yyt1; + YYCURSOR = yyt2; { 1 } yy6: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'c': - yyt0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy9; default: goto yy8; } @@ -59,7 +59,7 @@ yy11: default: goto yy13; } yy13: - YYCURSOR = yyt0; + YYCURSOR = yyt1; { 0 } } diff --git a/re2c/test/tags/conf1.i--tags--input(custom).c b/re2c/test/tags/conf1.i--tags--input(custom).c index 933e7cc5..e89fd8c2 100644 --- a/re2c/test/tags/conf1.i--tags--input(custom).c +++ b/re2c/test/tags/conf1.i--tags--input(custom).c @@ -21,7 +21,7 @@ static void lex(const char *s) #define ZZRT(t) s = t #define ZZCT(t1, t2) t1 = t2 const char *marker, *p0, *p1, *p2, *p3; - const char *zz_0p0;const char *zz_0p1;const char *zz_0p2;const char *zz_0p3; + const char *zz_1;const char *zz_2;const char *zz_3;const char *zz_4; { char yych; @@ -37,7 +37,7 @@ static void lex(const char *s) case '7': case '8': case '9': - ZZBT (zz_0p0); + ZZBT (zz_4); goto yy4; default: goto yy2; } @@ -51,7 +51,7 @@ yy4: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p1); + ZZBT (zz_3); goto yy5; case '0': case '1': @@ -89,7 +89,7 @@ yy7: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p1); + ZZBT (zz_3); goto yy5; case '0': case '1': @@ -108,7 +108,7 @@ yy8: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p2); + ZZBT (zz_2); goto yy10; case '0': case '1': @@ -127,7 +127,7 @@ yy9: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p1); + ZZBT (zz_3); goto yy5; default: goto yy6; } @@ -152,7 +152,7 @@ yy11: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p2); + ZZBT (zz_2); goto yy10; case '0': case '1': @@ -171,7 +171,7 @@ yy12: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p3); + ZZBT (zz_1); goto yy14; case '0': case '1': @@ -190,7 +190,7 @@ yy13: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p2); + ZZBT (zz_2); goto yy10; default: goto yy6; } @@ -215,7 +215,7 @@ yy15: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p3); + ZZBT (zz_1); goto yy14; case '0': case '1': @@ -245,10 +245,10 @@ yy16: default: goto yy17; } yy17: - ZZCT (p3, zz_0p3); - ZZCT (p2, zz_0p2); - ZZCT (p1, zz_0p1); - ZZCT (p0, zz_0p0); + ZZCT (p3, zz_1); + ZZCT (p2, zz_2); + ZZCT (p1, zz_3); + ZZCT (p0, zz_4); { printf("%u.%u.%u.%u\n", parse_oct(p0, p1), @@ -262,7 +262,7 @@ yy18: yych = YYPEEK (); switch (yych) { case '.': - ZZBT (zz_0p3); + ZZBT (zz_1); goto yy14; default: goto yy6; } diff --git a/re2c/test/tags/conf1.i--tags.c b/re2c/test/tags/conf1.i--tags.c index 48df0941..db32fc86 100644 --- a/re2c/test/tags/conf1.i--tags.c +++ b/re2c/test/tags/conf1.i--tags.c @@ -14,7 +14,7 @@ static inline unsigned parse_oct(const char *s, const char *e) static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3; - const char *zz_0p0;const char *zz_0p1;const char *zz_0p2;const char *zz_0p3; + const char *zz_1;const char *zz_2;const char *zz_3;const char *zz_4; { char yych; @@ -30,7 +30,7 @@ static void lex(const char *YYCURSOR) case '7': case '8': case '9': - zz_0p0 = YYCURSOR; + zz_4 = YYCURSOR; goto yy4; default: goto yy2; } @@ -42,7 +42,7 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '.': - zz_0p1 = YYCURSOR; + zz_3 = YYCURSOR; goto yy5; case '0': case '1': @@ -78,7 +78,7 @@ yy7: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p1 = YYCURSOR; + zz_3 = YYCURSOR; goto yy5; case '0': case '1': @@ -96,7 +96,7 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p2 = YYCURSOR; + zz_2 = YYCURSOR; goto yy10; case '0': case '1': @@ -114,7 +114,7 @@ yy9: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p1 = YYCURSOR; + zz_3 = YYCURSOR; goto yy5; default: goto yy6; } @@ -137,7 +137,7 @@ yy11: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p2 = YYCURSOR; + zz_2 = YYCURSOR; goto yy10; case '0': case '1': @@ -155,7 +155,7 @@ yy12: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p3 = YYCURSOR; + zz_1 = YYCURSOR; goto yy14; case '0': case '1': @@ -173,7 +173,7 @@ yy13: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p2 = YYCURSOR; + zz_2 = YYCURSOR; goto yy10; default: goto yy6; } @@ -196,7 +196,7 @@ yy15: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p3 = YYCURSOR; + zz_1 = YYCURSOR; goto yy14; case '0': case '1': @@ -226,10 +226,10 @@ yy16: default: goto yy17; } yy17: - p3 = zz_0p3; - p2 = zz_0p2; - p1 = zz_0p1; - p0 = zz_0p0; + p3 = zz_1; + p2 = zz_2; + p1 = zz_3; + p0 = zz_4; { printf("%u.%u.%u.%u\n", parse_oct(p0, p1), @@ -242,7 +242,7 @@ yy18: yych = *++YYCURSOR; switch (yych) { case '.': - zz_0p3 = YYCURSOR; + zz_1 = YYCURSOR; goto yy14; default: goto yy6; } diff --git a/re2c/test/tags/conf2.i--tags--input(custom).c b/re2c/test/tags/conf2.i--tags--input(custom).c index dd33a2f2..a0e383f8 100644 --- a/re2c/test/tags/conf2.i--tags--input(custom).c +++ b/re2c/test/tags/conf2.i--tags--input(custom).c @@ -23,7 +23,7 @@ struct input_t { char *cur; char *mar; char *tok; - char *yyt1p1;char *yyt1p2;char *yyt1p3; + char *yyt1;char *yyt2;char *yyt3; bool eof; input_t() @@ -32,7 +32,7 @@ struct input_t { , cur(lim) , mar(lim) , tok(lim) - , yyt1p1(0), yyt1p2(0), yyt1p3(0) + , yyt1(0), yyt2(0), yyt3(0) , eof(false) {} bool fill(size_t need) @@ -51,7 +51,7 @@ struct input_t { cur -= free; mar -= free; tok -= free; - yyt1p1 -= free;yyt1p2 -= free;yyt1p3 -= free; + yyt1 -= free;yyt2 -= free;yyt3 -= free; lim += fread(lim, 1, free, stdin); if (lim < buf + SIZE) { eof = true; @@ -107,7 +107,7 @@ yy6: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p1); + YYBACKUPTAG (in.yyt3); goto yy7; case '0': case '1': @@ -145,7 +145,7 @@ yy9: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p1); + YYBACKUPTAG (in.yyt3); goto yy7; case '0': case '1': @@ -164,7 +164,7 @@ yy10: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p2); + YYBACKUPTAG (in.yyt2); goto yy12; case '0': case '1': @@ -183,7 +183,7 @@ yy11: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p1); + YYBACKUPTAG (in.yyt3); goto yy7; default: goto yy8; } @@ -208,7 +208,7 @@ yy13: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p2); + YYBACKUPTAG (in.yyt2); goto yy12; case '0': case '1': @@ -227,7 +227,7 @@ yy14: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p3); + YYBACKUPTAG (in.yyt1); goto yy16; case '0': case '1': @@ -246,7 +246,7 @@ yy15: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p2); + YYBACKUPTAG (in.yyt2); goto yy12; default: goto yy8; } @@ -271,7 +271,7 @@ yy17: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p3); + YYBACKUPTAG (in.yyt1); goto yy16; case '0': case '1': @@ -307,15 +307,15 @@ yy19: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (in.yyt1p3); + YYBACKUPTAG (in.yyt1); goto yy16; default: goto yy8; } yy20: YYSKIP (); - YYCOPYTAG (p3, in.yyt1p3); - YYCOPYTAG (p2, in.yyt1p2); - YYCOPYTAG (p1, in.yyt1p1); + YYCOPYTAG (p3, in.yyt1); + YYCOPYTAG (p2, in.yyt2); + YYCOPYTAG (p1, in.yyt3); { printf("> %u.%u.%u.%u\n", parse_oct(in.tok, p1), diff --git a/re2c/test/tags/conf2.i--tags.c b/re2c/test/tags/conf2.i--tags.c index 4f8d199b..c00484e6 100644 --- a/re2c/test/tags/conf2.i--tags.c +++ b/re2c/test/tags/conf2.i--tags.c @@ -23,7 +23,7 @@ struct input_t { char *cur; char *mar; char *tok; - char *yyt1p1;char *yyt1p2;char *yyt1p3; + char *yyt1;char *yyt2;char *yyt3; bool eof; input_t() @@ -32,7 +32,7 @@ struct input_t { , cur(lim) , mar(lim) , tok(lim) - , yyt1p1(0), yyt1p2(0), yyt1p3(0) + , yyt1(0), yyt2(0), yyt3(0) , eof(false) {} bool fill(size_t need) @@ -51,7 +51,7 @@ struct input_t { cur -= free; mar -= free; tok -= free; - yyt1p1 -= free;yyt1p2 -= free;yyt1p3 -= free; + yyt1 -= free;yyt2 -= free;yyt3 -= free; lim += fread(lim, 1, free, stdin); if (lim < buf + SIZE) { eof = true; @@ -97,7 +97,7 @@ yy6: yych = *(in.mar = ++in.cur); switch (yych) { case '.': - in.yyt1p1 = in.cur; + in.yyt3 = in.cur; goto yy7; case '0': case '1': @@ -133,7 +133,7 @@ yy9: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p1 = in.cur; + in.yyt3 = in.cur; goto yy7; case '0': case '1': @@ -151,7 +151,7 @@ yy10: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p2 = in.cur; + in.yyt2 = in.cur; goto yy12; case '0': case '1': @@ -169,7 +169,7 @@ yy11: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p1 = in.cur; + in.yyt3 = in.cur; goto yy7; default: goto yy8; } @@ -192,7 +192,7 @@ yy13: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p2 = in.cur; + in.yyt2 = in.cur; goto yy12; case '0': case '1': @@ -210,7 +210,7 @@ yy14: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p3 = in.cur; + in.yyt1 = in.cur; goto yy16; case '0': case '1': @@ -228,7 +228,7 @@ yy15: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p2 = in.cur; + in.yyt2 = in.cur; goto yy12; default: goto yy8; } @@ -251,7 +251,7 @@ yy17: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p3 = in.cur; + in.yyt1 = in.cur; goto yy16; case '0': case '1': @@ -285,15 +285,15 @@ yy19: yych = *++in.cur; switch (yych) { case '.': - in.yyt1p3 = in.cur; + in.yyt1 = in.cur; goto yy16; default: goto yy8; } yy20: ++in.cur; - p3 = in.yyt1p3; - p2 = in.yyt1p2; - p1 = in.yyt1p1; + p3 = in.yyt1; + p2 = in.yyt2; + p1 = in.yyt3; { printf("> %u.%u.%u.%u\n", parse_oct(in.tok, p1), diff --git a/re2c/test/tags/conf3.i--tags--input(custom).c b/re2c/test/tags/conf3.i--tags--input(custom).c index f017f3bf..68fc4862 100644 --- a/re2c/test/tags/conf3.i--tags--input(custom).c +++ b/re2c/test/tags/conf3.i--tags--input(custom).c @@ -13,11 +13,11 @@ static inline unsigned parse_oct(const char *s, const char *e) struct tags_t { - const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4; tags_t(); - void push(const char *arg_yyt0p0,const char *arg_yyt0p1,const char *arg_yyt0p2,const char *arg_yyt0p3); - void pop(const char *&arg_yyt0p0,const char *&arg_yyt0p1,const char *&arg_yyt0p2,const char *&arg_yyt0p3); + void push(const char *arg_yyt1,const char *arg_yyt2,const char *arg_yyt3,const char *arg_yyt4); + void pop(const char *&arg_yyt1,const char *&arg_yyt2,const char *&arg_yyt3,const char *&arg_yyt4); }; static void lex(const char *s) @@ -46,7 +46,7 @@ static void lex(const char *s) case '7': case '8': case '9': - YYBACKUPTAG (tags.yyt0p0); + YYBACKUPTAG (tags.yyt4); goto yy4; default: goto yy2; } @@ -60,7 +60,7 @@ yy4: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p1); + YYBACKUPTAG (tags.yyt3); goto yy5; case '0': case '1': @@ -98,7 +98,7 @@ yy7: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p1); + YYBACKUPTAG (tags.yyt3); goto yy5; case '0': case '1': @@ -117,7 +117,7 @@ yy8: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p2); + YYBACKUPTAG (tags.yyt2); goto yy10; case '0': case '1': @@ -136,7 +136,7 @@ yy9: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p1); + YYBACKUPTAG (tags.yyt3); goto yy5; default: goto yy6; } @@ -161,7 +161,7 @@ yy11: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p2); + YYBACKUPTAG (tags.yyt2); goto yy10; case '0': case '1': @@ -180,7 +180,7 @@ yy12: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p3); + YYBACKUPTAG (tags.yyt1); goto yy14; case '0': case '1': @@ -199,7 +199,7 @@ yy13: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p2); + YYBACKUPTAG (tags.yyt2); goto yy10; default: goto yy6; } @@ -224,7 +224,7 @@ yy15: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p3); + YYBACKUPTAG (tags.yyt1); goto yy14; case '0': case '1': @@ -254,10 +254,10 @@ yy16: default: goto yy17; } yy17: - YYCOPYTAG (p3, tags.yyt0p3); - YYCOPYTAG (p2, tags.yyt0p2); - YYCOPYTAG (p1, tags.yyt0p1); - YYCOPYTAG (p0, tags.yyt0p0); + YYCOPYTAG (p3, tags.yyt1); + YYCOPYTAG (p2, tags.yyt2); + YYCOPYTAG (p1, tags.yyt3); + YYCOPYTAG (p0, tags.yyt4); { printf("%u.%u.%u.%u\n", parse_oct(p0, p1), @@ -271,7 +271,7 @@ yy18: yych = YYPEEK (); switch (yych) { case '.': - YYBACKUPTAG (tags.yyt0p3); + YYBACKUPTAG (tags.yyt1); goto yy14; default: goto yy6; } @@ -299,16 +299,16 @@ yy20: } -tags_t::tags_t(): yyt0p0(0),yyt0p1(0),yyt0p2(0),yyt0p3(0) {} +tags_t::tags_t(): yyt1(0),yyt2(0),yyt3(0),yyt4(0) {} -void tags_t::push(const char *arg_yyt0p0,const char *arg_yyt0p1,const char *arg_yyt0p2,const char *arg_yyt0p3) +void tags_t::push(const char *arg_yyt1,const char *arg_yyt2,const char *arg_yyt3,const char *arg_yyt4) { - yyt0p0 = arg_yyt0p0;yyt0p1 = arg_yyt0p1;yyt0p2 = arg_yyt0p2;yyt0p3 = arg_yyt0p3; + yyt1 = arg_yyt1;yyt2 = arg_yyt2;yyt3 = arg_yyt3;yyt4 = arg_yyt4; } -void tags_t::pop(const char *&arg_yyt0p0,const char *&arg_yyt0p1,const char *&arg_yyt0p2,const char *&arg_yyt0p3) +void tags_t::pop(const char *&arg_yyt1,const char *&arg_yyt2,const char *&arg_yyt3,const char *&arg_yyt4) { - arg_yyt0p0 = yyt0p0;arg_yyt0p1 = yyt0p1;arg_yyt0p2 = yyt0p2;arg_yyt0p3 = yyt0p3; + arg_yyt1 = yyt1;arg_yyt2 = yyt2;arg_yyt3 = yyt3;arg_yyt4 = yyt4; } int main(int argc, char **argv) diff --git a/re2c/test/tags/conf3.i--tags.c b/re2c/test/tags/conf3.i--tags.c index 46a5d645..a9850e5f 100644 --- a/re2c/test/tags/conf3.i--tags.c +++ b/re2c/test/tags/conf3.i--tags.c @@ -13,11 +13,11 @@ static inline unsigned parse_oct(const char *s, const char *e) struct tags_t { - const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4; tags_t(); - void push(const char *arg_yyt0p0,const char *arg_yyt0p1,const char *arg_yyt0p2,const char *arg_yyt0p3); - void pop(const char *&arg_yyt0p0,const char *&arg_yyt0p1,const char *&arg_yyt0p2,const char *&arg_yyt0p3); + void push(const char *arg_yyt1,const char *arg_yyt2,const char *arg_yyt3,const char *arg_yyt4); + void pop(const char *&arg_yyt1,const char *&arg_yyt2,const char *&arg_yyt3,const char *&arg_yyt4); }; static void lex(const char *YYCURSOR) @@ -39,7 +39,7 @@ static void lex(const char *YYCURSOR) case '7': case '8': case '9': - tags.yyt0p0 = YYCURSOR; + tags.yyt4 = YYCURSOR; goto yy4; default: goto yy2; } @@ -51,7 +51,7 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '.': - tags.yyt0p1 = YYCURSOR; + tags.yyt3 = YYCURSOR; goto yy5; case '0': case '1': @@ -87,7 +87,7 @@ yy7: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p1 = YYCURSOR; + tags.yyt3 = YYCURSOR; goto yy5; case '0': case '1': @@ -105,7 +105,7 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p2 = YYCURSOR; + tags.yyt2 = YYCURSOR; goto yy10; case '0': case '1': @@ -123,7 +123,7 @@ yy9: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p1 = YYCURSOR; + tags.yyt3 = YYCURSOR; goto yy5; default: goto yy6; } @@ -146,7 +146,7 @@ yy11: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p2 = YYCURSOR; + tags.yyt2 = YYCURSOR; goto yy10; case '0': case '1': @@ -164,7 +164,7 @@ yy12: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p3 = YYCURSOR; + tags.yyt1 = YYCURSOR; goto yy14; case '0': case '1': @@ -182,7 +182,7 @@ yy13: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p2 = YYCURSOR; + tags.yyt2 = YYCURSOR; goto yy10; default: goto yy6; } @@ -205,7 +205,7 @@ yy15: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p3 = YYCURSOR; + tags.yyt1 = YYCURSOR; goto yy14; case '0': case '1': @@ -235,10 +235,10 @@ yy16: default: goto yy17; } yy17: - p3 = tags.yyt0p3; - p2 = tags.yyt0p2; - p1 = tags.yyt0p1; - p0 = tags.yyt0p0; + p3 = tags.yyt1; + p2 = tags.yyt2; + p1 = tags.yyt3; + p0 = tags.yyt4; { printf("%u.%u.%u.%u\n", parse_oct(p0, p1), @@ -251,7 +251,7 @@ yy18: yych = *++YYCURSOR; switch (yych) { case '.': - tags.yyt0p3 = YYCURSOR; + tags.yyt1 = YYCURSOR; goto yy14; default: goto yy6; } @@ -278,16 +278,16 @@ yy20: } -tags_t::tags_t(): yyt0p0(0),yyt0p1(0),yyt0p2(0),yyt0p3(0) {} +tags_t::tags_t(): yyt1(0),yyt2(0),yyt3(0),yyt4(0) {} -void tags_t::push(const char *arg_yyt0p0,const char *arg_yyt0p1,const char *arg_yyt0p2,const char *arg_yyt0p3) +void tags_t::push(const char *arg_yyt1,const char *arg_yyt2,const char *arg_yyt3,const char *arg_yyt4) { - yyt0p0 = arg_yyt0p0;yyt0p1 = arg_yyt0p1;yyt0p2 = arg_yyt0p2;yyt0p3 = arg_yyt0p3; + yyt1 = arg_yyt1;yyt2 = arg_yyt2;yyt3 = arg_yyt3;yyt4 = arg_yyt4; } -void tags_t::pop(const char *&arg_yyt0p0,const char *&arg_yyt0p1,const char *&arg_yyt0p2,const char *&arg_yyt0p3) +void tags_t::pop(const char *&arg_yyt1,const char *&arg_yyt2,const char *&arg_yyt3,const char *&arg_yyt4) { - arg_yyt0p0 = yyt0p0;arg_yyt0p1 = yyt0p1;arg_yyt0p2 = yyt0p2;arg_yyt0p3 = yyt0p3; + arg_yyt1 = yyt1;arg_yyt2 = yyt2;arg_yyt3 = yyt3;arg_yyt4 = yyt4; } int main(int argc, char **argv) diff --git a/re2c/test/tags/dedup4.i--tags.c b/re2c/test/tags/dedup4.i--tags.c index f48d2e4a..782c5b62 100644 --- a/re2c/test/tags/dedup4.i--tags.c +++ b/re2c/test/tags/dedup4.i--tags.c @@ -13,23 +13,16 @@ yy2: {} yy4: ++YYCURSOR; + yyt1 = yyt2 = YYCURSOR; switch ((yych = *YYCURSOR)) { - case 'b': - yyt0p = YYCURSOR; - goto yy6; - case 'c': - yyt0 = yyt0p = YYCURSOR; - goto yy8; - case 'd': - yyt0 = yyt0p = YYCURSOR; - goto yy11; - default: - yyt0 = yyt0p = YYCURSOR; - goto yy5; + case 'b': goto yy6; + case 'c': goto yy8; + case 'd': goto yy11; + default: goto yy5; } yy5: - YYCURSOR = yyt0; - p = yyt0p; + YYCURSOR = yyt2; + p = yyt1; { 1 p } yy6: ++YYCURSOR; @@ -38,13 +31,13 @@ yy6: switch (yych) { case 'b': goto yy6; case 'c': - yyt0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; case 'd': - yyt0 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; default: - yyt0 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; } yy8: @@ -56,8 +49,8 @@ yy8: default: goto yy10; } yy10: - YYCURSOR = yyt0; - p = yyt0p; + YYCURSOR = yyt1; + p = yyt2; { 2 p } yy11: ++YYCURSOR; @@ -86,17 +79,17 @@ yy17: ++YYCURSOR; switch ((yych = *YYCURSOR)) { case 'b': - yyt0p = yyt1p = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy19; case 'c': - yyt0p = yyt1p = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy21; default: - yyt0p = YYCURSOR; + yyt2 = YYCURSOR; goto yy18; } yy18: - p = yyt0p; + p = yyt2; { 1 p } yy19: ++YYCURSOR; @@ -105,7 +98,7 @@ yy19: switch (yych) { case 'b': goto yy19; case 'c': - yyt0p = YYCURSOR; + yyt2 = YYCURSOR; goto yy21; default: goto yy18; } @@ -118,8 +111,8 @@ yy21: default: goto yy23; } yy23: - YYCURSOR = yyt0p; - p = yyt1p; + YYCURSOR = yyt2; + p = yyt1; { 2 p } } @@ -142,17 +135,17 @@ yy28: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'b': - yyt0p = YYCURSOR; + yyt2 = YYCURSOR; goto yy30; case 'c': - yyt0p = yyt1 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy32; default: - yyt0p = YYCURSOR; + yyt2 = YYCURSOR; goto yy29; } yy29: - p = yyt0p; + p = yyt2; { 1 p } yy30: yyaccept = 1; @@ -178,7 +171,7 @@ yy33: YYCURSOR = YYMARKER; switch (yyaccept) { case 0: - yyt0p = YYCURSOR; + yyt2 = YYCURSOR; goto yy29; case 1: goto yy29; default: goto yy35; @@ -194,7 +187,7 @@ yy34: } yy35: YYCURSOR = yyt1; - p = yyt0p; + p = yyt2; { 2 p } } @@ -217,7 +210,7 @@ yy40: yych = *++YYCURSOR; switch (yych) { case 'b': - yyt0p = YYCURSOR; + yyt2 = YYCURSOR; goto yy41; default: goto yy39; } @@ -234,7 +227,7 @@ yy41: default: goto yy43; } yy43: - p = yyt0p; + p = yyt2; { 1 p } yy44: ++YYCURSOR; @@ -262,7 +255,7 @@ yy46: } yy47: YYCURSOR = yyt1; - p = yyt0p; + p = yyt2; { 2 p } } diff --git a/re2c/test/tags/dedup5.i--tags.c b/re2c/test/tags/dedup5.i--tags.c index fc0be967..b83811d6 100644 --- a/re2c/test/tags/dedup5.i--tags.c +++ b/re2c/test/tags/dedup5.i--tags.c @@ -13,7 +13,7 @@ yych = *YYCURSOR; switch (yych) { case 'a': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy4; case 'b': goto yy5; default: goto yy2; @@ -30,7 +30,7 @@ yy4: } yy5: ++YYCURSOR; - p = yyt0p; + p = yyt1; { p } yy7: ++YYCURSOR; @@ -38,7 +38,7 @@ yy7: yych = *YYCURSOR; switch (yych) { case 'a': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy9; case 'b': goto yy5; default: goto yy8; @@ -65,7 +65,7 @@ yy9: switch (yych) { case 'a': goto yy14; case 'b': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy16; default: goto yy12; } @@ -75,7 +75,7 @@ yy13: {} yy14: ++YYCURSOR; - p = yyt0p; + p = yyt1; { p } yy16: yych = *(YYMARKER = ++YYCURSOR); @@ -90,7 +90,7 @@ yy17: switch (yych) { case 'a': goto yy14; case 'b': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy19; default: goto yy18; } diff --git a/re2c/test/tags/fallback1.i--tags.c b/re2c/test/tags/fallback1.i--tags.c index ebe77acd..e9deac55 100644 --- a/re2c/test/tags/fallback1.i--tags.c +++ b/re2c/test/tags/fallback1.i--tags.c @@ -17,13 +17,13 @@ unsigned int yyaccept = 0; if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); yych = *YYCURSOR; - yyt1p = YYCURSOR; + yyt1 = YYCURSOR; switch (yych) { case 'a': goto yy3; default: goto yy2; } yy2: - p = yyt1p; + p = yyt1; { 3 p } yy3: yyaccept = 0; @@ -36,7 +36,7 @@ yy4: yych = *++YYCURSOR; switch (yych) { case 'a': - yyt1p = YYCURSOR; + yyt1 = YYCURSOR; goto yy6; default: goto yy5; } @@ -56,7 +56,7 @@ yy6: default: goto yy7; } yy7: - p = yyt1p; + p = yyt1; { 2 p } yy8: yych = *++YYCURSOR; diff --git a/re2c/test/tags/fallback2.i--tags.c b/re2c/test/tags/fallback2.i--tags.c index 206aacb0..3d75dbab 100644 --- a/re2c/test/tags/fallback2.i--tags.c +++ b/re2c/test/tags/fallback2.i--tags.c @@ -24,7 +24,7 @@ default: goto yy2; } yy2: - p = yyt0p; + p = yyt1; { p } yy3: ++YYCURSOR; @@ -39,7 +39,7 @@ yy4: if (yyaccept == 0) { goto yy2; } else { - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy2; } yy5: @@ -50,7 +50,7 @@ yy5: switch (yych) { case 'a': goto yy3; default: - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy2; } } diff --git a/re2c/test/tags/fallback3.i--tags.c b/re2c/test/tags/fallback3.i--tags.c index bf2f3b7e..8bf0b681 100644 --- a/re2c/test/tags/fallback3.i--tags.c +++ b/re2c/test/tags/fallback3.i--tags.c @@ -23,7 +23,7 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case 'b': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; default: goto yy3; } @@ -40,7 +40,7 @@ yy6: if (yyaccept == 0) { goto yy3; } else { - yyt0p = yyt0p_; + yyt1 = yyt1_; goto yy8; } yy7: @@ -50,12 +50,12 @@ yy7: yych = *YYCURSOR; switch (yych) { case 'a': - yyt0p_ = yyt0p; + yyt1_ = yyt1; goto yy9; default: goto yy8; } yy8: - p = yyt0p; + p = yyt1; { p } yy9: ++YYCURSOR; @@ -63,7 +63,7 @@ yy9: yych = *YYCURSOR; switch (yych) { case 'b': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; default: goto yy6; } diff --git a/re2c/test/tags/fix2_trail.i--tags--input(custom).c b/re2c/test/tags/fix2_trail.i--tags--input(custom).c index 0271822e..2d472b04 100644 --- a/re2c/test/tags/fix2_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix2_trail.i--tags--input(custom).c @@ -12,14 +12,14 @@ static void lex(const char *s) #define YYRESTORETAG(t) s = t #define YYCOPYTAG(t1, t2) t1 = t2 const char *marker, *p0, *p1, *p2, *p3; - const char *yyt0;const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5; { char yych; yych = YYPEEK (); switch (yych) { case '0': - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt5); goto yy4; default: goto yy2; } @@ -33,7 +33,7 @@ yy4: yych = YYPEEK (); switch (yych) { case '1': - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt4); goto yy5; default: goto yy3; } @@ -52,7 +52,7 @@ yy7: yych = YYPEEK (); switch (yych) { case '2': - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt3); goto yy8; default: goto yy6; } @@ -75,7 +75,7 @@ yy10: yych = YYPEEK (); switch (yych) { case '3': - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt2); goto yy11; default: goto yy6; } @@ -105,7 +105,7 @@ yy14: yych = YYPEEK (); switch (yych) { case '4': - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); goto yy15; default: goto yy6; } @@ -139,11 +139,11 @@ yy18: } yy19: YYSKIP (); - YYRESTORETAG (yyt0); - YYCOPYTAG (p3, yyt0p3); - YYCOPYTAG (p2, yyt0p2); - YYCOPYTAG (p1, yyt0p1); - YYCOPYTAG (p0, yyt0p0); + YYRESTORETAG (yyt1); + YYCOPYTAG (p3, yyt2); + YYCOPYTAG (p2, yyt3); + YYCOPYTAG (p1, yyt4); + YYCOPYTAG (p0, yyt5); { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix3.i--tags.c b/re2c/test/tags/fix3.i--tags.c index 42ca5961..546e4a20 100644 --- a/re2c/test/tags/fix3.i--tags.c +++ b/re2c/test/tags/fix3.i--tags.c @@ -5,35 +5,35 @@ static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3, *p4; - const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3;const char *yyt0p4; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5; { char yych; yych = *YYCURSOR; switch (yych) { case '0': - yyt0p0 = YYCURSOR; + yyt5 = YYCURSOR; goto yy5; case '1': - yyt0p1 = yyt0p0 = YYCURSOR; + yyt4 = yyt5 = YYCURSOR; goto yy7; case '2': - yyt0p2 = yyt0p1 = yyt0p0 = YYCURSOR; + yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy9; case '3': - yyt0p3 = yyt0p2 = yyt0p1 = yyt0p0 = YYCURSOR; + yyt2 = yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy11; case '4': - yyt0p4 = yyt0p3 = yyt0p2 = yyt0p1 = yyt0p0 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy13; default: goto yy3; } yy2: - p4 = yyt0p4; - p3 = yyt0p3; - p2 = yyt0p2; - p1 = yyt0p1; - p0 = yyt0p0; + p4 = yyt1; + p3 = yyt2; + p2 = yyt3; + p1 = yyt4; + p0 = yyt5; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%.*s'\n", p1 - p0, p0, @@ -52,19 +52,19 @@ yy5: switch (yych) { case '0': goto yy5; case '1': - yyt0p1 = YYCURSOR; + yyt4 = YYCURSOR; goto yy7; case '2': - yyt0p2 = yyt0p1 = YYCURSOR; + yyt3 = yyt4 = YYCURSOR; goto yy9; case '3': - yyt0p3 = yyt0p2 = yyt0p1 = YYCURSOR; + yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy11; case '4': - yyt0p4 = yyt0p3 = yyt0p2 = yyt0p1 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy13; default: - yyt0p4 = yyt0p3 = yyt0p2 = yyt0p1 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy2; } yy7: @@ -73,16 +73,16 @@ yy7: switch (yych) { case '1': goto yy7; case '2': - yyt0p2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy9; case '3': - yyt0p3 = yyt0p2 = YYCURSOR; + yyt2 = yyt3 = YYCURSOR; goto yy11; case '4': - yyt0p4 = yyt0p3 = yyt0p2 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy13; default: - yyt0p4 = yyt0p3 = yyt0p2 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy2; } yy9: @@ -91,13 +91,13 @@ yy9: switch (yych) { case '2': goto yy9; case '3': - yyt0p3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; case '4': - yyt0p4 = yyt0p3 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy13; default: - yyt0p4 = yyt0p3 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy2; } yy11: @@ -106,10 +106,10 @@ yy11: switch (yych) { case '3': goto yy11; case '4': - yyt0p4 = YYCURSOR; + yyt1 = YYCURSOR; goto yy13; default: - yyt0p4 = YYCURSOR; + yyt1 = YYCURSOR; goto yy2; } yy13: diff --git a/re2c/test/tags/fix3_trail.i--tags--input(custom).c b/re2c/test/tags/fix3_trail.i--tags--input(custom).c index ffcae56a..2ac59b15 100644 --- a/re2c/test/tags/fix3_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix3_trail.i--tags--input(custom).c @@ -12,45 +12,45 @@ static void lex(const char *s) #define YYRESTORETAG(t) s = t #define YYCOPYTAG(t1, t2) t1 = t2 const char *marker, *p0, *p1, *p2, *p3; - const char *yyt0;const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5; { char yych; yych = YYPEEK (); switch (yych) { case '0': - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt5); goto yy5; case '1': - YYBACKUPTAG (yyt0p1); - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy7; case '2': - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy9; case '3': - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy11; case '4': - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy13; default: goto yy3; } yy2: - YYRESTORETAG (yyt0); - YYCOPYTAG (p3, yyt0p3); - YYCOPYTAG (p2, yyt0p2); - YYCOPYTAG (p1, yyt0p1); - YYCOPYTAG (p0, yyt0p0); + YYRESTORETAG (yyt1); + YYCOPYTAG (p3, yyt2); + YYCOPYTAG (p2, yyt3); + YYCOPYTAG (p1, yyt4); + YYCOPYTAG (p0, yyt5); { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, @@ -69,28 +69,28 @@ yy5: switch (yych) { case '0': goto yy5; case '1': - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt4); goto yy7; case '2': - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); goto yy9; case '3': - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); goto yy11; case '4': - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); goto yy13; default: - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); goto yy2; } yy7: @@ -99,21 +99,21 @@ yy7: switch (yych) { case '1': goto yy7; case '2': - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt3); goto yy9; case '3': - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy11; case '4': - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy13; default: - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy2; } yy9: @@ -122,15 +122,15 @@ yy9: switch (yych) { case '2': goto yy9; case '3': - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt2); goto yy11; case '4': - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); goto yy13; default: - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); goto yy2; } yy11: @@ -139,10 +139,10 @@ yy11: switch (yych) { case '3': goto yy11; case '4': - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); goto yy13; default: - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); goto yy2; } yy13: diff --git a/re2c/test/tags/fix3_trail.i--tags.c b/re2c/test/tags/fix3_trail.i--tags.c index 60d698eb..8907b387 100644 --- a/re2c/test/tags/fix3_trail.i--tags.c +++ b/re2c/test/tags/fix3_trail.i--tags.c @@ -5,35 +5,35 @@ static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3; - const char *yyt0;const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5; { char yych; yych = *YYCURSOR; switch (yych) { case '0': - yyt0p0 = YYCURSOR; + yyt5 = YYCURSOR; goto yy5; case '1': - yyt0p1 = yyt0p0 = YYCURSOR; + yyt4 = yyt5 = YYCURSOR; goto yy7; case '2': - yyt0p2 = yyt0p1 = yyt0p0 = YYCURSOR; + yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy9; case '3': - yyt0p3 = yyt0p2 = yyt0p1 = yyt0p0 = YYCURSOR; + yyt2 = yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy11; case '4': - yyt0 = yyt0p3 = yyt0p2 = yyt0p1 = yyt0p0 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy13; default: goto yy3; } yy2: - YYCURSOR = yyt0; - p3 = yyt0p3; - p2 = yyt0p2; - p1 = yyt0p1; - p0 = yyt0p0; + YYCURSOR = yyt1; + p3 = yyt2; + p2 = yyt3; + p1 = yyt4; + p0 = yyt5; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, @@ -52,19 +52,19 @@ yy5: switch (yych) { case '0': goto yy5; case '1': - yyt0p1 = YYCURSOR; + yyt4 = YYCURSOR; goto yy7; case '2': - yyt0p2 = yyt0p1 = YYCURSOR; + yyt3 = yyt4 = YYCURSOR; goto yy9; case '3': - yyt0p3 = yyt0p2 = yyt0p1 = YYCURSOR; + yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy11; case '4': - yyt0 = yyt0p3 = yyt0p2 = yyt0p1 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy13; default: - yyt0 = yyt0p3 = yyt0p2 = yyt0p1 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy2; } yy7: @@ -73,16 +73,16 @@ yy7: switch (yych) { case '1': goto yy7; case '2': - yyt0p2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy9; case '3': - yyt0p3 = yyt0p2 = YYCURSOR; + yyt2 = yyt3 = YYCURSOR; goto yy11; case '4': - yyt0 = yyt0p3 = yyt0p2 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy13; default: - yyt0 = yyt0p3 = yyt0p2 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy2; } yy9: @@ -91,13 +91,13 @@ yy9: switch (yych) { case '2': goto yy9; case '3': - yyt0p3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; case '4': - yyt0 = yyt0p3 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy13; default: - yyt0 = yyt0p3 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy2; } yy11: @@ -106,10 +106,10 @@ yy11: switch (yych) { case '3': goto yy11; case '4': - yyt0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy13; default: - yyt0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy2; } yy13: diff --git a/re2c/test/tags/fix4.i--tags.c b/re2c/test/tags/fix4.i--tags.c index c6be7831..116418bb 100644 --- a/re2c/test/tags/fix4.i--tags.c +++ b/re2c/test/tags/fix4.i--tags.c @@ -5,7 +5,7 @@ static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3, *p4; - const char *yyt0p1;const char *yyt0p3; + const char *yyt1;const char *yyt2; { char yych; @@ -22,10 +22,10 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '1': - yyt0p1 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; case '2': - yyt0p1 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; default: goto yy3; } @@ -44,10 +44,10 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '3': - yyt0p3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy9; case '4': - yyt0p3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; default: goto yy7; } @@ -62,10 +62,10 @@ yy9: yy11: ++YYCURSOR; p4 = YYCURSOR - 1; - p3 = yyt0p3; - p2 = yyt0p3 - 1; - p1 = yyt0p1; - p0 = yyt0p1 - 1; + p3 = yyt2; + p2 = yyt2 - 1; + p1 = yyt1; + p0 = yyt1 - 1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%.*s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix4_trail.i--tags--input(custom).c b/re2c/test/tags/fix4_trail.i--tags--input(custom).c index a346017c..c3774770 100644 --- a/re2c/test/tags/fix4_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix4_trail.i--tags--input(custom).c @@ -12,14 +12,14 @@ static void lex(const char *s) #define YYRESTORETAG(t) s = t #define YYCOPYTAG(t1, t2) t1 = t2 const char *marker, *p0, *p1, *p2, *p3; - const char *yyt0;const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5; { char yych; yych = YYPEEK (); switch (yych) { case '0': - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt5); goto yy4; default: goto yy2; } @@ -33,11 +33,11 @@ yy4: yych = YYPEEK (); switch (yych) { case '1': - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt4); goto yy5; case '2': - YYBACKUPTAG (yyt0p2); - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); goto yy8; default: goto yy3; } @@ -47,7 +47,7 @@ yy5: switch (yych) { case '1': goto yy5; case '2': - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt3); goto yy8; default: goto yy7; } @@ -59,11 +59,11 @@ yy8: yych = YYPEEK (); switch (yych) { case '3': - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt2); goto yy9; case '4': - YYBACKUPTAG (yyt0); - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); goto yy11; default: goto yy7; } @@ -73,17 +73,17 @@ yy9: switch (yych) { case '3': goto yy9; case '4': - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); goto yy11; default: goto yy7; } yy11: YYSKIP (); - YYRESTORETAG (yyt0); - YYCOPYTAG (p3, yyt0p3); - YYCOPYTAG (p2, yyt0p2); - YYCOPYTAG (p1, yyt0p1); - YYCOPYTAG (p0, yyt0p0); + YYRESTORETAG (yyt1); + YYCOPYTAG (p3, yyt2); + YYCOPYTAG (p2, yyt3); + YYCOPYTAG (p1, yyt4); + YYCOPYTAG (p0, yyt5); { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix4_trail.i--tags.c b/re2c/test/tags/fix4_trail.i--tags.c index d0750ab9..f1e18825 100644 --- a/re2c/test/tags/fix4_trail.i--tags.c +++ b/re2c/test/tags/fix4_trail.i--tags.c @@ -5,7 +5,7 @@ static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3; - const char *yyt0p1;const char *yyt0p3; + const char *yyt1;const char *yyt2; { char yych; @@ -22,10 +22,10 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '1': - yyt0p1 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; case '2': - yyt0p1 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; default: goto yy3; } @@ -44,10 +44,10 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '3': - yyt0p3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy9; case '4': - yyt0p3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; default: goto yy7; } @@ -62,10 +62,10 @@ yy9: yy11: ++YYCURSOR; YYCURSOR -= 1; - p3 = yyt0p3; - p2 = yyt0p3 - 1; - p1 = yyt0p1; - p0 = yyt0p1 - 1; + p3 = yyt2; + p2 = yyt2 - 1; + p1 = yyt1; + p0 = yyt1 - 1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix5.i--tags.c b/re2c/test/tags/fix5.i--tags.c index 365c334e..f656b625 100644 --- a/re2c/test/tags/fix5.i--tags.c +++ b/re2c/test/tags/fix5.i--tags.c @@ -5,17 +5,17 @@ static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3, *p4; - const char *yyt0p0;const char *yyt0p2;const char *yyt0p4; + const char *yyt1;const char *yyt2;const char *yyt3; { char yych; yych = *YYCURSOR; switch (yych) { case '0': - yyt0p0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy4; case '1': - yyt0p0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; default: goto yy2; } @@ -34,10 +34,10 @@ yy5: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '2': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy3; } @@ -57,10 +57,10 @@ yy9: yych = *++YYCURSOR; switch (yych) { case '2': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy8; } @@ -74,15 +74,15 @@ yy10: } yy12: ++YYCURSOR; - yyt0p4 = YYCURSOR; + yyt3 = YYCURSOR; yych = *YYCURSOR; goto yy15; yy13: - p4 = yyt0p4; - p3 = yyt0p4 - 1; - p2 = yyt0p2; - p1 = yyt0p2 - 1; - p0 = yyt0p0; + p4 = yyt3; + p3 = yyt3 - 1; + p2 = yyt2; + p1 = yyt2 - 1; + p0 = yyt1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%.*s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix5_trail.i--tags--input(custom).c b/re2c/test/tags/fix5_trail.i--tags--input(custom).c index 2a97cc56..744c213e 100644 --- a/re2c/test/tags/fix5_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix5_trail.i--tags--input(custom).c @@ -12,18 +12,18 @@ static void lex(const char *s) #define YYRESTORETAG(t) s = t #define YYCOPYTAG(t1, t2) t1 = t2 const char *marker, *p0, *p1, *p2, *p3; - const char *yyt0;const char *yyt0p0;const char *yyt0p1;const char *yyt0p2;const char *yyt0p3; + const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5; { char yych; yych = YYPEEK (); switch (yych) { case '0': - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt5); goto yy4; case '1': - YYBACKUPTAG (yyt0p1); - YYBACKUPTAG (yyt0p0); + YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy5; default: goto yy2; } @@ -46,11 +46,11 @@ yy5: yych = YYPEEK (); switch (yych) { case '2': - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt3); goto yy10; case '3': - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy12; default: goto yy3; } @@ -61,7 +61,7 @@ yy7: switch (yych) { case '0': goto yy6; case '1': - YYBACKUPTAG (yyt0p1); + YYBACKUPTAG (yyt4); goto yy9; default: goto yy8; } @@ -73,11 +73,11 @@ yy9: yych = YYPEEK (); switch (yych) { case '2': - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt3); goto yy10; case '3': - YYBACKUPTAG (yyt0p3); - YYBACKUPTAG (yyt0p2); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy12; default: goto yy8; } @@ -87,21 +87,21 @@ yy10: switch (yych) { case '2': goto yy10; case '3': - YYBACKUPTAG (yyt0p3); + YYBACKUPTAG (yyt2); goto yy12; default: goto yy8; } yy12: YYSKIP (); - YYBACKUPTAG (yyt0); + YYBACKUPTAG (yyt1); yych = YYPEEK (); goto yy15; yy13: - YYRESTORETAG (yyt0); - YYCOPYTAG (p3, yyt0p3); - YYCOPYTAG (p2, yyt0p2); - YYCOPYTAG (p1, yyt0p1); - YYCOPYTAG (p0, yyt0p0); + YYRESTORETAG (yyt1); + YYCOPYTAG (p3, yyt2); + YYCOPYTAG (p2, yyt3); + YYCOPYTAG (p1, yyt4); + YYCOPYTAG (p0, yyt5); { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/fix5_trail.i--tags.c b/re2c/test/tags/fix5_trail.i--tags.c index 8b90ba03..55ebebe2 100644 --- a/re2c/test/tags/fix5_trail.i--tags.c +++ b/re2c/test/tags/fix5_trail.i--tags.c @@ -5,17 +5,17 @@ static void lex(const char *YYCURSOR) { const char *YYMARKER, *p0, *p1, *p2, *p3; - const char *yyt0;const char *yyt0p0;const char *yyt0p2; + const char *yyt1;const char *yyt2;const char *yyt3; { char yych; yych = *YYCURSOR; switch (yych) { case '0': - yyt0p0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy4; case '1': - yyt0p0 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; default: goto yy2; } @@ -34,10 +34,10 @@ yy5: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '2': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy3; } @@ -57,10 +57,10 @@ yy9: yych = *++YYCURSOR; switch (yych) { case '2': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt0p2 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy8; } @@ -74,15 +74,15 @@ yy10: } yy12: ++YYCURSOR; - yyt0 = YYCURSOR; + yyt3 = YYCURSOR; yych = *YYCURSOR; goto yy15; yy13: - YYCURSOR = yyt0; - p3 = yyt0 - 1; - p2 = yyt0p2; - p1 = yyt0p2 - 1; - p0 = yyt0p0; + YYCURSOR = yyt3; + p3 = yyt3 - 1; + p2 = yyt2; + p1 = yyt2 - 1; + p0 = yyt1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/iter_plus.i--tags.c b/re2c/test/tags/iter_plus.i--tags.c index 3fb4b7ef..1505b65a 100644 --- a/re2c/test/tags/iter_plus.i--tags.c +++ b/re2c/test/tags/iter_plus.i--tags.c @@ -9,7 +9,7 @@ yych = *YYCURSOR; switch (yych) { case 'a': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy4; default: goto yy2; } @@ -22,12 +22,12 @@ yy4: yych = *YYCURSOR; switch (yych) { case 'a': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy4; default: goto yy6; } yy6: - p = yyt0p; + p = yyt1; { p } } diff --git a/re2c/test/tags/minimization.i.c b/re2c/test/tags/minimization.i.c index ea283061..ab875045 100644 --- a/re2c/test/tags/minimization.i.c +++ b/re2c/test/tags/minimization.i.c @@ -47,7 +47,7 @@ yy11: yych = *++YYCURSOR; switch (yych) { case 'a': - yyt0p = YYCURSOR; + yyt1 = YYCURSOR; goto yy13; default: goto yy10; } @@ -59,7 +59,7 @@ yy12: } yy13: ++YYCURSOR; - p = yyt0p; + p = yyt1; { p } }