From 31a8afdf15e3140c9f608f1cc54872efc0dd9e14 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 23 Jan 2017 17:42:37 +0000 Subject: [PATCH] Use the same tag version for all transitions from the given state. This reduces the overall number of versions greatly, which is crucial for the space and time efficiency of tag liveness analysis. Of course, bottom and normal transitions still have different versions. Differents tags on the same transition also have different versions. It is not incorrect to give them the same version: all tags updated by one and the same transition are either set to bottom, or to current input position (which is the same for all tags on the given transition). But this would create many states with a very special "shape" that do not map to other states. In fact, this would cause exponential blowup in the number of states (even in simple cases). --- re2c/src/ir/dfa/closure.cc | 22 ++++-- re2c/src/ir/dfa/closure.h | 3 +- re2c/src/ir/dfa/determinization.cc | 9 ++- re2c/test/tags/fix3.i--tags.c | 36 +++++----- .../tags/fix3_trail.i--tags--input(custom).c | 44 ++++++------ re2c/test/tags/fix3_trail.i--tags.c | 36 +++++----- re2c/test/tags/fix4.i--tags.c | 16 ++--- .../tags/fix4_trail.i--tags--input(custom).c | 16 ++--- re2c/test/tags/fix4_trail.i--tags.c | 16 ++--- re2c/test/tags/fix5.i--tags.c | 18 ++--- .../tags/fix5_trail.i--tags--input(custom).c | 16 ++--- re2c/test/tags/fix5_trail.i--tags.c | 18 ++--- .../mapping1.i--tags--non-bijective-mapping.c | 18 ++--- re2c/test/tags/mapping1.i--tags.c | 18 ++--- re2c/test/tags/topsort2.i--tags.c | 44 ++++++------ re2c/test/tags/twopass.i--tags.c | 70 +++++++++---------- 16 files changed, 209 insertions(+), 191 deletions(-) diff --git a/re2c/src/ir/dfa/closure.cc b/re2c/src/ir/dfa/closure.cc index 52cfa35b..91eb2454 100644 --- a/re2c/src/ir/dfa/closure.cc +++ b/re2c/src/ir/dfa/closure.cc @@ -10,10 +10,11 @@ static void closure_one(closure_t &clos, Tagpool &tagpool, clos_t &c0, nfa_state bool is_better(const clos_t &c1, const clos_t &c2, Tagpool &tagpool); static bool compare_by_rule(const clos_t &c1, const clos_t &c2); static void prune_final_items(closure_t &clos, std::valarray &rules); -static void update_versions(closure_t &clos, Tagpool &tagpool, tagver_t &maxver); +static void update_versions(closure_t &clos, Tagpool &tagpool, tagver_t &maxver, tagver_t *newvers); void closure(closure_t &clos1, closure_t &clos2, Tagpool &tagpool, - std::valarray &rules, tagver_t &maxver, bool lookahead) + std::valarray &rules, tagver_t &maxver, tagver_t *newvers, + bool lookahead) { // build tagged epsilon-closure of the given set of NFA states clos2.clear(); @@ -42,7 +43,7 @@ void closure(closure_t &clos1, closure_t &clos2, Tagpool &tagpool, std::sort(clos2.begin(), clos2.end(), compare_by_rule); // merge tags from different rules, find nondeterministic tags - update_versions(clos2, tagpool, maxver); + update_versions(clos2, tagpool, maxver, newvers); } /* note [epsilon-closures in tagged NFA] @@ -206,7 +207,8 @@ void prune_final_items(closure_t &clos, std::valarray &rules) } } -void update_versions(closure_t &clos, Tagpool &tagpool, tagver_t &maxver) +void update_versions(closure_t &clos, Tagpool &tagpool, + tagver_t &maxver, tagver_t *newvers) { const size_t ntag = tagpool.ntags; tagver_t *cur = tagpool.buffer1, @@ -219,18 +221,26 @@ void update_versions(closure_t &clos, Tagpool &tagpool, tagver_t &maxver) // normal transition, however absolute value should be unique // among all versions of all tags) for (size_t t = 0; t < ntag; ++t) { + tagver_t &newcur = newvers[t], + &newbot = newvers[ntag + t]; cur[t] = bot[t] = TAGVER_ZERO; for (c = b; c != e; ++c) { if (tagpool[c->ttran][t] == TAGVER_CURSOR) { - cur[t] = ++maxver; + if (newcur == TAGVER_ZERO) { + newcur = ++maxver; + } + cur[t] = newcur; break; } } for (c = b; c != e; ++c) { if (tagpool[c->ttran][t] == TAGVER_BOTTOM) { - bot[t] = -(++maxver); + if (newbot == TAGVER_ZERO) { + newbot = -(++maxver); + } + bot[t] = newbot; break; } } diff --git a/re2c/src/ir/dfa/closure.h b/re2c/src/ir/dfa/closure.h index dabbb44a..cb80da08 100644 --- a/re2c/src/ir/dfa/closure.h +++ b/re2c/src/ir/dfa/closure.h @@ -26,7 +26,8 @@ typedef closure_t::iterator clositer_t; typedef closure_t::const_iterator cclositer_t; void closure(closure_t &clos1, closure_t &clos2, Tagpool &tagpool, - std::valarray &rules, tagver_t &maxver, bool lookahead); + std::valarray &rules, tagver_t &maxver, tagver_t *newvers, + bool lookahead); } // namespace re2c diff --git a/re2c/src/ir/dfa/determinization.cc b/re2c/src/ir/dfa/determinization.cc index 773601be..8c0dbea2 100644 --- a/re2c/src/ir/dfa/determinization.cc +++ b/re2c/src/ir/dfa/determinization.cc @@ -66,6 +66,7 @@ dfa_t::dfa_t(const nfa_t &nfa, const charset_t &charset, const opt_t *opts, Tagpool tagpool(ntag); kernels_t kernels(tagpool, opts->bijective_mapping); closure_t clos1, clos2; + tagver_t *newvers = new tagver_t[ntag * 2]; dump_dfa_t dump(*this, tagpool, nfa, opts->dump_dfa_raw); // all-zero tag configuration must have static number zero @@ -85,18 +86,22 @@ dfa_t::dfa_t(const nfa_t &nfa, const charset_t &charset, const opt_t *opts, clos_t c0 = {NULL, nfa.root, INITIAL_TAGS, ZERO_TAGS, ZERO_TAGS}; clos1.push_back(c0); - closure(clos1, clos2, tagpool, rules, maxtagver, lookahead); + std::fill(newvers, newvers + ntag * 2, TAGVER_ZERO); + closure(clos1, clos2, tagpool, rules, maxtagver, newvers, lookahead); find_state(*this, dfa_t::NIL, 0/* any */, tagpool, kernels, clos2, dump); for (size_t i = 0; i < kernels.size(); ++i) { + std::fill(newvers, newvers + ntag * 2, TAGVER_ZERO); for (size_t c = 0; c < nchars; ++c) { reach(kernels[i], clos1, charset[c]); - closure(clos1, clos2, tagpool, rules, maxtagver, lookahead); + closure(clos1, clos2, tagpool, rules, maxtagver, newvers, lookahead); find_state(*this, i, c, tagpool, kernels, clos2, dump); } } warn_nondeterministic_tags(kernels, tagpool, vartags, rules, cond, warn); + + delete[] newvers; } /* diff --git a/re2c/test/tags/fix3.i--tags.c b/re2c/test/tags/fix3.i--tags.c index 73745821..bb1c808e 100644 --- a/re2c/test/tags/fix3.i--tags.c +++ b/re2c/test/tags/fix3.i--tags.c @@ -12,13 +12,13 @@ static void lex(const char *YYCURSOR) yych = *YYCURSOR; switch (yych) { case '0': - yyt2 = YYCURSOR; + yyt5 = YYCURSOR; goto yy4; case '1': - yyt2 = yyt3 = YYCURSOR; + yyt4 = yyt5 = YYCURSOR; goto yy7; case '2': - yyt2 = yyt3 = yyt4 = YYCURSOR; + yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy9; case '3': yyt2 = yyt3 = yyt4 = yyt5 = YYCURSOR; @@ -36,27 +36,27 @@ yy4: switch (yych) { case '0': goto yy4; case '1': - yyt3 = YYCURSOR; + yyt4 = YYCURSOR; goto yy7; case '2': yyt3 = yyt4 = YYCURSOR; goto yy9; case '3': - yyt3 = yyt4 = yyt5 = YYCURSOR; + yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy11; case '4': - yyt1 = yyt3 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy13; default: - yyt1 = yyt3 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy6; } yy6: p4 = yyt1; - p3 = yyt5; - p2 = yyt4; - p1 = yyt3; - p0 = yyt2; + p3 = yyt2; + p2 = yyt3; + p1 = yyt4; + p0 = yyt5; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%.*s'\n", p1 - p0, p0, @@ -71,16 +71,16 @@ yy7: switch (yych) { case '1': goto yy7; case '2': - yyt4 = YYCURSOR; + yyt3 = YYCURSOR; goto yy9; case '3': - yyt4 = yyt5 = YYCURSOR; + yyt2 = yyt3 = YYCURSOR; goto yy11; case '4': - yyt1 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy13; default: - yyt1 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy6; } yy9: @@ -88,13 +88,13 @@ yy9: switch (yych) { case '2': goto yy9; case '3': - yyt5 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; case '4': - yyt1 = yyt5 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy13; default: - yyt1 = yyt5 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy6; } yy11: 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 bfc50f96..5f3ee4af 100644 --- a/re2c/test/tags/fix3_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix3_trail.i--tags--input(custom).c @@ -19,16 +19,16 @@ static void lex(const char *s) yych = YYPEEK (); switch (yych) { case '0': - YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt5); goto yy4; case '1': - YYBACKUPTAG (yyt2); - YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy7; case '2': - YYBACKUPTAG (yyt2); YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy9; case '3': YYBACKUPTAG (yyt2); @@ -54,36 +54,36 @@ yy4: switch (yych) { case '0': goto yy4; case '1': - YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt4); goto yy7; case '2': YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); goto yy9; case '3': + YYBACKUPTAG (yyt2); YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); - YYBACKUPTAG (yyt5); goto yy11; case '4': YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); - YYBACKUPTAG (yyt5); goto yy13; default: YYBACKUPTAG (yyt1); + YYBACKUPTAG (yyt2); YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); - YYBACKUPTAG (yyt5); goto yy6; } yy6: YYRESTORETAG (yyt1); - YYCOPYTAG (p3, yyt5); - YYCOPYTAG (p2, yyt4); - YYCOPYTAG (p1, yyt3); - YYCOPYTAG (p0, yyt2); + YYCOPYTAG (p3, yyt2); + YYCOPYTAG (p2, yyt3); + YYCOPYTAG (p1, yyt4); + YYCOPYTAG (p0, yyt5); { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, @@ -99,21 +99,21 @@ yy7: switch (yych) { case '1': goto yy7; case '2': - YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt3); goto yy9; case '3': - YYBACKUPTAG (yyt4); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy11; case '4': YYBACKUPTAG (yyt1); - YYBACKUPTAG (yyt4); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy13; default: YYBACKUPTAG (yyt1); - YYBACKUPTAG (yyt4); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy6; } yy9: @@ -122,15 +122,15 @@ yy9: switch (yych) { case '2': goto yy9; case '3': - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); goto yy11; case '4': YYBACKUPTAG (yyt1); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); goto yy13; default: YYBACKUPTAG (yyt1); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); goto yy6; } yy11: diff --git a/re2c/test/tags/fix3_trail.i--tags.c b/re2c/test/tags/fix3_trail.i--tags.c index f53c2aab..46afdc95 100644 --- a/re2c/test/tags/fix3_trail.i--tags.c +++ b/re2c/test/tags/fix3_trail.i--tags.c @@ -12,13 +12,13 @@ static void lex(const char *YYCURSOR) yych = *YYCURSOR; switch (yych) { case '0': - yyt2 = YYCURSOR; + yyt5 = YYCURSOR; goto yy4; case '1': - yyt2 = yyt3 = YYCURSOR; + yyt4 = yyt5 = YYCURSOR; goto yy7; case '2': - yyt2 = yyt3 = yyt4 = YYCURSOR; + yyt3 = yyt4 = yyt5 = YYCURSOR; goto yy9; case '3': yyt2 = yyt3 = yyt4 = yyt5 = YYCURSOR; @@ -36,27 +36,27 @@ yy4: switch (yych) { case '0': goto yy4; case '1': - yyt3 = YYCURSOR; + yyt4 = YYCURSOR; goto yy7; case '2': yyt3 = yyt4 = YYCURSOR; goto yy9; case '3': - yyt3 = yyt4 = yyt5 = YYCURSOR; + yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy11; case '4': - yyt1 = yyt3 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy13; default: - yyt1 = yyt3 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = yyt4 = YYCURSOR; goto yy6; } yy6: YYCURSOR = yyt1; - p3 = yyt5; - p2 = yyt4; - p1 = yyt3; - p0 = yyt2; + p3 = yyt2; + p2 = yyt3; + p1 = yyt4; + p0 = yyt5; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, @@ -71,16 +71,16 @@ yy7: switch (yych) { case '1': goto yy7; case '2': - yyt4 = YYCURSOR; + yyt3 = YYCURSOR; goto yy9; case '3': - yyt4 = yyt5 = YYCURSOR; + yyt2 = yyt3 = YYCURSOR; goto yy11; case '4': - yyt1 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy13; default: - yyt1 = yyt4 = yyt5 = YYCURSOR; + yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy6; } yy9: @@ -88,13 +88,13 @@ yy9: switch (yych) { case '2': goto yy9; case '3': - yyt5 = YYCURSOR; + yyt2 = YYCURSOR; goto yy11; case '4': - yyt1 = yyt5 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy13; default: - yyt1 = yyt5 = YYCURSOR; + yyt1 = yyt2 = YYCURSOR; goto yy6; } yy11: diff --git a/re2c/test/tags/fix4.i--tags.c b/re2c/test/tags/fix4.i--tags.c index d389e807..c21b7b29 100644 --- a/re2c/test/tags/fix4.i--tags.c +++ b/re2c/test/tags/fix4.i--tags.c @@ -22,10 +22,10 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '1': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; case '2': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy8; default: goto yy3; } @@ -43,10 +43,10 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '3': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy9; case '4': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: goto yy7; } @@ -59,11 +59,11 @@ yy9: } yy11: ++YYCURSOR; - p3 = yyt2; - p1 = yyt1; + p3 = yyt1; + p1 = yyt2; p4 = YYCURSOR - 1; - p2 = yyt2 - 1; - p0 = yyt1 - 1; + p2 = yyt1 - 1; + p0 = yyt2 - 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 7542ab2f..c3774770 100644 --- a/re2c/test/tags/fix4_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix4_trail.i--tags--input(custom).c @@ -19,7 +19,7 @@ static void lex(const char *s) yych = YYPEEK (); switch (yych) { case '0': - YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt5); goto yy4; default: goto yy2; } @@ -36,7 +36,7 @@ yy4: YYBACKUPTAG (yyt4); goto yy5; case '2': - YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); goto yy8; default: goto yy3; @@ -47,7 +47,7 @@ yy5: switch (yych) { case '1': goto yy5; case '2': - YYBACKUPTAG (yyt2); + YYBACKUPTAG (yyt3); goto yy8; default: goto yy7; } @@ -59,11 +59,11 @@ yy8: yych = YYPEEK (); switch (yych) { case '3': - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); goto yy9; case '4': YYBACKUPTAG (yyt1); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt2); goto yy11; default: goto yy7; } @@ -80,10 +80,10 @@ yy9: yy11: YYSKIP (); YYRESTORETAG (yyt1); - YYCOPYTAG (p3, yyt5); - YYCOPYTAG (p2, yyt2); + YYCOPYTAG (p3, yyt2); + YYCOPYTAG (p2, yyt3); YYCOPYTAG (p1, yyt4); - YYCOPYTAG (p0, yyt3); + 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 3c1100e4..97e37032 100644 --- a/re2c/test/tags/fix4_trail.i--tags.c +++ b/re2c/test/tags/fix4_trail.i--tags.c @@ -22,10 +22,10 @@ yy4: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '1': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy5; case '2': - yyt1 = YYCURSOR; + yyt2 = YYCURSOR; goto yy8; default: goto yy3; } @@ -43,10 +43,10 @@ yy8: yych = *++YYCURSOR; switch (yych) { case '3': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy9; case '4': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: goto yy7; } @@ -59,11 +59,11 @@ yy9: } yy11: ++YYCURSOR; - p3 = yyt2; - p1 = yyt1; + p3 = yyt1; + p1 = yyt2; YYCURSOR -= 1; - p2 = yyt2 - 1; - p0 = yyt1 - 1; + p2 = yyt1 - 1; + p0 = yyt2 - 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 cc728109..1acbb9b2 100644 --- a/re2c/test/tags/fix5.i--tags.c +++ b/re2c/test/tags/fix5.i--tags.c @@ -12,10 +12,10 @@ static void lex(const char *YYCURSOR) yych = *YYCURSOR; switch (yych) { case '0': - yyt2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy4; case '1': - yyt2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy5; default: goto yy2; } @@ -34,10 +34,10 @@ yy5: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '2': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy3; } @@ -56,10 +56,10 @@ yy9: yych = *++YYCURSOR; switch (yych) { case '2': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy8; } @@ -76,10 +76,10 @@ yy12: goto yy15; yy13: p4 = yyt1; - p2 = yyt3; - p0 = yyt2; + p2 = yyt2; + p0 = yyt3; p3 = yyt1 - 1; - p1 = yyt3 - 1; + p1 = yyt2 - 1; { 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 bbed469d..99e0c51a 100644 --- a/re2c/test/tags/fix5_trail.i--tags--input(custom).c +++ b/re2c/test/tags/fix5_trail.i--tags--input(custom).c @@ -22,8 +22,8 @@ static void lex(const char *s) YYBACKUPTAG (yyt4); goto yy4; case '1': - YYBACKUPTAG (yyt3); YYBACKUPTAG (yyt4); + YYBACKUPTAG (yyt5); goto yy5; default: goto yy2; } @@ -46,11 +46,11 @@ yy5: yych = YYPEEK (); switch (yych) { case '2': - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt3); goto yy10; case '3': YYBACKUPTAG (yyt2); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt3); goto yy12; default: goto yy3; } @@ -61,7 +61,7 @@ yy7: switch (yych) { case '0': goto yy6; case '1': - YYBACKUPTAG (yyt3); + YYBACKUPTAG (yyt5); goto yy9; default: goto yy8; } @@ -73,11 +73,11 @@ yy9: yych = YYPEEK (); switch (yych) { case '2': - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt3); goto yy10; case '3': YYBACKUPTAG (yyt2); - YYBACKUPTAG (yyt5); + YYBACKUPTAG (yyt3); goto yy12; default: goto yy8; } @@ -99,8 +99,8 @@ yy12: yy13: YYRESTORETAG (yyt1); YYCOPYTAG (p3, yyt2); - YYCOPYTAG (p2, yyt5); - YYCOPYTAG (p1, yyt3); + YYCOPYTAG (p2, yyt3); + YYCOPYTAG (p1, yyt5); YYCOPYTAG (p0, yyt4); { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", diff --git a/re2c/test/tags/fix5_trail.i--tags.c b/re2c/test/tags/fix5_trail.i--tags.c index f3f83c36..c0f40af0 100644 --- a/re2c/test/tags/fix5_trail.i--tags.c +++ b/re2c/test/tags/fix5_trail.i--tags.c @@ -12,10 +12,10 @@ static void lex(const char *YYCURSOR) yych = *YYCURSOR; switch (yych) { case '0': - yyt2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy4; case '1': - yyt2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy5; default: goto yy2; } @@ -34,10 +34,10 @@ yy5: yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '2': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy3; } @@ -56,10 +56,10 @@ yy9: yych = *++YYCURSOR; switch (yych) { case '2': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy10; case '3': - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy12; default: goto yy8; } @@ -76,10 +76,10 @@ yy12: goto yy15; yy13: YYCURSOR = yyt1; - p2 = yyt3; - p0 = yyt2; + p2 = yyt2; + p0 = yyt3; p3 = yyt1 - 1; - p1 = yyt3 - 1; + p1 = yyt2 - 1; { printf("'%.*s', '%.*s', '%.*s', '%.*s', '%s'\n", p1 - p0, p0, diff --git a/re2c/test/tags/mapping1.i--tags--non-bijective-mapping.c b/re2c/test/tags/mapping1.i--tags--non-bijective-mapping.c index 70a47d53..0bba6f78 100644 --- a/re2c/test/tags/mapping1.i--tags--non-bijective-mapping.c +++ b/re2c/test/tags/mapping1.i--tags--non-bijective-mapping.c @@ -6,7 +6,7 @@ yych = *(YYMARKER = YYCURSOR); switch (yych) { case 'a': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; case 'b': goto yy7; default: @@ -36,13 +36,13 @@ yy5: default: goto yy6; } yy6: - p = yyt2; + p = yyt1; {} yy7: yych = *++YYCURSOR; switch (yych) { case 'a': - yyt2 = NULL; + yyt1 = NULL; goto yy5; case 'b': goto yy4; default: @@ -52,16 +52,18 @@ yy7: yy8: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy10; + case 'a': + yyt1 = yyt2; + goto yy10; default: goto yy4; } yy9: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy10; - default: - yyt2 = yyt1; - goto yy6; + case 'a': + yyt1 = yyt2; + goto yy10; + default: goto yy6; } yy10: ++YYCURSOR; diff --git a/re2c/test/tags/mapping1.i--tags.c b/re2c/test/tags/mapping1.i--tags.c index 70a47d53..0bba6f78 100644 --- a/re2c/test/tags/mapping1.i--tags.c +++ b/re2c/test/tags/mapping1.i--tags.c @@ -6,7 +6,7 @@ yych = *(YYMARKER = YYCURSOR); switch (yych) { case 'a': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy5; case 'b': goto yy7; default: @@ -36,13 +36,13 @@ yy5: default: goto yy6; } yy6: - p = yyt2; + p = yyt1; {} yy7: yych = *++YYCURSOR; switch (yych) { case 'a': - yyt2 = NULL; + yyt1 = NULL; goto yy5; case 'b': goto yy4; default: @@ -52,16 +52,18 @@ yy7: yy8: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy10; + case 'a': + yyt1 = yyt2; + goto yy10; default: goto yy4; } yy9: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy10; - default: - yyt2 = yyt1; - goto yy6; + case 'a': + yyt1 = yyt2; + goto yy10; + default: goto yy6; } yy10: ++YYCURSOR; diff --git a/re2c/test/tags/topsort2.i--tags.c b/re2c/test/tags/topsort2.i--tags.c index e0650ef3..015e8d42 100644 --- a/re2c/test/tags/topsort2.i--tags.c +++ b/re2c/test/tags/topsort2.i--tags.c @@ -4,19 +4,12 @@ YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; + yyt1 = NULL; + yyt2 = YYCURSOR; switch (yych) { - case 'a': - yyt1 = NULL; - yyt2 = YYCURSOR; - goto yy3; - case 'b': - yyt3 = NULL; - yyt1 = YYCURSOR; - goto yy5; - default: - yyt1 = NULL; - yyt2 = YYCURSOR; - goto yy2; + case 'a': goto yy3; + case 'b': goto yy5; + default: goto yy2; } yy2: p = yyt1; @@ -32,20 +25,26 @@ yy3: } yy5: yych = *(YYMARKER = ++YYCURSOR); - yyt2 = NULL; switch (yych) { - case 'a': goto yy6; - case 'b': goto yy7; - default: goto yy2; + case 'a': + yyt3 = NULL; + goto yy6; + case 'b': + yyt3 = NULL; + goto yy7; + default: + yyt1 = yyt2; + yyt2 = NULL; + goto yy2; } yy6: yych = *++YYCURSOR; switch (yych) { - case 'a': goto yy3; - default: - yyt2 = yyt1; - yyt1 = yyt3; - goto yy2; + case 'a': + yyt1 = yyt2; + yyt2 = yyt3; + goto yy3; + default: goto yy2; } yy7: yych = *++YYCURSOR; @@ -55,10 +54,13 @@ yy7: } yy8: YYCURSOR = YYMARKER; + yyt1 = yyt2; yyt2 = NULL; goto yy2; yy9: ++YYCURSOR; + yyt1 = yyt2; + yyt2 = yyt3; goto yy2; } diff --git a/re2c/test/tags/twopass.i--tags.c b/re2c/test/tags/twopass.i--tags.c index 04f5ce8b..e1c71b25 100644 --- a/re2c/test/tags/twopass.i--tags.c +++ b/re2c/test/tags/twopass.i--tags.c @@ -10,18 +10,18 @@ yych = *(YYMARKER = YYCURSOR); switch (yych) { case 'a': - yyt2 = YYCURSOR; + yyt3 = YYCURSOR; goto yy4; case 'b': yyt1 = yyt2 = yyt3 = YYCURSOR; goto yy6; default: - yyt3 = YYCURSOR; + yyt2 = YYCURSOR; goto yy3; } yy2: s = yyt4; - r = yyt2; + r = yyt1; {} yy3: yyaccept = 1; @@ -31,10 +31,10 @@ yy3: yyt4 = YYCURSOR; goto yy10; case 'b': - yyt2 = yyt4 = YYCURSOR; + yyt1 = yyt4 = YYCURSOR; goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy4: @@ -47,23 +47,19 @@ yy5: YYCURSOR = YYMARKER; switch (yyaccept) { case 0: - yyt2 = yyt4 = NULL; + yyt1 = yyt4 = NULL; goto yy2; case 1: - yyt2 = yyt3; + yyt1 = yyt2; yyt4 = YYCURSOR; goto yy2; - case 2: - yyt3 = yyt1; - yyt1 = yyt2; - goto yy7; + case 2: goto yy7; case 3: yyt4 = YYCURSOR; goto yy2; - case 4: - yyt2 = yyt3; + default: + yyt1 = yyt2; goto yy2; - default: goto yy7; } yy6: yyaccept = 2; @@ -73,16 +69,16 @@ yy6: yyt4 = YYCURSOR; goto yy10; case 'b': - yyt2 = yyt4 = YYCURSOR; + yyt1 = yyt4 = YYCURSOR; goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy7: y = yyt1; - q = yyt3; - p = yyt2; + q = yyt2; + p = yyt3; {} yy8: yyaccept = 3; @@ -91,15 +87,15 @@ yy8: yych = *YYCURSOR; switch (yych) { case 'a': - yyt3 = yyt2; + yyt2 = yyt1; yyt4 = YYCURSOR; goto yy10; case 'b': - yyt3 = yyt2; - yyt2 = yyt4 = YYCURSOR; + yyt2 = yyt1; + yyt1 = yyt4 = YYCURSOR; goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy10: @@ -117,11 +113,11 @@ yy11: switch (yych) { case 'a': goto yy14; case 'b': - yyt3 = yyt2; - yyt2 = yyt4 = YYCURSOR; + yyt2 = yyt1; + yyt1 = yyt4 = YYCURSOR; goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy13: @@ -129,11 +125,11 @@ yy13: switch (yych) { case 'a': goto yy17; case 'b': - yyt3 = NULL; + yyt2 = NULL; yyt1 = YYCURSOR; goto yy18; default: - yyt3 = NULL; + yyt2 = NULL; yyt1 = YYCURSOR; goto yy15; } @@ -145,10 +141,10 @@ yy14: switch (yych) { case 'a': goto yy10; case 'b': - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy11; default: - yyt2 = YYCURSOR; + yyt1 = YYCURSOR; goto yy8; } yy15: @@ -164,19 +160,19 @@ yy17: yych = *++YYCURSOR; switch (yych) { case 'a': - yyt2 = NULL; + yyt3 = NULL; goto yy20; case 'b': - yyt2 = NULL; - yyt1 = yyt3 = YYCURSOR; + yyt3 = NULL; + yyt1 = yyt2 = YYCURSOR; goto yy18; default: - yyt2 = NULL; - yyt1 = yyt3 = YYCURSOR; + yyt3 = NULL; + yyt1 = yyt2 = YYCURSOR; goto yy15; } yy18: - yyaccept = 5; + yyaccept = 2; YYMARKER = ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -196,11 +192,11 @@ yy21: switch (yych) { case 'a': goto yy5; case 'b': - yyt3 = NULL; + yyt2 = NULL; yyt1 = YYCURSOR; goto yy18; default: - yyt3 = NULL; + yyt2 = NULL; yyt1 = YYCURSOR; goto yy15; } -- 2.40.0