From 5958a2366cdb1361b5158076924014a36ff19dcc Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 2 May 2016 10:40:04 +0100 Subject: [PATCH] Bind contexts (a.k.a. tags) to DFA transitions, not states. This is a very imortant change: it makes tracing tag conflicts as simple as comparing tags on transitions during DFA construction. If during determinization we get two identical transitions that differ only in tags, then we have a tag conflict. Tags that cause conflicts are called non-deterministic (since they don't allow deterministic match). This approach if very similar to Ville Laurikari's TDFA: as he does, we first build TNFA and then apply determinization; however Laurikari's TDFA uses complex bookkeeping to track all possible tag values, while re2c simply forbids tags that cannot be matche efficiently. Binding tags to transitions allows more fine-grained liveness analyses, dead tag elimination and tag deduplication. --- re2c/Makefile.am | 1 - re2c/src/codegen/bitmap.cc | 7 +- re2c/src/codegen/emit.h | 10 +- re2c/src/codegen/emit_action.cc | 62 +++-- re2c/src/codegen/emit_dfa.cc | 8 +- re2c/src/codegen/go.h | 34 ++- re2c/src/codegen/go_construct.cc | 46 ++-- re2c/src/codegen/go_emit.cc | 86 +++---- re2c/src/ir/adfa/action.h | 2 +- re2c/src/ir/adfa/adfa.cc | 6 +- re2c/src/ir/adfa/adfa.h | 5 +- re2c/src/ir/adfa/prepare.cc | 40 ++- re2c/src/ir/dfa/context_deduplication.cc | 56 +++- re2c/src/ir/dfa/context_selfoverlap.cc | 112 -------- re2c/src/ir/dfa/determinization.cc | 241 +++++++++++------- re2c/src/ir/dfa/dfa.h | 10 +- re2c/src/ir/dfa/minimization.cc | 16 +- re2c/src/ir/skeleton/skeleton.cc | 17 +- re2c/src/ir/skeleton/skeleton.h | 1 + .../bug57_original.bi--case-insensitive.c | 62 +++-- re2c/test/config10.--skeleton.c | Bin 19428 -> 19478 bytes re2c/test/config10.c | 13 +- re2c/test/config8.c | 13 +- re2c/test/config9.b.c | 11 +- .../contexts/cond_star0.ci--input(custom).c | 18 +- re2c/test/contexts/cond_star0.ci.c | 18 +- .../contexts/cond_star1.ci--input(custom).c | 18 +- re2c/test/contexts/cond_star1.ci.c | 18 +- re2c/test/contexts/cond_star2.ci.c | 55 ++-- .../conf1.i--contexts--input(custom).c | 45 ++-- re2c/test/contexts/conf1.i--contexts.c | 45 ++-- .../conf2.i--contexts--input(custom).c | 45 ++-- re2c/test/contexts/conf2.i--contexts.c | 45 ++-- .../conf3.i--contexts--input(custom).c | 45 ++-- re2c/test/contexts/conf3.i--contexts.c | 45 ++-- .../conf4.i--contexts--input(custom).c | 45 ++-- re2c/test/contexts/conf4.i--contexts.c | 45 ++-- .../conf5.i--contexts--input(custom).c | 45 ++-- re2c/test/contexts/conf5.i--contexts.c | 45 ++-- .../conf6.--contexts--input(custom).c | 47 ++-- re2c/test/contexts/conf6.--contexts.c | 47 ++-- re2c/test/contexts/dedup0.i--input(custom).c | 14 +- re2c/test/contexts/dedup0.i.c | 14 +- re2c/test/contexts/dedup1.i--input(custom).c | 32 ++- re2c/test/contexts/dedup1.i.c | 32 ++- re2c/test/contexts/dedup2.i--input(custom).c | 3 - re2c/test/contexts/dedup2.i.c | 3 - re2c/test/contexts/dedup3.i--input(custom).c | 26 +- re2c/test/contexts/dedup3.i.c | 26 +- re2c/test/contexts/fix3.i--contexts.c | 77 ++++-- .../fix3_trail.i--contexts--input(custom).c | 77 ++++-- re2c/test/contexts/fix3_trail.i--contexts.c | 77 ++++-- re2c/test/contexts/fix4.i--contexts.c | 20 +- .../fix4_trail.i--contexts--input(custom).c | 20 +- re2c/test/contexts/fix4_trail.i--contexts.c | 20 +- re2c/test/contexts/fix5.i--contexts.c | 19 +- .../fix5_trail.i--contexts--input(custom).c | 19 +- re2c/test/contexts/fix5_trail.i--contexts.c | 19 +- re2c/test/contexts/overlap.i--input(custom).c | 18 +- re2c/test/contexts/overlap.i.c | 18 +- re2c/test/contexts/selfoverlap1_trail.i.c | 10 +- re2c/test/contexts/yyaccept1.i.c | 63 +++++ re2c/test/contexts/yyaccept1.i.re | 11 + re2c/test/ctx.--skeleton.c | Bin 19418 -> 19468 bytes re2c/test/ctx.b.c | 11 +- re2c/test/ctx.c | 13 +- re2c/test/ctx.s.c | 11 +- .../input_custom_default.--input(custom).c | 7 +- ...custom_default.--skeleton--input(custom).c | Bin 49002 -> 49015 bytes .../test/input_custom_fgetc.--input(custom).c | 7 +- ...t_custom_fgetc.--skeleton--input(custom).c | Bin 48998 -> 49011 bytes ...put_custom_istringstream.--input(custom).c | 7 +- ..._istringstream.--skeleton--input(custom).c | Bin 49014 -> 49027 bytes re2c/test/rexx.--skeleton.c | 19 +- re2c/test/scanner_re2c.bi.c | 66 +++-- re2c/test/scanner_re2c_default.--emit-dot.c | 18 +- re2c/test/scanner_re2c_default.bi.c | 66 +++-- re2c/test/strip_003.b--skeleton.c | 12 +- 78 files changed, 1463 insertions(+), 922 deletions(-) delete mode 100644 re2c/src/ir/dfa/context_selfoverlap.cc create mode 100644 re2c/test/contexts/yyaccept1.i.c create mode 100644 re2c/test/contexts/yyaccept1.i.re diff --git a/re2c/Makefile.am b/re2c/Makefile.am index 621f6f0e..73559056 100644 --- a/re2c/Makefile.am +++ b/re2c/Makefile.am @@ -86,7 +86,6 @@ SRC = \ src/ir/adfa/adfa.cc \ src/ir/adfa/prepare.cc \ src/ir/dfa/context_deduplication.cc \ - src/ir/dfa/context_selfoverlap.cc \ src/ir/dfa/determinization.cc \ src/ir/dfa/fallback.cc \ src/ir/dfa/fillpoints.cc \ diff --git a/re2c/src/codegen/bitmap.cc b/re2c/src/codegen/bitmap.cc index ca23423c..aa8c841d 100644 --- a/re2c/src/codegen/bitmap.cc +++ b/re2c/src/codegen/bitmap.cc @@ -156,7 +156,12 @@ bool matches(const Span * b1, uint32_t n1, const State * s1, const Span * b2, ui { return false; } - if (lb1 != lb2 || b1->ub != b2->ub) + // tags are forbidden: transitions on different symbols + // might go to the same state, but have different tag sets + if (lb1 != lb2 + || b1->ub != b2->ub + || b1->tags != 0 + || b2->tags != 0) { return false; } diff --git a/re2c/src/codegen/emit.h b/re2c/src/codegen/emit.h index 499ce644..f094354f 100644 --- a/re2c/src/codegen/emit.h +++ b/re2c/src/codegen/emit.h @@ -8,9 +8,13 @@ namespace re2c { void emit_action(OutputFile &o, uint32_t ind, bool &readCh, const DFA &dfa, const State *s, const std::set &used_labels); -void gen_goto(OutputFile &o, uint32_t ind, bool &readCh, const State *to); -void gen_goto_case(OutputFile &o, uint32_t ind, bool &readCh, const State *to); -void gen_goto_if(OutputFile &o, uint32_t ind, bool &readCh, const State *to); +void gen_goto(OutputFile &o, uint32_t ind, bool &readCh, + const State *to, const DFA &dfa, size_t tags); +void gen_goto_case(OutputFile &o, uint32_t ind, bool &readCh, + const State *to, const DFA &dfa, size_t tags); +void gen_goto_if(OutputFile &o, uint32_t ind, bool &readCh, + const State *to, const DFA &dfa, size_t tags); +void gen_settags(OutputFile &o, uint32_t ind, const DFA &dfa, size_t tags); } // namespace re2c diff --git a/re2c/src/codegen/emit_action.cc b/re2c/src/codegen/emit_action.cc index 8c32608e..c331ab60 100644 --- a/re2c/src/codegen/emit_action.cc +++ b/re2c/src/codegen/emit_action.cc @@ -54,13 +54,6 @@ void emit_action(OutputFile &o, uint32_t ind, bool &readCh, emit_rule(o, ind, dfa, s->action.info.rule); break; } - if (s->tags != 0) { - if (dfa.base_ctxmarker) { - o.wstring(opts->input_api.stmt_dist(ind, dfa.tagpool[s->tags], dfa.contexts)); - } else { - o.wstring(opts->input_api.stmt_backupctx(ind)); - } - } } void emit_match(OutputFile &o, uint32_t ind, bool &readCh, const State *s) @@ -147,7 +140,7 @@ void emit_accept_binary(OutputFile &o, uint32_t ind, bool &readCh, o.wind(--ind).ws("}\n"); } else { const accept_t &acc = *s->action.info.accepts; - gen_goto(o, ind, readCh, acc[l]); + gen_goto(o, ind, readCh, acc[l].first, dfa, acc[l].second); } } @@ -169,19 +162,27 @@ void emit_accept(OutputFile &o, uint32_t ind, bool &readCh, // only one possible 'yyaccept' value: unconditional jump if (nacc == 1) { - gen_goto(o, ind, readCh, acc[0]); + gen_goto(o, ind, readCh, acc[0].first, dfa, acc[0].second); return; } + bool have_tags = false; + for (size_t i = 0; i < nacc; ++i) { + if (acc[i].second != 0) { + have_tags = true; + break; + } + } + // jump table - if (opts->gFlag && nacc >= opts->cGotoThreshold) { + if (opts->gFlag && nacc >= opts->cGotoThreshold && !have_tags) { o.wind(ind).ws("{\n") .wind(ind + 1).ws("static void *") .wstring(opts->yytarget).ws("[") .wu64(nacc).ws("] = {\n"); for (uint32_t i = 0; i < nacc; ++i) { o.wind(ind + 2).ws("&&").wstring(opts->labelPrefix) - .wlabel(acc[i]->label).ws(",\n"); + .wlabel(acc[i].first->label).ws(",\n"); } o.wind(ind + 1).ws("};\n") .wind(ind + 1).ws("goto *") @@ -201,10 +202,10 @@ void emit_accept(OutputFile &o, uint32_t ind, bool &readCh, o.wind(ind).ws("switch (").wstring(opts->yyaccept).ws(") {\n"); for (uint32_t i = 0; i < nacc - 1; ++i) { o.wind(ind).ws("case ").wu32(i).ws(": "); - gen_goto_case(o, ind, readCh, acc[i]); + gen_goto_case(o, ind, readCh, acc[i].first, dfa, acc[i].second); } o.wind(ind).ws("default:"); - gen_goto_case(o, ind, readCh, acc[nacc - 1]); + gen_goto_case(o, ind, readCh, acc[nacc - 1].first, dfa, acc[nacc - 1].second); o.wind(ind).ws("}\n"); } @@ -344,33 +345,37 @@ void genSetState(OutputFile &o, uint32_t ind, uint32_t fillIndex) o.ws("\n"); } -void gen_goto_case(OutputFile &o, uint32_t ind, bool &readCh, const State *to) +void gen_goto_case(OutputFile &o, uint32_t ind, bool &readCh, + const State *to, const DFA &dfa, size_t tags) { - const bool multiline = readCh; + const bool multiline = readCh || (tags != 0); if (multiline) { o.ws("\n"); - gen_goto(o, ind + 1, readCh, to); + gen_goto(o, ind + 1, readCh, to, dfa, tags); } else { - gen_goto(o, 1, readCh, to); + gen_goto(o, 1, readCh, to, dfa, tags); } } -void gen_goto_if(OutputFile &o, uint32_t ind, bool &readCh, const State *to) +void gen_goto_if(OutputFile &o, uint32_t ind, bool &readCh, + const State *to, const DFA &dfa, size_t tags) { const int32_t linecount = (readCh && to != NULL) - || (to != NULL); + + (tags != 0) + + (to != NULL); if (linecount > 1) { o.ws("{\n"); - gen_goto(o, ind + 1, readCh, to); + gen_goto(o, ind + 1, readCh, to, dfa, tags); o.wind(ind).ws("}\n"); } else { - gen_goto(o, 0, readCh, to); + gen_goto(o, 0, readCh, to, dfa, tags); } } -void gen_goto(OutputFile &o, uint32_t ind, bool &readCh, const State *to) +void gen_goto(OutputFile &o, uint32_t ind, bool &readCh, + const State *to, const DFA &dfa, size_t tags) { if (to == NULL) { readCh = false; @@ -379,10 +384,23 @@ void gen_goto(OutputFile &o, uint32_t ind, bool &readCh, const State *to) o.wstring(opts->input_api.stmt_peek(ind)); readCh = false; } + gen_settags(o, ind, dfa, tags); if (to) { o.wind(ind).ws("goto ").wstring(opts->labelPrefix) .wlabel(to->label).ws(";\n"); } } +void gen_settags(OutputFile &o, uint32_t ind, const DFA &dfa, size_t tags) +{ + if (tags != 0) { + if (dfa.base_ctxmarker) { + o.wstring(opts->input_api.stmt_dist(ind, + dfa.tagpool[tags], dfa.contexts)); + } else { + o.wstring(opts->input_api.stmt_backupctx(ind)); + } + } +} + } // namespace re2c diff --git a/re2c/src/codegen/emit_dfa.cc b/re2c/src/codegen/emit_dfa.cc index 26c76448..158e178b 100644 --- a/re2c/src/codegen/emit_dfa.cc +++ b/re2c/src/codegen/emit_dfa.cc @@ -64,7 +64,7 @@ void DFA::count_used_labels (std::set & used, label_t start, label_t in } for (uint32_t i = 0; i < accepts.size (); ++i) { - used.insert (accepts[i]->label); + used.insert (accepts[i].first->label); } // must go last: it needs the set of used labels if (used.count (head->label)) @@ -88,7 +88,7 @@ void DFA::emit_body(OutputFile &o, uint32_t& ind, bool readCh = false; emit_state(o, ind, s, used_labels.count(s->label)); emit_action(o, ind, readCh, *this, s, used_labels); - s->go.emit(o, ind, readCh); + s->go.emit(o, ind, *this, readCh); } } @@ -117,7 +117,7 @@ void DFA::emit_dot( const accept_t &accepts = *s->action.info.accepts; for (uint32_t i = 0; i < accepts.size(); ++i) { o.wlabel(s->label).ws(" -> ") - .wlabel(accepts[i]->label) + .wlabel(accepts[i].first->label) .ws(" [label=\"yyaccept=") .wu32(i).ws("\"]").ws("\n"); } @@ -131,7 +131,7 @@ void DFA::emit_dot( } } bool readCh = false; - s->go.emit(o, 0, readCh); + s->go.emit(o, 0, *this, readCh); } if (!opts->cFlag || last_cond) { o.ws("}\n"); diff --git a/re2c/src/codegen/go.h b/re2c/src/codegen/go.h index f5395b7d..1cd15e00 100644 --- a/re2c/src/codegen/go.h +++ b/re2c/src/codegen/go.h @@ -12,6 +12,7 @@ namespace re2c { +struct DFA; class BitMap; class State; struct If; @@ -20,6 +21,7 @@ struct Span { uint32_t ub; State * to; + size_t tags; FORBID_COPY (Span); }; @@ -28,9 +30,10 @@ struct Case { std::vector > ranges; const State *to; + size_t tags; void emit(OutputFile &o, uint32_t ind) const; - inline Case(): ranges(), to(NULL) {} + inline Case(): ranges(), to(NULL), tags(0) {} FORBID_COPY(Case); }; @@ -39,10 +42,10 @@ struct Cases Case *cases; uint32_t cases_size; - void add(uint32_t lb, uint32_t ub, State *to); + void add(uint32_t lb, uint32_t ub, State *to, size_t tags); Cases(const Span *spans, uint32_t nspans); ~Cases(); - void emit(OutputFile &o, uint32_t ind, bool &readCh) const; + void emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh) const; void used_labels(std::set &used); FORBID_COPY(Cases); }; @@ -61,7 +64,7 @@ struct Binary If * els; Binary (const Span * s, uint32_t n, const State * next); ~Binary (); - void emit (OutputFile & o, uint32_t ind, bool & readCh); + void emit (OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh); void used_labels (std::set & used); FORBID_COPY (Binary); @@ -73,12 +76,14 @@ struct Linear { const Cond *cond; const State *to; + size_t tags; - Branch(): cond(NULL), to(NULL) {} - void init(const Cond *c, const State *s) + Branch(): cond(NULL), to(NULL), tags(0) {} + void init(const Cond *c, const State *s, size_t ts) { cond = c; to = s; + tags = ts; } FORBID_COPY(Branch); }; @@ -88,7 +93,7 @@ struct Linear Linear(const Span *s, uint32_t n, const State *next); ~Linear(); - void emit(OutputFile &o, uint32_t ind, bool &readCh); + void emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh); void used_labels(std::set &used); FORBID_COPY(Linear); }; @@ -107,7 +112,7 @@ struct If } info; If (type_t t, const Span * sp, uint32_t nsp, const State * next); ~If (); - void emit (OutputFile & o, uint32_t ind, bool & readCh); + void emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh); void used_labels (std::set & used); }; @@ -125,7 +130,7 @@ struct SwitchIf } info; SwitchIf (const Span * sp, uint32_t nsp, const State * next); ~SwitchIf (); - void emit (OutputFile & o, uint32_t ind, bool & readCh); + void emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh); void used_labels (std::set & used); }; @@ -137,7 +142,7 @@ struct GoBitmap SwitchIf * lgo; GoBitmap (const Span * span, uint32_t nSpans, const Span * hspan, uint32_t hSpans, const BitMap * bm, const State * bm_state, const State * next); ~GoBitmap (); - void emit (OutputFile & o, uint32_t ind, bool & readCh); + void emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh); void used_labels (std::set & used); FORBID_COPY (GoBitmap); @@ -164,7 +169,7 @@ struct Cpgoto CpgotoTable * table; Cpgoto (const Span * span, uint32_t nSpans, const Span * hspan, uint32_t hSpans, const State * next); ~Cpgoto (); - void emit (OutputFile & o, uint32_t ind, bool & readCh); + void emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh); void used_labels (std::set & used); FORBID_COPY (Cpgoto); @@ -176,7 +181,7 @@ struct Dot Cases * cases; Dot (const Span * sp, uint32_t nsp, const State * from); ~Dot (); - void emit (OutputFile & o); + void emit (OutputFile & o, const DFA &dfa); FORBID_COPY (Dot); }; @@ -185,6 +190,7 @@ struct Go { uint32_t nSpans; // number of spans Span * span; + size_t tags; enum { EMPTY, @@ -204,12 +210,13 @@ struct Go Go (); ~Go (); void init (const State * from); - void emit (OutputFile & o, uint32_t ind, bool & readCh); + void emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh); void used_labels (std::set & used); Go (const Go & g) : nSpans (g.nSpans) , span (g.span) + , tags (g.tags) , type (g.type) , info (g.info) {} @@ -217,6 +224,7 @@ struct Go { nSpans = g.nSpans; span = g.span; + tags = g.tags; type = g.type; info = g.info; return * this; diff --git a/re2c/src/codegen/go_construct.cc b/re2c/src/codegen/go_construct.cc index 3b8ab7dc..0da2b52d 100644 --- a/re2c/src/codegen/go_construct.cc +++ b/re2c/src/codegen/go_construct.cc @@ -26,19 +26,20 @@ Cases::Cases(const Span *spans, uint32_t nspans) Case &c = cases[cases_size++]; const Span &s = spans[nspans - 1]; c.to = s.to; + c.tags = s.tags; for (uint32_t i = 0, lb = 0; i < nspans; ++i) { const Span &s = spans[i]; - add(lb, s.ub, s.to); + add(lb, s.ub, s.to, s.tags); lb = s.ub; } } -void Cases::add(uint32_t lb, uint32_t ub, State *to) +void Cases::add(uint32_t lb, uint32_t ub, State *to, size_t tags) { for (uint32_t i = 0; i < cases_size; ++i) { Case &c = cases[i]; - if (c.to == to) { + if (c.to == to && c.tags == tags) { c.ranges.push_back(std::make_pair(lb, ub)); return; } @@ -46,6 +47,7 @@ void Cases::add(uint32_t lb, uint32_t ub, State *to) Case &c = cases[cases_size++]; c.ranges.push_back(std::make_pair(lb, ub)); c.to = to; + c.tags = tags; } Cond::Cond (const std::string & cmp, uint32_t val) @@ -71,30 +73,32 @@ Linear::Linear(const Span *s, uint32_t n, const State *next) { for (;;) { if (n == 1 && s[0].to == next) { - branches[nbranches++].init(NULL, NULL); + branches[nbranches++].init(NULL, NULL, s[0].tags); return; } else if (n == 1) { - branches[nbranches++].init(NULL, s[0].to); + branches[nbranches++].init(NULL, s[0].to, s[0].tags); return; } else if (n == 2 && s[0].to == next) { - branches[nbranches++].init(new Cond(">=", s[0].ub), s[1].to); - branches[nbranches++].init(NULL, NULL); + branches[nbranches++].init(new Cond(">=", s[0].ub), s[1].to, s[1].tags); + branches[nbranches++].init(NULL, NULL, s[0].tags); return; } else if (n == 3 && s[1].to == next && s[1].ub - s[0].ub == 1 - && s[2].to == s[0].to) { - branches[nbranches++].init(new Cond("!=", s[0].ub), s[0].to); - branches[nbranches++].init(NULL, NULL); + && s[2].to == s[0].to + && s[2].tags == s[0].tags) { + branches[nbranches++].init(new Cond("!=", s[0].ub), s[0].to, s[0].tags); + branches[nbranches++].init(NULL, NULL, s[1].tags); return; } else if (n >= 3 && s[1].ub - s[0].ub == 1 - && s[2].to == s[0].to) { - branches[nbranches++].init(new Cond("==", s[0].ub), s[1].to); + && s[2].to == s[0].to + && s[2].tags == s[0].tags) { + branches[nbranches++].init(new Cond("==", s[0].ub), s[1].to, s[1].tags); n -= 2; s += 2; } else { - branches[nbranches++].init(new Cond("<=", s[0].ub - 1), s[0].to); + branches[nbranches++].init(new Cond("<=", s[0].ub - 1), s[0].to, s[0].tags); n -= 1; s += 1; } @@ -182,6 +186,7 @@ Dot::Dot (const Span * sp, uint32_t nsp, const State * s) Go::Go () : nSpans (0) , span (NULL) + , tags (0) , type (EMPTY) , info () {} @@ -206,6 +211,14 @@ void Go::init (const State * from) } } + bool low_spans_have_tags = false; + for (uint32_t i = 0; i < nSpans - hSpans; ++i) { + if (span[i].tags != 0) { + low_spans_have_tags = true; + break; + } + } + // initialize bitmaps uint32_t nBitmaps = 0; const BitMap * bitmap = NULL; @@ -233,7 +246,7 @@ void Go::init (const State * from) type = DOT; info.dot = new Dot (span, nSpans, from); } - else if (opts->gFlag && (dSpans >= opts->cGotoThreshold)) + else if (opts->gFlag && (dSpans >= opts->cGotoThreshold) && !low_spans_have_tags) { type = CPGOTO; info.cpgoto = new Cpgoto (span, nSpans, hspan, hSpans, from->next); @@ -265,12 +278,15 @@ uint32_t unmap (Span * new_span, const Span * old_span, uint32_t old_nspans, con { if (old_span[i].to != x) { - if (new_nspans > 0 && new_span[new_nspans - 1].to == old_span[i].to) + if (new_nspans > 0 + && new_span[new_nspans - 1].to == old_span[i].to + && new_span[new_nspans - 1].tags == old_span[i].tags) new_span[new_nspans - 1].ub = old_span[i].ub; else { new_span[new_nspans].to = old_span[i].to; new_span[new_nspans].ub = old_span[i].ub; + new_span[new_nspans].tags = old_span[i].tags; ++new_nspans; } } diff --git a/re2c/src/codegen/go_emit.cc b/re2c/src/codegen/go_emit.cc index 160cdc55..6b9cb3da 100644 --- a/re2c/src/codegen/go_emit.cc +++ b/re2c/src/codegen/go_emit.cc @@ -21,7 +21,7 @@ namespace re2c static void output_if (OutputFile & o, uint32_t ind, bool & readCh, const std::string & compare, uint32_t value); static std::string output_yych (bool & readCh); -static std::string output_hgo (OutputFile & o, uint32_t ind, bool & readCh, SwitchIf * hgo); +static std::string output_hgo (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh, SwitchIf * hgo); std::string output_yych (bool & readCh) { @@ -41,13 +41,13 @@ void output_if (OutputFile & o, uint32_t ind, bool & readCh, const std::string & o.wind(ind).ws("if (").wstring(output_yych (readCh)).ws(" ").wstring(compare).ws(" ").wc_hex (value).ws(") "); } -std::string output_hgo (OutputFile & o, uint32_t ind, bool & readCh, SwitchIf * hgo) +std::string output_hgo (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh, SwitchIf * hgo) { std::string yych = output_yych (readCh); if (hgo != NULL) { o.wind(ind).ws("if (").wstring(yych).ws(" & ~0xFF) {\n"); - hgo->emit (o, ind + 1, readCh); + hgo->emit (o, ind + 1, dfa, readCh); o.wind(ind).ws("} else "); yych = opts->yych; } @@ -80,77 +80,67 @@ void Case::emit (OutputFile & o, uint32_t ind) const } } -void Cases::emit(OutputFile &o, uint32_t ind, bool &readCh) const +void Cases::emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh) const { o.wind(ind).ws("switch (").wstring(output_yych(readCh)).ws(") {\n"); for (uint32_t i = 1; i < cases_size; ++i) { const Case &c = cases[i]; c.emit(o, ind); - gen_goto_case(o, ind, readCh, c.to); + gen_goto_case(o, ind, readCh, c.to, dfa, c.tags); } // default case must be the last one const Case &c = cases[0]; o.wind(ind).ws("default:"); - gen_goto_case(o, ind, readCh, c.to); + gen_goto_case(o, ind, readCh, c.to, dfa, c.tags); o.wind(ind).ws("}\n"); } -void Binary::emit (OutputFile & o, uint32_t ind, bool & readCh) +void Binary::emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh) { - output_if (o, ind, readCh, cond->compare, cond->value); + output_if(o, ind, readCh, cond->compare, cond->value); o.ws("{\n"); - thn->emit (o, ind + 1, readCh); + thn->emit(o, ind + 1, dfa, readCh); o.wind(ind).ws("} else {\n"); - els->emit (o, ind + 1, readCh); + els->emit(o, ind + 1, dfa, readCh); o.wind(ind).ws("}\n"); } -void Linear::emit(OutputFile &o, uint32_t ind, bool &readCh) +void Linear::emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh) { for (uint32_t i = 0; i < nbranches; ++i) { const Branch &b = branches[i]; const Cond *cond = b.cond; if (cond) { output_if(o, ind, readCh, cond->compare, cond->value); - gen_goto_if(o, ind, readCh, b.to); + gen_goto_if(o, ind, readCh, b.to, dfa, b.tags); } else { - gen_goto(o, ind, readCh, b.to); + gen_goto(o, ind, readCh, b.to, dfa, b.tags); } } } -void If::emit (OutputFile & o, uint32_t ind, bool & readCh) +void If::emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh) { - switch (type) - { - case BINARY: - info.binary->emit (o, ind, readCh); - break; - case LINEAR: - info.linear->emit (o, ind, readCh); - break; + switch (type) { + case BINARY: info.binary->emit(o, ind, dfa, readCh); break; + case LINEAR: info.linear->emit(o, ind, dfa, readCh); break; } } -void SwitchIf::emit (OutputFile & o, uint32_t ind, bool & readCh) +void SwitchIf::emit(OutputFile &o, uint32_t ind, const DFA &dfa, bool &readCh) { - switch (type) - { - case SWITCH: - info.cases->emit (o, ind, readCh); - break; - case IF: - info.ifs->emit (o, ind, readCh); - break; + switch (type) { + case SWITCH: info.cases->emit(o, ind, dfa, readCh); break; + case IF: info.ifs->emit(o, ind, dfa, readCh); break; } } -void GoBitmap::emit (OutputFile & o, uint32_t ind, bool & readCh) +void GoBitmap::emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh) { - std::string yych = output_hgo (o, ind, readCh, hgo); + std::string yych = output_hgo (o, ind, dfa, readCh, hgo); o.ws("if (").wstring(opts->yybm).ws("[").wu32(bitmap->i).ws("+").wstring(yych).ws("] & "); if (opts->yybmHexTable) { @@ -161,11 +151,11 @@ void GoBitmap::emit (OutputFile & o, uint32_t ind, bool & readCh) o.wu32(bitmap->m); } o.ws(") {\n"); - gen_goto(o, ind + 1, readCh, bitmap_state); + gen_goto(o, ind + 1, readCh, bitmap_state, dfa, 0); o.wind(ind).ws("}\n"); if (lgo != NULL) { - lgo->emit (o, ind, readCh); + lgo->emit (o, ind, dfa, readCh); } } @@ -207,16 +197,16 @@ void CpgotoTable::emit (OutputFile & o, uint32_t ind) o.wind(--ind).ws("};\n"); } -void Cpgoto::emit (OutputFile & o, uint32_t ind, bool & readCh) +void Cpgoto::emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh) { - std::string yych = output_hgo (o, ind, readCh, hgo); + std::string yych = output_hgo (o, ind, dfa, readCh, hgo); o.ws("{\n"); table->emit (o, ++ind); o.wind(ind).ws("goto *").wstring(opts->yytarget).ws("[").wstring(yych).ws("];\n"); o.wind(--ind).ws("}\n"); } -void Dot::emit (OutputFile & o) +void Dot::emit(OutputFile &o, const DFA &dfa) { const uint32_t n = cases->cases_size; if (n == 1) { @@ -228,28 +218,34 @@ void Dot::emit (OutputFile & o) 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]; + for (size_t j = 0; j < dfa.tagpool.ntags; ++j) { + if (tags[j]) { + o.ws("<").wstring(dfa.contexts[j].name()).ws(">"); + } + } o.ws("\"]\n"); } } } -void Go::emit (OutputFile & o, uint32_t ind, bool & readCh) +void Go::emit (OutputFile & o, uint32_t ind, const DFA &dfa, bool & readCh) { - switch (type) - { + gen_settags(o, ind, dfa, tags); + switch (type) { case EMPTY: break; case SWITCH_IF: - info.switchif->emit (o, ind, readCh); + info.switchif->emit (o, ind, dfa, readCh); break; case BITMAP: - info.bitmap->emit (o, ind, readCh); + info.bitmap->emit (o, ind, dfa, readCh); break; case CPGOTO: - info.cpgoto->emit (o, ind, readCh); + info.cpgoto->emit (o, ind, dfa, readCh); break; case DOT: - info.dot->emit (o); + info.dot->emit (o, dfa); break; } } diff --git a/re2c/src/ir/adfa/action.h b/re2c/src/ir/adfa/action.h index cc0b6c87..8d3a21e1 100644 --- a/re2c/src/ir/adfa/action.h +++ b/re2c/src/ir/adfa/action.h @@ -24,7 +24,7 @@ struct Initial {} }; -typedef uniq_vector_t accept_t; +typedef uniq_vector_t > accept_t; class Action { diff --git a/re2c/src/ir/adfa/adfa.cc b/re2c/src/ir/adfa/adfa.cc index 0678ce24..cce2aed0 100644 --- a/re2c/src/ir/adfa/adfa.cc +++ b/re2c/src/ir/adfa/adfa.cc @@ -79,17 +79,19 @@ DFA::DFA *p = s; p = &s->next; - s->tags = t->tags; s->rule = t->rule; + s->rule_tags = t->rule_tags; s->fill = fill[i]; s->go.span = allocate(nchars); uint32_t j = 0; for (uint32_t c = 0; c < nchars; ++j) { const size_t to = t->arcs[c]; - for (;++c < nchars && t->arcs[c] == to;); + const size_t tags = t->tags[c]; + for (;++c < nchars && t->arcs[c] == to && t->tags[c] == tags;); s->go.span[j].to = to == dfa_t::NIL ? NULL : i2s[to]; s->go.span[j].ub = charset[c]; + s->go.span[j].tags = tags; } s->go.nSpans = j; } diff --git a/re2c/src/ir/adfa/adfa.h b/re2c/src/ir/adfa/adfa.h index 693dcb24..0c72b8b2 100644 --- a/re2c/src/ir/adfa/adfa.h +++ b/re2c/src/ir/adfa/adfa.h @@ -31,7 +31,7 @@ struct State bool fallback; size_t rule; - size_t tags; + size_t rule_tags; bool isBase; Go go; Action action; @@ -42,7 +42,7 @@ struct State , fill (0) , fallback (false) , rule (Rule::NONE) - , tags (0) + , rule_tags (0) , isBase (false) , go () , action () @@ -95,6 +95,7 @@ private: void addState(State*, State *); void split (State *); void findBaseState (); + void hoist_tags(); void count_used_labels (std::set & used, label_t prolog, label_t start, bool force_start) const; void emit_body (OutputFile &, uint32_t &, const std::set & used_labels, label_t initial) const; void emit_dot(OutputFile &o, bool last_cond, const std::vector &conds) const; diff --git a/re2c/src/ir/adfa/prepare.cc b/re2c/src/ir/adfa/prepare.cc index ee9dff21..92dafc2a 100644 --- a/re2c/src/ir/adfa/prepare.cc +++ b/re2c/src/ir/adfa/prepare.cc @@ -19,11 +19,13 @@ void DFA::split(State *s) move->rule = s->rule; move->fill = s->fill; move->go = s->go; + move->rule_tags = s->rule_tags; s->rule = Rule::NONE; s->go.nSpans = 1; s->go.span = allocate (1); s->go.span[0].ub = ubChar; s->go.span[0].to = move; + s->go.span[0].tags = 0; } static uint32_t merge(Span *x, State *fg, State *bg) @@ -35,13 +37,16 @@ static uint32_t merge(Span *x, State *fg, State *bg) Span *const x0 = x; for (;!(f == fe && b == be);) { - if (f->to == b->to) { + if (f->to == b->to && f->tags == b->tags) { x->to = bg; + x->tags = 0; } else { x->to = f->to; + x->tags = f->tags; } if (x == x0 - || x[-1].to != x->to) { + || x[-1].to != x->to + || x[-1].tags != x->tags) { ++x; } x[-1].ub = std::min(f->ub, b->ub); @@ -110,6 +115,7 @@ void DFA::prepare () for (uint32_t i = 0; i < s->go.nSpans; ++i) { if (!s->go.span[i].to) { s->go.span[i].to = rule2state[s->rule]; + s->go.span[i].tags = s->rule_tags; } } } @@ -137,13 +143,17 @@ void DFA::prepare () if (default_state) { for (State *s = head; s; s = s->next) { if (s->fallback) { - const size_t accept = accepts.find_or_add(rule2state[s->rule]); - s->action.set_save(accept); + const std::pair acc(rule2state[s->rule], s->rule_tags); + s->action.set_save(accepts.find_or_add(acc)); } } default_state->action.set_accept(&accepts); } + // tag hoisting should be done before tunneling, but after + // binding default arcs (which may introduce new tags) + hoist_tags(); + // split ``base'' states into two parts for (State * s = head; s; s = s->next) { @@ -169,7 +179,6 @@ void DFA::prepare () } } } - // find ``base'' state, if possible findBaseState(); @@ -198,4 +207,25 @@ void DFA::calc_stats () need_accept = accepts.size () > 1; } +void DFA::hoist_tags() +{ + for (State * s = head; s; s = s->next) { + const size_t nsp = s->go.nSpans; + if (nsp > 0) { + Span *sp = s->go.span; + const size_t tags0 = sp[0].tags; + bool common_tags = tags0 != 0; + for (uint32_t i = 1; common_tags && i < nsp; ++i) { + common_tags &= sp[i].tags == tags0; + } + if (common_tags) { + s->go.tags = tags0; + for (uint32_t i = 0; i < nsp; ++i) { + sp[i].tags = 0; + } + } + } + } +} + } // namespace re2c diff --git a/re2c/src/ir/dfa/context_deduplication.cc b/re2c/src/ir/dfa/context_deduplication.cc index c74ece58..45d9afa3 100644 --- a/re2c/src/ir/dfa/context_deduplication.cc +++ b/re2c/src/ir/dfa/context_deduplication.cc @@ -32,14 +32,14 @@ static bool dangling_arcs(const size_t *arcs, size_t narcs) * * Tag T is alive in state S if either: * - * - There is a transition from S to default state, S does not set T, + * - There is a transition from S to default state that does not set T, * S is final and T belongs to tag set associated with rule in S. * - * - There is a transition from S to default state, S does not set T + * - There is a transition from S to default state that does not set T * and T belongs to any tag set associated with fallback rules. * - * - There is a transition from S to some state S' (maybe equal to S), - * S does not set T and T is alive in S'. + * - There is a transition from S to some state S' (maybe equal to S) + * that does not set T and T is alive in S'. */ static void calc_live(const dfa_t &dfa, const bool *fallback, @@ -62,7 +62,7 @@ static void calc_live(const dfa_t &dfa, // final state, only rule tags are alive add_tags_with_mask(&live[i * ntags], dfa.rules[s->rule].tags, - dfa.tagpool[s->tags], + dfa.tagpool[s->rule_tags], ntags); } else { // transition to default state and dispatch on @@ -79,7 +79,7 @@ static void calc_live(const dfa_t &dfa, calc_live(dfa, fallback, visited, live, j); add_tags_with_mask(&live[i * ntags], &live[j * ntags], - dfa.tagpool[s->tags], + dfa.tagpool[s->tags[c]], ntags); } } @@ -92,7 +92,17 @@ static void mask_dead(dfa_t &dfa, const size_t ntags = dfa.contexts.size(); for (size_t i = 0; i < nstates; ++i) { dfa_state_t *s = dfa.states[i]; - mask_dead_tags(dfa.tagpool, s->tags, &livetags[i * ntags]); + for (size_t c = 0; c < dfa.nchars; ++c) { + const size_t j = s->arcs[c]; + if (j != dfa_t::NIL) { + s->tags[c] = mask_dead_tags(dfa.tagpool, + s->tags[c], &livetags[j * ntags]); + } + } + if (s->rule != Rule::NONE) { + s->rule_tags = mask_dead_tags(dfa.tagpool, + s->rule_tags, dfa.rules[s->rule].tags); + } } } @@ -116,14 +126,35 @@ static void incompatible(bool *tbl, static void incompatibility_table(const dfa_t &dfa, const bool *livetags, + const bool *deftags, bool *incompattbl) { const size_t nstates = dfa.states.size(); const size_t ntags = dfa.contexts.size(); for (size_t i = 0; i < nstates; ++i) { const dfa_state_t *s = dfa.states[i]; - incompatible(incompattbl, &livetags[i * ntags], - dfa.tagpool[s->tags], ntags); + for (size_t c = 0; c < dfa.nchars; ++c) { + const size_t j = s->arcs[c]; + if (j != dfa_t::NIL) { + incompatible(incompattbl, + &livetags[j * ntags], + dfa.tagpool[s->tags[c]], + ntags); + } + } + if (dangling_arcs(s->arcs, dfa.nchars)) { + if (s->rule != Rule::NONE) { + incompatible(incompattbl, + dfa.rules[s->rule].tags, + dfa.tagpool[s->rule_tags], + ntags); + } else { + incompatible(incompattbl, + deftags, + dfa.tagpool[s->rule_tags], + ntags); + } + } } } @@ -200,7 +231,10 @@ static void patch_tags(dfa_t &dfa, const std::vector &represent) const size_t nstates = dfa.states.size(); for (size_t i = 0; i < nstates; ++i) { dfa_state_t *s = dfa.states[i]; - s->tags = patch_tagset(dfa.tagpool, s->tags, represent); + for (size_t c = 0; c < dfa.nchars; ++c) { + s->tags[c] = patch_tagset(dfa.tagpool, s->tags[c], represent); + } + s->rule_tags = patch_tagset(dfa.tagpool, s->rule_tags, represent); } const size_t ntags = dfa.contexts.size(); @@ -231,7 +265,7 @@ size_t deduplicate_contexts(dfa_t &dfa, mask_dead(dfa, live); bool *incompattbl = new bool[ntags * ntags](); - incompatibility_table(dfa, live, incompattbl); + incompatibility_table(dfa, live, fbctxs, incompattbl); std::vector represent(ntags, 0); const size_t nreps = equivalence_classes(incompattbl, ntags, represent); diff --git a/re2c/src/ir/dfa/context_selfoverlap.cc b/re2c/src/ir/dfa/context_selfoverlap.cc deleted file mode 100644 index 65e30743..00000000 --- a/re2c/src/ir/dfa/context_selfoverlap.cc +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include - -#include "src/conf/warn.h" -#include "src/ir/dfa/dfa.h" -#include "src/ir/nfa/nfa.h" -#include "src/util/intersect_sorted.h" -#include "src/globals.h" - -namespace re2c -{ - -static void g(nfa_state_t *n, std::vector &tail); -static void e(nfa_state_t *n, std::vector &tail); -static void f(nfa_state_t *n, std::vector &tail); - -void check_context_selfoverlap( - ord_hash_set_t &kernels, - const std::vector &contexts, - uint32_t line, - const std::string &cond) -{ - const size_t nctxs = contexts.size(); - - std::vector bad(nctxs, false); - - std::map > shadows; - for (size_t i = 0; i < kernels.size(); ++i) { - nfa_state_t **kernel; - const size_t kernel_size = kernels.deref(i, kernel); - for (size_t j = 0; j < kernel_size; ++j) { - nfa_state_t *n = kernel[j]; - if (n->type == nfa_state_t::CTX - && !bad[n->value.ctx.info]) { - std::vector &shadow = shadows[n]; - if (shadow.empty()) { - f(n, shadow); - } - if (intersect_sorted( - shadow.begin(), shadow.end(), - kernel, kernel + kernel_size)) { - bad[n->value.ctx.info] = true; - } - } - } - } - - for (size_t i = 0; i < nctxs; ++i) { - if (bad[i]) { - warn.selfoverlapping_contexts(line, cond, contexts[i]); - } - } -} - -void f(nfa_state_t *n, std::vector &tail) -{ - e(n, tail); - std::sort(tail.begin(), tail.end()); -} - -void g(nfa_state_t *n, std::vector &tail) -{ - if (!n->mark) - { - n->mark = true; - tail.push_back(n); - switch (n->type) - { - case nfa_state_t::ALT: - g(n->value.alt.out2, tail); - g(n->value.alt.out1, tail); - break; - case nfa_state_t::RAN: - g(n->value.ran.out, tail); - break; - case nfa_state_t::CTX: - g(n->value.ctx.out, tail); - break; - case nfa_state_t::FIN: - break; - } - n->mark = false; - } -} - -static void e(nfa_state_t *n, std::vector &tail) -{ - if (!n->mark) - { - n->mark = true; - switch (n->type) - { - case nfa_state_t::ALT: - e(n->value.alt.out2, tail); - e(n->value.alt.out1, tail); - break; - case nfa_state_t::RAN: - g(n->value.ran.out, tail); - break; - case nfa_state_t::CTX: - e(n->value.ctx.out, tail); - break; - case nfa_state_t::FIN: - break; - } - n->mark = false; - } -} - -} // namespace re2c - diff --git a/re2c/src/ir/dfa/determinization.cc b/re2c/src/ir/dfa/determinization.cc index 6d1f8f1f..b71bb756 100644 --- a/re2c/src/ir/dfa/determinization.cc +++ b/re2c/src/ir/dfa/determinization.cc @@ -1,90 +1,130 @@ #include #include -#include -#include #include +#include "src/conf/warn.h" #include "src/ir/dfa/dfa.h" #include "src/ir/nfa/nfa.h" #include "src/ir/regexp/regexp.h" #include "src/util/range.h" +#include "src/globals.h" namespace re2c { const size_t dfa_t::NIL = std::numeric_limits::max(); -/* - * note [marking DFA states] +static void merge_tags(bool *oldtags, const bool *newtags, + bool *badtags, size_t ntags) +{ + for (size_t i = 0; i < ntags; ++i) { + badtags[i] |= oldtags[i] ^ newtags[i]; + oldtags[i] |= newtags[i]; + } +} + +static void merge_tags_with_mask(bool *oldtags, const bool *newtags, + bool *oldmask, const bool *newmask, + bool *badtags, size_t ntags) +{ + for (size_t i = 0; i < ntags; ++i) { + badtags[i] |= oldmask[i] & newmask[i] & (oldtags[i] ^ newtags[i]); + oldtags[i] |= newtags[i]; + oldmask[i] |= newmask[i]; + } +} +struct kitem_t +{ + nfa_state_t *state; + union + { + bool *tagptr; + size_t tagidx; + }; + + bool operator <(const kitem_t &k) + { + return state < k.state + || (state == k.state && tagidx < k.tagidx); + } +}; + +/* note [epsilon-closures in tagged NFA] * * DFA state is a set of NFA states. * However, DFA state includes not all NFA states that are in * epsilon-closure (NFA states that have only epsilon-transitions - * and are not context of final states are omitted). + * and are not final states are omitted). * The included states are called 'kernel' states. * - * We mark visited NFA states during closure construction. - * These marks serve two purposes: - * - avoid loops in NFA - * - avoid duplication of NFA states in kernel - * - * Note that after closure construction: - * - all non-kernel states must be unmarked (these states are - * not stored in kernel and it is impossible to unmark them - * afterwards) - * - all kernel states must be marked (because we may later - * extend this kernel with epsilon-closure of another NFA - * state). Kernel states are unmarked later (before finding - * or adding DFA state). + * For tagged NFA we have to trace all epsilon-paths to each + * kernel state, accumulate tags along the way and compare + * resulting tag sets: if they differ, then NFA is tagwise + * ambiguous. All tags are merged together; ambiguity is reported. */ -static nfa_state_t **closure(nfa_state_t **cP, nfa_state_t *n) +static void closure(kitem_t *const kernel, kitem_t *&kend, + nfa_state_t *n, bool *tags, bool *badtags, size_t ntags) { - if (!n->mark) - { - n->mark = true; - switch (n->type) - { - case nfa_state_t::ALT: - cP = closure(cP, n->value.alt.out2); - cP = closure(cP, n->value.alt.out1); - n->mark = false; - break; - case nfa_state_t::CTX: - *(cP++) = n; - cP = closure(cP, n->value.ctx.out); - break; - default: - *(cP++) = n; - break; - } + if (n->mark) { + return; } - return cP; + n->mark = true; + switch (n->type) { + case nfa_state_t::ALT: + closure(kernel, kend, n->value.alt.out2, tags, badtags, ntags); + closure(kernel, kend, n->value.alt.out1, tags, badtags, ntags); + break; + case nfa_state_t::CTX: { + const size_t ctx = n->value.ctx.info; + const bool old = tags[ctx]; + tags[ctx] = true; + closure(kernel, kend, n->value.ctx.out, tags, badtags, ntags); + tags[ctx] = old; + break; + } + case nfa_state_t::RAN: + case nfa_state_t::FIN: { + kitem_t *k = kernel; + while (k != kend && k->state != n) ++k; + if (k == kend) { + kend->state = n; + kend->tagptr = new bool[ntags]; + memcpy(kend->tagptr, tags, ntags * sizeof(bool)); + ++kend; + } else { + // it is impossible to reach the same NFA state from + // different rules, so no need to mess with masks here + merge_tags(k->tagptr, tags, badtags, ntags); + } + break; + } + } + n->mark = false; } -static size_t find_state - ( nfa_state_t **kernel - , nfa_state_t **end - , ord_hash_set_t &kernels - ) +static size_t find_state(kitem_t *kernel, kitem_t *kend, + ord_hash_set_t &kernels, Tagpool &tagpool) { + const size_t kcount = static_cast(kend - kernel); + // zero-sized kernel corresponds to default state - if (kernel == end) - { + if (kcount == 0) { return dfa_t::NIL; } - // see note [marking DFA states] - for (nfa_state_t **p = kernel; p != end; ++p) - { - (*p)->mark = false; + // dump tagsets to tagpool and address them by index: + // this simpifies storing and comparing kernels + for (kitem_t *k = kernel; k != kend; ++k) { + bool *tags = k->tagptr; + k->tagidx = tagpool.insert(tags); + delete[] tags; } - // sort kernel states: we need this to get stable hash - // and to compare states with simple 'memcmp' - std::sort(kernel, end); - const size_t size = static_cast(end - kernel) * sizeof(nfa_state_t*); - return kernels.insert(kernel, size); + // sort kernel items to allow comparison by hash and 'memcmp' + std::sort(kernel, kend); + + return kernels.insert(kernel, kcount * sizeof(kitem_t)); } dfa_t::dfa_t( @@ -100,64 +140,72 @@ dfa_t::dfa_t( { const size_t ntags = contexts.size(); const size_t nrules = rules.size(); + const size_t mask_size = (nchars + 1) * ntags; ord_hash_set_t kernels; - nfa_state_t **const buffer = new nfa_state_t*[nfa.size]; - std::vector > arcs(nchars); + kitem_t *kstart = new kitem_t[nfa.size], *kend = kstart; + bool *ktags = new bool[ntags](); + bool *badtags = new bool[ntags](); + bool *tags = new bool[mask_size]; + bool *mask = new bool[mask_size]; bool *fin = new bool[nrules]; - bool *tags = new bool[ntags]; + std::vector *arcs = new std::vector[nchars]; + + closure(kstart, kend, nfa.root, ktags, badtags, ntags); + find_state(kstart, kend, kernels, tagpool); + for (size_t i = 0; i < kernels.size(); ++i) { + memset(fin, 0, nrules * sizeof(bool)); + memset(tags, 0, mask_size * sizeof(bool)); + memset(mask, 0, mask_size * sizeof(bool)); + for(size_t c = 0; c < nchars; ++c) { + arcs[c].clear(); + } - find_state(buffer, closure(buffer, nfa.root), kernels); - for (size_t i = 0; i < kernels.size(); ++i) - { dfa_state_t *s = new dfa_state_t(nchars); states.push_back(s); - memset(fin, 0, nrules * sizeof(bool)); - memset(tags, 0, ntags * sizeof(bool)); - - nfa_state_t **kernel; - const size_t kernel_size = kernels.deref(i, kernel); - for (size_t j = 0; j < kernel_size; ++j) - { - nfa_state_t *n = kernel[j]; - switch (n->type) - { - case nfa_state_t::RAN: - { + const kitem_t *kernel; + const size_t kcount = kernels.deref(i, kernel); + for (size_t j = 0; j < kcount; ++j) { + nfa_state_t *n = kernel[j].state; + const bool *newtags = tagpool[kernel[j].tagidx]; + switch (n->type) { + case nfa_state_t::RAN: { nfa_state_t *m = n->value.ran.out; size_t c = 0; - for (const Range *r = n->value.ran.ran; r; r = r->next ()) - { + for (const Range *r = n->value.ran.ran; r; r = r->next ()) { for (; charset[c] != r->lower(); ++c); - for (; charset[c] != r->upper(); ++c) - { + for (; charset[c] != r->upper(); ++c) { + merge_tags_with_mask(&tags[c * ntags], newtags, + &mask[c * ntags], rules[m->rule].tags, + badtags, ntags); arcs[c].push_back(m); } } break; } - case nfa_state_t::CTX: - tags[n->value.ctx.info] = true; - break; case nfa_state_t::FIN: + merge_tags_with_mask(&tags[nchars * ntags], newtags, + &mask[nchars * ntags], rules[n->rule].tags, + badtags, ntags); fin[n->rule] = true; break; default: + assert(false); break; } } - for(size_t c = 0; c < nchars; ++c) - { - nfa_state_t **end = buffer; - for (std::vector::const_iterator j = arcs[c].begin(); j != arcs[c].end(); ++j) - { - end = closure(end, *j); + for (size_t c = 0; c < nchars; ++c) { + kend = kstart; + const std::vector &a = arcs[c]; + for (size_t j = 0; j < a.size(); ++j) { + closure(kstart, kend, a[j], ktags, badtags, ntags); } - s->arcs[c] = find_state(buffer, end, kernels); + s->arcs[c] = find_state(kstart, kend, kernels, tagpool); + s->tags[c] = tagpool.insert(&tags[c * ntags]); } - s->tags = tagpool.insert(tags); + s->rule_tags = tagpool.insert(&tags[nchars * ntags]); // choose the first rule (the one with smallest rank) size_t r; @@ -173,17 +221,22 @@ dfa_t::dfa_t( rules[r].shadow.insert(rules[s->rule].info->loc.line); } } + } - for(size_t c = 0; c < nchars; ++c) - { - arcs[c].clear(); + for (size_t i = 0; i < ntags; ++i) { + if (badtags[i]) { + // TODO: use rule line, add rule reference to context struct + warn.selfoverlapping_contexts(line, cond, contexts[i]); } } - delete[] buffer; - delete[] fin; - delete[] tags; - check_context_selfoverlap(kernels, contexts, line, cond); + delete[] kstart; + delete[] ktags; + delete[] badtags; + delete[] tags; + delete[] mask; + delete[] fin; + delete[] arcs; } dfa_t::~dfa_t() diff --git a/re2c/src/ir/dfa/dfa.h b/re2c/src/ir/dfa/dfa.h index 1bea33fe..4b0c86c4 100644 --- a/re2c/src/ir/dfa/dfa.h +++ b/re2c/src/ir/dfa/dfa.h @@ -20,17 +20,20 @@ struct nfa_t; struct dfa_state_t { size_t *arcs; + size_t *tags; size_t rule; - size_t tags; + size_t rule_tags; explicit dfa_state_t(size_t nchars) : arcs(new size_t[nchars]) + , tags(new size_t[nchars]) , rule(Rule::NONE) - , tags(0) + , rule_tags(0) {} ~dfa_state_t() { delete[] arcs; + delete[] tags; } FORBID_COPY(dfa_state_t); @@ -59,9 +62,6 @@ enum dfa_minimization_t DFA_MINIMIZATION_MOORE }; -void check_context_selfoverlap(ord_hash_set_t &kernels, - const std::vector &contexts, - uint32_t line, const std::string &cond); void minimization(dfa_t &dfa); void fillpoints(const dfa_t &dfa, std::vector &fill); void fallback_states(const dfa_t &dfa, std::vector &fallback); diff --git a/re2c/src/ir/dfa/minimization.cc b/re2c/src/ir/dfa/minimization.cc index 33ada5bb..88b9ae22 100644 --- a/re2c/src/ir/dfa/minimization.cc +++ b/re2c/src/ir/dfa/minimization.cc @@ -45,8 +45,8 @@ static void minimization_table( for (size_t j = 0; j < i; ++j) { dfa_state_t *s2 = states[j]; - tbl[i][j] = s1->tags != s2->tags - || s1->rule != s2->rule; + tbl[i][j] = s1->rule != s2->rule + || s1->rule_tags != s2->rule_tags; } } @@ -68,9 +68,10 @@ static void minimization_table( std::swap(oi, oj); } if (oi != oj && - (oi == dfa_t::NIL || - oj == dfa_t::NIL || - tbl[oi][oj])) + (oi == dfa_t::NIL + || oj == dfa_t::NIL + || tbl[oi][oj] + || memcmp(states[i]->tags, states[j]->tags, nchars * sizeof(size_t)) != 0)) { tbl[i][j] = true; loop = true; @@ -137,7 +138,7 @@ static void minimization_moore( for (size_t i = 0; i < count; ++i) { dfa_state_t *s = states[i]; - std::pair key(s->rule, s->tags); + std::pair key(s->rule, s->rule_tags); if (init.insert(std::make_pair(key, i)).second) { part[i] = i; @@ -186,7 +187,8 @@ static void minimization_moore( size_t k = diff[n]; if (memcmp(&out[j * nchars], &out[k * nchars], - nchars * sizeof(size_t)) == 0) + nchars * sizeof(size_t)) == 0 + && memcmp(states[j]->tags, states[k]->tags, nchars * sizeof(size_t)) == 0) { part[j] = k; next[j] = next[k]; diff --git a/re2c/src/ir/skeleton/skeleton.cc b/re2c/src/ir/skeleton/skeleton.cc index 8b00b3b4..d6193831 100644 --- a/re2c/src/ir/skeleton/skeleton.cc +++ b/re2c/src/ir/skeleton/skeleton.cc @@ -44,6 +44,11 @@ void Node::init(const bool *ts, size_t r, } } +Node::~Node() +{ + delete[] tags; +} + bool Node::end() const { return arcs.size() == 0; @@ -67,6 +72,7 @@ Skeleton::Skeleton( , contexts(dfa.contexts) { const size_t nc = cs.size() - 1; + const size_t ntags = dfa.tagpool.ntags; // initialize skeleton nodes for (size_t i = 0; i < nodes_count - 1; ++i) { @@ -84,7 +90,16 @@ Skeleton::Skeleton( if (arcs.size() == 1 && arcs[0].first == nodes_count - 1) { arcs.clear(); } - nodes[i].init(dfa.tagpool[s->tags], s->rule, arcs); + + // in skeleton we are only interested in trailing contexts + // which may be attributed to states rather than transitions + bool *tags = new bool[ntags](); + add_tags(tags, dfa.tagpool[s->rule_tags], ntags); + for (size_t c = 0; c < nc; ++c) { + add_tags(tags, dfa.tagpool[s->tags[c]], ntags); + } + + nodes[i].init(tags, s->rule, arcs); } // initialize size of key diff --git a/re2c/src/ir/skeleton/skeleton.h b/re2c/src/ir/skeleton/skeleton.h index 7f7561d4..dd80c03e 100644 --- a/re2c/src/ir/skeleton/skeleton.h +++ b/re2c/src/ir/skeleton/skeleton.h @@ -39,6 +39,7 @@ struct Node const bool *tags; Node(); + ~Node(); void init(const bool *ts, size_t r, const std::vector > &arcs); bool end() const; diff --git a/re2c/test/bug57_original.bi--case-insensitive.c b/re2c/test/bug57_original.bi--case-insensitive.c index 7b017094..ba1bfc93 100644 --- a/re2c/test/bug57_original.bi--case-insensitive.c +++ b/re2c/test/bug57_original.bi--case-insensitive.c @@ -8486,23 +8486,29 @@ yy918: yy919: ++p; yych = *p; - marker = p; - if (yybm[0+yych] & 64) { - goto yy923; + if (yybm[0+yych] & 16) { + goto yy919; } if (yych <= 0x00) goto yy917; - if (yych <= '\n') goto yy925; - goto yy919; + if (yych == '\n') { + marker = p; + goto yy925; + } + marker = p; + goto yy923; yy921: ++p; yych = *p; - marker = p; - if (yybm[0+yych] & 128) { - goto yy927; + if (yybm[0+yych] & 32) { + goto yy921; } if (yych <= 0x00) goto yy917; - if (yych <= '\n') goto yy929; - goto yy921; + if (yych == '\n') { + marker = p; + goto yy929; + } + marker = p; + goto yy927; yy923: ++p; yych = *p; @@ -8611,27 +8617,43 @@ yy939: yy940: ++p; yych = *p; - marker = p; - if (yybm[0+yych] & 128) { - goto yy944; + if (yybm[0+yych] & 32) { + goto yy940; + } + if (yych <= '\n') { + if (yych <= 0x08) goto yy938; + if (yych <= '\t') { + marker = p; + goto yy944; + } + marker = p; + goto yy946; + } else { + if (yych == ' ') { + marker = p; + goto yy944; + } + goto yy938; } - if (yych <= 0x08) goto yy938; - if (yych <= '\n') goto yy946; - if (yych == '`') goto yy940; - goto yy938; yy942: ++p; yych = *p; - marker = p; if (yybm[0+yych] & 64) { goto yy942; } if (yych <= '\n') { if (yych <= 0x08) goto yy938; - if (yych <= '\t') goto yy948; + if (yych <= '\t') { + marker = p; + goto yy948; + } + marker = p; goto yy950; } else { - if (yych == ' ') goto yy948; + if (yych == ' ') { + marker = p; + goto yy948; + } goto yy938; } yy944: diff --git a/re2c/test/config10.--skeleton.c b/re2c/test/config10.--skeleton.c index be417ae81bd32f36f8059bc691aeda1e6d60f05a..8f50b9d64d4a70146e9cedc726ac34ea69c89f17 100644 GIT binary patch delta 105 zcmaDdopIU>#to+hC-?KpO^y)|n%p4JsLG{)1R^7y9G$&G1Dr!56f`ug;c}A&M8qer V7UG=TAj~NPQjbgF<}E@7mH^fr8P@;+ delta 40 wcmbO>gYn69#to+hCwB@-Otup+nA{-HGuc;!hch{`I8{O2P~B?tGa&;@05wDn&;S4c diff --git a/re2c/test/config10.c b/re2c/test/config10.c index b2d2d258..34a3575e 100644 --- a/re2c/test/config10.c +++ b/re2c/test/config10.c @@ -106,7 +106,6 @@ xx8: #line 107 "config10.c" xx9: curr = *++s.cur; - s.ctx = s.cur; switch (curr) { case '0': case '2': @@ -116,8 +115,12 @@ xx9: case '6': case '7': case '8': - case '9': goto xx10; - case '1': goto xx13; + case '9': + s.ctx = s.cur; + goto xx10; + case '1': + s.ctx = s.cur; + goto xx13; default: goto xx3; } xx10: @@ -141,7 +144,7 @@ xx12: s.cur = s.ctx; #line 56 "config10.re" { return KEYWORD; } -#line 145 "config10.c" +#line 148 "config10.c" xx13: ++s.cur; switch ((curr = *s.cur)) { @@ -161,7 +164,7 @@ xx14: s.cur -= 1; #line 55 "config10.re" { return KEYWORD; } -#line 165 "config10.c" +#line 168 "config10.c" } #line 70 "config10.re" diff --git a/re2c/test/config8.c b/re2c/test/config8.c index 5ff78cb1..91377b27 100644 --- a/re2c/test/config8.c +++ b/re2c/test/config8.c @@ -106,7 +106,6 @@ xx8: #line 107 "config8.c" xx9: curr = *++s.cur; - s.ctx = s.cur; switch (curr) { case '0': case '2': @@ -116,8 +115,12 @@ xx9: case '6': case '7': case '8': - case '9': goto xx10; - case '1': goto xx13; + case '9': + s.ctx = s.cur; + goto xx10; + case '1': + s.ctx = s.cur; + goto xx13; default: goto xx3; } xx10: @@ -141,7 +144,7 @@ xx12: s.cur = s.ctx; #line 55 "config8.re" { return KEYWORD; } -#line 145 "config8.c" +#line 148 "config8.c" xx13: ++s.cur; switch ((curr = *s.cur)) { @@ -161,7 +164,7 @@ xx14: s.cur -= 1; #line 54 "config8.re" { return KEYWORD; } -#line 165 "config8.c" +#line 168 "config8.c" } #line 69 "config8.re" diff --git a/re2c/test/config9.b.c b/re2c/test/config9.b.c index e93b7b6f..e08ae800 100644 --- a/re2c/test/config9.b.c +++ b/re2c/test/config9.b.c @@ -122,10 +122,13 @@ xx6: #line 123 "config9.b.c" xx9: curr = (unsigned char)*++s.cur; - s.ctx = s.cur; if (curr <= '/') goto xx3; - if (curr == '1') goto xx13; + if (curr == '1') { + s.ctx = s.cur; + goto xx13; + } if (curr >= ':') goto xx3; + s.ctx = s.cur; xx10: ++s.cur; if (s.lim <= s.cur) fill(1); @@ -136,7 +139,7 @@ xx12: s.cur = s.ctx; #line 57 "config9.b.re" { return KEYWORD; } -#line 140 "config9.b.c" +#line 143 "config9.b.c" xx13: ++s.cur; if ((curr = (unsigned char)*s.cur) <= '/') goto xx14; @@ -145,7 +148,7 @@ xx14: s.cur -= 1; #line 56 "config9.b.re" { return KEYWORD; } -#line 149 "config9.b.c" +#line 152 "config9.b.c" } #line 71 "config9.b.re" diff --git a/re2c/test/contexts/cond_star0.ci--input(custom).c b/re2c/test/contexts/cond_star0.ci--input(custom).c index 8150a0fe..2dcfaa24 100644 --- a/re2c/test/contexts/cond_star0.ci--input(custom).c +++ b/re2c/test/contexts/cond_star0.ci--input(custom).c @@ -2,14 +2,11 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; switch (YYGETCONDITION()) { case yycc1: goto yyc_c1; } /* *********************************** */ yyc_c1: - YYBACKUPCTX (); if (YYLESSTHAN (3)) YYFILL(3); yych = YYPEEK (); switch (yych) { @@ -21,24 +18,27 @@ yy3: {} yy5: YYSKIP (); - yyctx1 = YYDIST(); + YYBACKUPCTX (); switch ((yych = YYPEEK ())) { case 'b': goto yy7; default: goto yy6; } yy6: - YYRESTORECTX (yyctx1); + YYRESTORECTX (); {} yy7: YYSKIP (); - yyctx0 = YYDIST(); switch ((yych = YYPEEK ())) { case 'b': goto yy9; - case 'c': goto yy11; - default: goto yy8; + case 'c': + YYBACKUPCTX (); + goto yy11; + default: + YYBACKUPCTX (); + goto yy8; } yy8: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy9: YYSKIP (); diff --git a/re2c/test/contexts/cond_star0.ci.c b/re2c/test/contexts/cond_star0.ci.c index dc58f637..cda1204f 100644 --- a/re2c/test/contexts/cond_star0.ci.c +++ b/re2c/test/contexts/cond_star0.ci.c @@ -2,14 +2,11 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; switch (YYGETCONDITION()) { case yycc1: goto yyc_c1; } /* *********************************** */ yyc_c1: - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -21,24 +18,27 @@ yy3: {} yy5: ++YYCURSOR; - yyctx1 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; switch ((yych = *YYCURSOR)) { case 'b': goto yy7; default: goto yy6; } yy6: - YYCURSOR = YYCTXMARKER + yyctx1; + YYCURSOR = YYCTXMARKER; {} yy7: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); switch ((yych = *YYCURSOR)) { case 'b': goto yy9; - case 'c': goto yy11; - default: goto yy8; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy11; + default: + YYCTXMARKER = YYCURSOR; + goto yy8; } yy8: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy9: ++YYCURSOR; diff --git a/re2c/test/contexts/cond_star1.ci--input(custom).c b/re2c/test/contexts/cond_star1.ci--input(custom).c index 795caee6..5643eb0e 100644 --- a/re2c/test/contexts/cond_star1.ci--input(custom).c +++ b/re2c/test/contexts/cond_star1.ci--input(custom).c @@ -2,15 +2,12 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; switch (YYGETCONDITION()) { case yycc1: goto yyc_c1; case yycc2: goto yyc_c2; } /* *********************************** */ yyc_c1: - YYBACKUPCTX (); if (YYLESSTHAN (3)) YYFILL(3); yych = YYPEEK (); switch (yych) { @@ -22,24 +19,27 @@ yy3: {} yy5: YYSKIP (); - yyctx1 = YYDIST(); + YYBACKUPCTX (); switch ((yych = YYPEEK ())) { case 'b': goto yy7; default: goto yy6; } yy6: - YYRESTORECTX (yyctx1); + YYRESTORECTX (); {} yy7: YYSKIP (); - yyctx0 = YYDIST(); switch ((yych = YYPEEK ())) { case 'b': goto yy9; - case 'c': goto yy11; - default: goto yy8; + case 'c': + YYBACKUPCTX (); + goto yy11; + default: + YYBACKUPCTX (); + goto yy8; } yy8: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy9: YYSKIP (); diff --git a/re2c/test/contexts/cond_star1.ci.c b/re2c/test/contexts/cond_star1.ci.c index 88f19999..adc00d3b 100644 --- a/re2c/test/contexts/cond_star1.ci.c +++ b/re2c/test/contexts/cond_star1.ci.c @@ -2,15 +2,12 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; switch (YYGETCONDITION()) { case yycc1: goto yyc_c1; case yycc2: goto yyc_c2; } /* *********************************** */ yyc_c1: - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -22,24 +19,27 @@ yy3: {} yy5: ++YYCURSOR; - yyctx1 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; switch ((yych = *YYCURSOR)) { case 'b': goto yy7; default: goto yy6; } yy6: - YYCURSOR = YYCTXMARKER + yyctx1; + YYCURSOR = YYCTXMARKER; {} yy7: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); switch ((yych = *YYCURSOR)) { case 'b': goto yy9; - case 'c': goto yy11; - default: goto yy8; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy11; + default: + YYCTXMARKER = YYCURSOR; + goto yy8; } yy8: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy9: ++YYCURSOR; diff --git a/re2c/test/contexts/cond_star2.ci.c b/re2c/test/contexts/cond_star2.ci.c index a254b249..b23f4317 100644 --- a/re2c/test/contexts/cond_star2.ci.c +++ b/re2c/test/contexts/cond_star2.ci.c @@ -2,16 +2,12 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; - long yyctx3; switch (YYGETCONDITION()) { case yycc1: goto yyc_c1; case yycc2: goto yyc_c2; } /* *********************************** */ yyc_c1: - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -23,24 +19,27 @@ yy3: {} yy5: ++YYCURSOR; - yyctx1 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; switch ((yych = *YYCURSOR)) { case 'b': goto yy7; default: goto yy6; } yy6: - YYCURSOR = YYCTXMARKER + yyctx1; + YYCURSOR = YYCTXMARKER; {} yy7: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); switch ((yych = *YYCURSOR)) { case 'b': goto yy9; - case 'c': goto yy11; - default: goto yy8; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy11; + default: + YYCTXMARKER = YYCURSOR; + goto yy8; } yy8: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy9: ++YYCURSOR; @@ -60,7 +59,6 @@ yy11: } /* *********************************** */ yyc_c2: - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -69,23 +67,28 @@ yyc_c2: } yy15: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; goto yy20; yy16: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy17: yych = *(YYMARKER = ++YYCURSOR); - yyctx0 = (YYCURSOR - YYCTXMARKER); switch (yych) { case 'a': goto yy21; - case 'b': goto yy23; - case 'c': goto yy26; - default: goto yy18; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy23; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy26; + default: + YYCTXMARKER = YYCURSOR; + goto yy18; } yy18: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy19: ++YYCURSOR; @@ -98,14 +101,18 @@ yy20: } yy21: yych = *++YYCURSOR; - yyctx3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case 'b': goto yy28; - case 'c': goto yy31; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy28; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy31; default: goto yy22; } yy22: YYCURSOR = YYMARKER; + YYCTXMARKER = YYCURSOR; goto yy18; yy23: ++YYCURSOR; @@ -116,7 +123,7 @@ yy23: default: goto yy25; } yy25: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy26: ++YYCURSOR; @@ -135,7 +142,7 @@ yy28: default: goto yy30; } yy30: - YYCURSOR = YYCTXMARKER + yyctx3; + YYCURSOR = YYCTXMARKER; {} yy31: ++YYCURSOR; @@ -146,7 +153,7 @@ yy31: default: goto yy33; } yy33: - YYCURSOR = YYCTXMARKER + yyctx3; + YYCURSOR = YYCTXMARKER; {} } diff --git a/re2c/test/contexts/conf1.i--contexts--input(custom).c b/re2c/test/contexts/conf1.i--contexts--input(custom).c index 047b3108..d4969f58 100644 --- a/re2c/test/contexts/conf1.i--contexts--input(custom).c +++ b/re2c/test/contexts/conf1.i--contexts--input(custom).c @@ -52,9 +52,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -89,9 +90,10 @@ yy6: yy7: YYSKIP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -107,9 +109,10 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -125,9 +128,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; default: goto yy6; } yy10: @@ -149,9 +153,10 @@ yy10: yy11: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -167,9 +172,10 @@ yy11: yy12: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -185,9 +191,10 @@ yy12: yy13: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; default: goto yy6; } yy14: @@ -209,9 +216,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -251,9 +259,10 @@ yy17: yy18: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf1.i--contexts.c b/re2c/test/contexts/conf1.i--contexts.c index 3b4b9b90..b87bcacd 100644 --- a/re2c/test/contexts/conf1.i--contexts.c +++ b/re2c/test/contexts/conf1.i--contexts.c @@ -42,9 +42,10 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -77,9 +78,10 @@ yy6: goto yy3; yy7: yych = *++YYCURSOR; - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -94,9 +96,10 @@ yy7: } yy8: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -111,9 +114,10 @@ yy8: } yy9: yych = *++YYCURSOR; - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; default: goto yy6; } yy10: @@ -133,9 +137,10 @@ yy10: } yy11: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -150,9 +155,10 @@ yy11: } yy12: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -167,9 +173,10 @@ yy12: } yy13: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; default: goto yy6; } yy14: @@ -189,9 +196,10 @@ yy14: } yy15: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -230,9 +238,10 @@ yy17: } yy18: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf2.i--contexts--input(custom).c b/re2c/test/contexts/conf2.i--contexts--input(custom).c index 7af780cb..9cd85b1b 100644 --- a/re2c/test/contexts/conf2.i--contexts--input(custom).c +++ b/re2c/test/contexts/conf2.i--contexts--input(custom).c @@ -50,9 +50,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -87,9 +88,10 @@ yy6: yy7: YYSKIP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -105,9 +107,10 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -123,9 +126,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; default: goto yy6; } yy10: @@ -147,9 +151,10 @@ yy10: yy11: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -165,9 +170,10 @@ yy11: yy12: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -183,9 +189,10 @@ yy12: yy13: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; default: goto yy6; } yy14: @@ -207,9 +214,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -249,9 +257,10 @@ yy17: yy18: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf2.i--contexts.c b/re2c/test/contexts/conf2.i--contexts.c index 48e7cc0b..c71261f9 100644 --- a/re2c/test/contexts/conf2.i--contexts.c +++ b/re2c/test/contexts/conf2.i--contexts.c @@ -40,9 +40,10 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -75,9 +76,10 @@ yy6: goto yy3; yy7: yych = *++YYCURSOR; - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -92,9 +94,10 @@ yy7: } yy8: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -109,9 +112,10 @@ yy8: } yy9: yych = *++YYCURSOR; - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; default: goto yy6; } yy10: @@ -131,9 +135,10 @@ yy10: } yy11: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -148,9 +153,10 @@ yy11: } yy12: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -165,9 +171,10 @@ yy12: } yy13: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; default: goto yy6; } yy14: @@ -187,9 +194,10 @@ yy14: } yy15: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -228,9 +236,10 @@ yy17: } yy18: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf3.i--contexts--input(custom).c b/re2c/test/contexts/conf3.i--contexts--input(custom).c index ff03eca9..5570188d 100644 --- a/re2c/test/contexts/conf3.i--contexts--input(custom).c +++ b/re2c/test/contexts/conf3.i--contexts--input(custom).c @@ -51,9 +51,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -88,9 +89,10 @@ yy6: yy7: YYSKIP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -106,9 +108,10 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -124,9 +127,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = ZZ_DIST(); + goto yy5; default: goto yy6; } yy10: @@ -148,9 +152,10 @@ yy10: yy11: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -166,9 +171,10 @@ yy11: yy12: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -184,9 +190,10 @@ yy12: yy13: YYSKIP (); yych = YYPEEK (); - zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = ZZ_DIST(); + goto yy10; default: goto yy6; } yy14: @@ -208,9 +215,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -250,9 +258,10 @@ yy17: yy18: YYSKIP (); yych = YYPEEK (); - zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = ZZ_DIST(); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf3.i--contexts.c b/re2c/test/contexts/conf3.i--contexts.c index 7c2869f8..9d4656d7 100644 --- a/re2c/test/contexts/conf3.i--contexts.c +++ b/re2c/test/contexts/conf3.i--contexts.c @@ -41,9 +41,10 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -76,9 +77,10 @@ yy6: goto yy3; yy7: yych = *++YYCURSOR; - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -93,9 +95,10 @@ yy7: } yy8: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -110,9 +113,10 @@ yy8: } yy9: yych = *++YYCURSOR; - zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; default: goto yy6; } yy10: @@ -132,9 +136,10 @@ yy10: } yy11: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -149,9 +154,10 @@ yy11: } yy12: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -166,9 +172,10 @@ yy12: } yy13: yych = *++YYCURSOR; - zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; default: goto yy6; } yy14: @@ -188,9 +195,10 @@ yy14: } yy15: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -229,9 +237,10 @@ yy17: } yy18: yych = *++YYCURSOR; - zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf4.i--contexts--input(custom).c b/re2c/test/contexts/conf4.i--contexts--input(custom).c index dc190bcf..54848890 100644 --- a/re2c/test/contexts/conf4.i--contexts--input(custom).c +++ b/re2c/test/contexts/conf4.i--contexts--input(custom).c @@ -65,9 +65,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -102,9 +103,10 @@ yy6: yy7: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -120,9 +122,10 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -138,9 +141,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; default: goto yy6; } yy10: @@ -162,9 +166,10 @@ yy10: yy11: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -180,9 +185,10 @@ yy11: yy12: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -198,9 +204,10 @@ yy12: yy13: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; default: goto yy6; } yy14: @@ -222,9 +229,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -264,9 +272,10 @@ yy17: yy18: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf4.i--contexts.c b/re2c/test/contexts/conf4.i--contexts.c index 50ebd1c0..99ef9fe0 100644 --- a/re2c/test/contexts/conf4.i--contexts.c +++ b/re2c/test/contexts/conf4.i--contexts.c @@ -55,9 +55,10 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -90,9 +91,10 @@ yy6: goto yy3; yy7: yych = *++YYCURSOR; - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -107,9 +109,10 @@ yy7: } yy8: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -124,9 +127,10 @@ yy8: } yy9: yych = *++YYCURSOR; - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; default: goto yy6; } yy10: @@ -146,9 +150,10 @@ yy10: } yy11: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -163,9 +168,10 @@ yy11: } yy12: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -180,9 +186,10 @@ yy12: } yy13: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; default: goto yy6; } yy14: @@ -202,9 +209,10 @@ yy14: } yy15: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -243,9 +251,10 @@ yy17: } yy18: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf5.i--contexts--input(custom).c b/re2c/test/contexts/conf5.i--contexts--input(custom).c index 784f3d7c..1d245f9e 100644 --- a/re2c/test/contexts/conf5.i--contexts--input(custom).c +++ b/re2c/test/contexts/conf5.i--contexts--input(custom).c @@ -59,9 +59,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -96,9 +97,10 @@ yy6: yy7: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -114,9 +116,10 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -132,9 +135,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; default: goto yy6; } yy10: @@ -156,9 +160,10 @@ yy10: yy11: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -174,9 +179,10 @@ yy11: yy12: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -192,9 +198,10 @@ yy12: yy13: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; default: goto yy6; } yy14: @@ -216,9 +223,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -258,9 +266,10 @@ yy17: yy18: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf5.i--contexts.c b/re2c/test/contexts/conf5.i--contexts.c index 8d1f265c..1f5634e5 100644 --- a/re2c/test/contexts/conf5.i--contexts.c +++ b/re2c/test/contexts/conf5.i--contexts.c @@ -49,9 +49,10 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -84,9 +85,10 @@ yy6: goto yy3; yy7: yych = *++YYCURSOR; - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -101,9 +103,10 @@ yy7: } yy8: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -118,9 +121,10 @@ yy8: } yy9: yych = *++YYCURSOR; - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; default: goto yy6; } yy10: @@ -140,9 +144,10 @@ yy10: } yy11: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -157,9 +162,10 @@ yy11: } yy12: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -174,9 +180,10 @@ yy12: } yy13: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; default: goto yy6; } yy14: @@ -196,9 +203,10 @@ yy14: } yy15: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -237,9 +245,10 @@ yy17: } yy18: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf6.--contexts--input(custom).c b/re2c/test/contexts/conf6.--contexts--input(custom).c index f9cbd262..1a6914f6 100644 --- a/re2c/test/contexts/conf6.--contexts--input(custom).c +++ b/re2c/test/contexts/conf6.--contexts--input(custom).c @@ -63,9 +63,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -100,9 +101,10 @@ yy6: yy7: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; case '0': case '1': case '2': @@ -118,9 +120,10 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -136,9 +139,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p1 = ZZ_DIST(); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = ZZ_DIST(); + goto yy5; default: goto yy6; } yy10: @@ -160,9 +164,10 @@ yy10: yy11: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; case '0': case '1': case '2': @@ -178,9 +183,10 @@ yy11: yy12: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -196,9 +202,10 @@ yy12: yy13: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p2 = ZZ_DIST(); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = ZZ_DIST(); + goto yy10; default: goto yy6; } yy14: @@ -220,9 +227,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; case '0': case '1': case '2': @@ -260,13 +268,14 @@ yy17: parse_oct(ZZ_CTX(ctxs.zz_0p3) + 1, s)); return; } -#line 264 "contexts/conf6.--contexts--input(custom).c" +#line 272 "contexts/conf6.--contexts--input(custom).c" yy18: YYSKIP (); yych = YYPEEK (); - ctxs.zz_0p3 = ZZ_DIST(); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = ZZ_DIST(); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/conf6.--contexts.c b/re2c/test/contexts/conf6.--contexts.c index aeb06f8b..187b7837 100644 --- a/re2c/test/contexts/conf6.--contexts.c +++ b/re2c/test/contexts/conf6.--contexts.c @@ -53,9 +53,10 @@ yy3: #line 54 "contexts/conf6.--contexts.c" yy4: yych = *(YYMARKER = ++YYCURSOR); - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -88,9 +89,10 @@ yy6: goto yy3; yy7: yych = *++YYCURSOR; - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; case '0': case '1': case '2': @@ -105,9 +107,10 @@ yy7: } yy8: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -122,9 +125,10 @@ yy8: } yy9: yych = *++YYCURSOR; - ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy5; + case '.': + ctxs.zz_0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; default: goto yy6; } yy10: @@ -144,9 +148,10 @@ yy10: } yy11: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; case '0': case '1': case '2': @@ -161,9 +166,10 @@ yy11: } yy12: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -178,9 +184,10 @@ yy12: } yy13: yych = *++YYCURSOR; - ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy10; + case '.': + ctxs.zz_0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; default: goto yy6; } yy14: @@ -200,9 +207,10 @@ yy14: } yy15: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; case '0': case '1': case '2': @@ -240,12 +248,13 @@ yy17: parse_oct((YYCTXMARKER + ctxs.zz_0p3) + 1, YYCURSOR)); return; } -#line 244 "contexts/conf6.--contexts.c" +#line 252 "contexts/conf6.--contexts.c" yy18: yych = *++YYCURSOR; - ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case '.': goto yy14; + case '.': + ctxs.zz_0p3 = (YYCURSOR - YYCTXMARKER); + goto yy14; default: goto yy6; } yy19: diff --git a/re2c/test/contexts/dedup0.i--input(custom).c b/re2c/test/contexts/dedup0.i--input(custom).c index b3492e83..6dbec296 100644 --- a/re2c/test/contexts/dedup0.i--input(custom).c +++ b/re2c/test/contexts/dedup0.i--input(custom).c @@ -16,19 +16,23 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - YYBACKUPCTX (); switch (yych) { case 'a': goto yy5; - case 'b': goto yy7; - case 'c': goto yy10; + case 'b': + YYBACKUPCTX (); + goto yy7; + case 'c': + YYBACKUPCTX (); + goto yy10; default: goto yy3; } yy5: YYSKIP (); yych = YYPEEK (); - YYBACKUPCTX (); switch (yych) { - case 'z': goto yy13; + case 'z': + YYBACKUPCTX (); + goto yy13; default: goto yy6; } yy6: diff --git a/re2c/test/contexts/dedup0.i.c b/re2c/test/contexts/dedup0.i.c index 6d015264..890c8c87 100644 --- a/re2c/test/contexts/dedup0.i.c +++ b/re2c/test/contexts/dedup0.i.c @@ -14,18 +14,22 @@ yy3: {} yy4: yych = *(YYMARKER = ++YYCURSOR); - YYCTXMARKER = YYCURSOR; switch (yych) { case 'a': goto yy5; - case 'b': goto yy7; - case 'c': goto yy10; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy7; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy10; default: goto yy3; } yy5: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; switch (yych) { - case 'z': goto yy13; + case 'z': + YYCTXMARKER = YYCURSOR; + goto yy13; default: goto yy6; } yy6: diff --git a/re2c/test/contexts/dedup1.i--input(custom).c b/re2c/test/contexts/dedup1.i--input(custom).c index 40b88cf1..4fe89a68 100644 --- a/re2c/test/contexts/dedup1.i--input(custom).c +++ b/re2c/test/contexts/dedup1.i--input(custom).c @@ -2,9 +2,6 @@ { YYCTYPE yych; - long yyctx0; - long yyctx2; - YYBACKUPCTX (); if (YYLESSTHAN (3)) YYFILL(3); yych = YYPEEK (); switch (yych) { @@ -13,23 +10,27 @@ } yy2: YYSKIP (); - yyctx0 = YYDIST(); + YYBACKUPCTX (); yych = YYPEEK (); goto yy7; yy3: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - yyctx0 = YYDIST(); switch (yych) { case 'a': goto yy8; - default: goto yy11; + case 'b': + YYBACKUPCTX (); + goto yy10; + default: + YYBACKUPCTX (); + goto yy5; } yy5: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy6: YYSKIP (); @@ -43,20 +44,23 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - yyctx2 = YYDIST(); switch (yych) { - case 'b': goto yy12; - case 'c': goto yy15; + case 'b': + YYBACKUPCTX (); + goto yy12; + case 'c': + YYBACKUPCTX (); + goto yy15; default: goto yy9; } yy9: YYRESTORE (); + YYBACKUPCTX (); goto yy5; yy10: YYSKIP (); if (YYLESSTHAN (1)) YYFILL(1); yych = YYPEEK (); -yy11: switch (yych) { case 'b': goto yy10; default: goto yy5; @@ -70,7 +74,7 @@ yy12: default: goto yy14; } yy14: - YYRESTORECTX (yyctx2); + YYRESTORECTX (); {} yy15: YYSKIP (); @@ -81,7 +85,7 @@ yy15: default: goto yy17; } yy17: - YYRESTORECTX (yyctx2); + YYRESTORECTX (); {} } diff --git a/re2c/test/contexts/dedup1.i.c b/re2c/test/contexts/dedup1.i.c index b0901611..dfd7012b 100644 --- a/re2c/test/contexts/dedup1.i.c +++ b/re2c/test/contexts/dedup1.i.c @@ -2,9 +2,6 @@ { YYCTYPE yych; - long yyctx0; - long yyctx2; - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -13,21 +10,25 @@ } yy2: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; goto yy7; yy3: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy4: yych = *(YYMARKER = ++YYCURSOR); - yyctx0 = (YYCURSOR - YYCTXMARKER); switch (yych) { case 'a': goto yy8; - default: goto yy11; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy10; + default: + YYCTXMARKER = YYCURSOR; + goto yy5; } yy5: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy6: ++YYCURSOR; @@ -40,20 +41,23 @@ yy7: } yy8: yych = *++YYCURSOR; - yyctx2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case 'b': goto yy12; - case 'c': goto yy15; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy12; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy15; default: goto yy9; } yy9: YYCURSOR = YYMARKER; + YYCTXMARKER = YYCURSOR; goto yy5; yy10: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy11: switch (yych) { case 'b': goto yy10; default: goto yy5; @@ -67,7 +71,7 @@ yy12: default: goto yy14; } yy14: - YYCURSOR = YYCTXMARKER + yyctx2; + YYCURSOR = YYCTXMARKER; {} yy15: ++YYCURSOR; @@ -78,7 +82,7 @@ yy15: default: goto yy17; } yy17: - YYCURSOR = YYCTXMARKER + yyctx2; + YYCURSOR = YYCTXMARKER; {} } diff --git a/re2c/test/contexts/dedup2.i--input(custom).c b/re2c/test/contexts/dedup2.i--input(custom).c index 1cffd83d..d20eec34 100644 --- a/re2c/test/contexts/dedup2.i--input(custom).c +++ b/re2c/test/contexts/dedup2.i--input(custom).c @@ -10,14 +10,12 @@ } yy2: YYSKIP (); - YYBACKUPCTX (); yych = YYPEEK (); goto yy6; YYRESTORECTX (); {} yy4: YYSKIP (); - YYBACKUPCTX (); switch ((yych = YYPEEK ())) { case 'a': goto yy10; default: goto yy8; @@ -36,7 +34,6 @@ yy8: goto yy8; yy10: YYSKIP (); - YYBACKUPCTX (); yych = YYPEEK (); goto yy8; } diff --git a/re2c/test/contexts/dedup2.i.c b/re2c/test/contexts/dedup2.i.c index b594ceab..4d37bb76 100644 --- a/re2c/test/contexts/dedup2.i.c +++ b/re2c/test/contexts/dedup2.i.c @@ -10,14 +10,12 @@ } yy2: ++YYCURSOR; - YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; goto yy6; YYCURSOR = YYCTXMARKER; {} yy4: ++YYCURSOR; - YYCTXMARKER = YYCURSOR; switch ((yych = *YYCURSOR)) { case 'a': goto yy10; default: goto yy8; @@ -36,7 +34,6 @@ yy8: goto yy8; yy10: ++YYCURSOR; - YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; goto yy8; } diff --git a/re2c/test/contexts/dedup3.i--input(custom).c b/re2c/test/contexts/dedup3.i--input(custom).c index f00ad458..adf529d1 100644 --- a/re2c/test/contexts/dedup3.i--input(custom).c +++ b/re2c/test/contexts/dedup3.i--input(custom).c @@ -2,9 +2,6 @@ { YYCTYPE yych; - long yyctx0; - long yyctx2; - YYBACKUPCTX (); if (YYLESSTHAN (3)) YYFILL(3); yych = YYPEEK (); switch (yych) { @@ -13,23 +10,27 @@ } yy2: YYSKIP (); - yyctx0 = YYDIST(); + YYBACKUPCTX (); yych = YYPEEK (); goto yy7; yy3: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - yyctx0 = YYDIST(); switch (yych) { case 'a': goto yy8; - default: goto yy11; + case 'b': + YYBACKUPCTX (); + goto yy10; + default: + YYBACKUPCTX (); + goto yy5; } yy5: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy6: YYSKIP (); @@ -43,19 +44,20 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - yyctx2 = YYDIST(); switch (yych) { - case 'b': goto yy12; + case 'b': + YYBACKUPCTX (); + goto yy12; default: goto yy9; } yy9: YYRESTORE (); + YYBACKUPCTX (); goto yy5; yy10: YYSKIP (); if (YYLESSTHAN (1)) YYFILL(1); yych = YYPEEK (); -yy11: switch (yych) { case 'b': goto yy10; default: goto yy5; @@ -69,7 +71,7 @@ yy12: default: goto yy14; } yy14: - YYRESTORECTX (yyctx2); + YYRESTORECTX (); {} } diff --git a/re2c/test/contexts/dedup3.i.c b/re2c/test/contexts/dedup3.i.c index c0937ea5..ec4d094e 100644 --- a/re2c/test/contexts/dedup3.i.c +++ b/re2c/test/contexts/dedup3.i.c @@ -2,9 +2,6 @@ { YYCTYPE yych; - long yyctx0; - long yyctx2; - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -13,21 +10,25 @@ } yy2: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; goto yy7; yy3: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy4: yych = *(YYMARKER = ++YYCURSOR); - yyctx0 = (YYCURSOR - YYCTXMARKER); switch (yych) { case 'a': goto yy8; - default: goto yy11; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy10; + default: + YYCTXMARKER = YYCURSOR; + goto yy5; } yy5: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy6: ++YYCURSOR; @@ -40,19 +41,20 @@ yy7: } yy8: yych = *++YYCURSOR; - yyctx2 = (YYCURSOR - YYCTXMARKER); switch (yych) { - case 'b': goto yy12; + case 'b': + YYCTXMARKER = YYCURSOR; + goto yy12; default: goto yy9; } yy9: YYCURSOR = YYMARKER; + YYCTXMARKER = YYCURSOR; goto yy5; yy10: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; -yy11: switch (yych) { case 'b': goto yy10; default: goto yy5; @@ -66,7 +68,7 @@ yy12: default: goto yy14; } yy14: - YYCURSOR = YYCTXMARKER + yyctx2; + YYCURSOR = YYCTXMARKER; {} } diff --git a/re2c/test/contexts/fix3.i--contexts.c b/re2c/test/contexts/fix3.i--contexts.c index a1ca6956..e02091d9 100644 --- a/re2c/test/contexts/fix3.i--contexts.c +++ b/re2c/test/contexts/fix3.i--contexts.c @@ -15,13 +15,20 @@ static void lex(const char *YYCURSOR) long yyctx0p4; YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; - yyctx0p4 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '0': goto yy5; - case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; + case '1': + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy7; + case '2': + yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0p4 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy13; default: goto yy3; } yy2: @@ -40,44 +47,68 @@ yy3: yy5: ++YYCURSOR; yych = *YYCURSOR; - yyctx0p4 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '0': goto yy5; - case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '1': + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy7; + case '2': + yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0p4 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0p4 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy7: ++YYCURSOR; yych = *YYCURSOR; - yyctx0p4 = yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '2': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0p4 = yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0p4 = yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy9: ++YYCURSOR; yych = *YYCURSOR; - yyctx0p4 = yyctx0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '3': + yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0p4 = yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0p4 = yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy11: ++YYCURSOR; yych = *YYCURSOR; - yyctx0p4 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '4': + yyctx0p4 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0p4 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy13: ++YYCURSOR; diff --git a/re2c/test/contexts/fix3_trail.i--contexts--input(custom).c b/re2c/test/contexts/fix3_trail.i--contexts--input(custom).c index 25b45577..582ec07d 100644 --- a/re2c/test/contexts/fix3_trail.i--contexts--input(custom).c +++ b/re2c/test/contexts/fix3_trail.i--contexts--input(custom).c @@ -15,13 +15,20 @@ static void lex(const char *YYCURSOR) long yyctx0p3; YYBACKUPCTX (); yych = YYPEEK (); - yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); switch (yych) { case '0': goto yy5; - case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; + case '1': + yyctx0p1 = YYDIST(); + goto yy7; + case '2': + yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy13; default: goto yy3; } yy2: @@ -41,44 +48,68 @@ yy3: yy5: YYSKIP (); yych = YYPEEK (); - yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); switch (yych) { case '0': goto yy5; - case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '1': + yyctx0p1 = YYDIST(); + goto yy7; + case '2': + yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy13; + default: + yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = YYDIST(); + goto yy2; } yy7: YYSKIP (); yych = YYPEEK (); - yyctx0 = yyctx0p3 = yyctx0p2 = YYDIST(); switch (yych) { case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '2': + yyctx0p2 = YYDIST(); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = YYDIST(); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = yyctx0p2 = YYDIST(); + goto yy13; + default: + yyctx0 = yyctx0p3 = yyctx0p2 = YYDIST(); + goto yy2; } yy9: YYSKIP (); yych = YYPEEK (); - yyctx0 = yyctx0p3 = YYDIST(); switch (yych) { case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '3': + yyctx0p3 = YYDIST(); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = YYDIST(); + goto yy13; + default: + yyctx0 = yyctx0p3 = YYDIST(); + goto yy2; } yy11: YYSKIP (); yych = YYPEEK (); - yyctx0 = YYDIST(); switch (yych) { case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '4': + yyctx0 = YYDIST(); + goto yy13; + default: + yyctx0 = YYDIST(); + goto yy2; } yy13: YYSKIP (); diff --git a/re2c/test/contexts/fix3_trail.i--contexts.c b/re2c/test/contexts/fix3_trail.i--contexts.c index 2cc5c548..0e81aa66 100644 --- a/re2c/test/contexts/fix3_trail.i--contexts.c +++ b/re2c/test/contexts/fix3_trail.i--contexts.c @@ -15,13 +15,20 @@ static void lex(const char *YYCURSOR) long yyctx0p3; YYCTXMARKER = YYCURSOR; yych = *YYCURSOR; - yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '0': goto yy5; - case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; + case '1': + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy7; + case '2': + yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy13; default: goto yy3; } yy2: @@ -41,44 +48,68 @@ yy3: yy5: ++YYCURSOR; yych = *YYCURSOR; - yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '0': goto yy5; - case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '1': + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy7; + case '2': + yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0 = yyctx0p3 = yyctx0p2 = yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy7: ++YYCURSOR; yych = *YYCURSOR; - yyctx0 = yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '1': goto yy7; - case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '2': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '3': + yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0 = yyctx0p3 = yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy9: ++YYCURSOR; yych = *YYCURSOR; - yyctx0 = yyctx0p3 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '2': goto yy9; - case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '3': + yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy11; + case '4': + yyctx0 = yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0 = yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy11: ++YYCURSOR; yych = *YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '3': goto yy11; - case '4': goto yy13; - default: goto yy2; + case '4': + yyctx0 = (YYCURSOR - YYCTXMARKER); + goto yy13; + default: + yyctx0 = (YYCURSOR - YYCTXMARKER); + goto yy2; } yy13: ++YYCURSOR; diff --git a/re2c/test/contexts/fix4.i--contexts.c b/re2c/test/contexts/fix4.i--contexts.c index d6273511..2d46e396 100644 --- a/re2c/test/contexts/fix4.i--contexts.c +++ b/re2c/test/contexts/fix4.i--contexts.c @@ -23,16 +23,18 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - yyctx0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '1': - case '2': goto yy6; + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; + case '2': + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy8; default: goto yy3; } yy5: ++YYCURSOR; yych = *YYCURSOR; -yy6: switch (yych) { case '1': goto yy5; case '2': goto yy8; @@ -43,12 +45,18 @@ yy7: goto yy3; yy8: yych = *++YYCURSOR; - yyctx0p3 = (YYCURSOR - YYCTXMARKER); - goto yy10; + switch (yych) { + case '3': + yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '4': + yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy11; + default: goto yy7; + } yy9: ++YYCURSOR; yych = *YYCURSOR; -yy10: switch (yych) { case '3': goto yy9; case '4': goto yy11; diff --git a/re2c/test/contexts/fix4_trail.i--contexts--input(custom).c b/re2c/test/contexts/fix4_trail.i--contexts--input(custom).c index 1e649a20..15150e97 100644 --- a/re2c/test/contexts/fix4_trail.i--contexts--input(custom).c +++ b/re2c/test/contexts/fix4_trail.i--contexts--input(custom).c @@ -25,16 +25,18 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - yyctx0p1 = YYDIST(); switch (yych) { case '1': - case '2': goto yy6; + yyctx0p1 = YYDIST(); + goto yy5; + case '2': + yyctx0p1 = YYDIST(); + goto yy8; default: goto yy3; } yy5: YYSKIP (); yych = YYPEEK (); -yy6: switch (yych) { case '1': goto yy5; case '2': goto yy8; @@ -46,12 +48,18 @@ yy7: yy8: YYSKIP (); yych = YYPEEK (); - yyctx0p3 = YYDIST(); - goto yy10; + switch (yych) { + case '3': + yyctx0p3 = YYDIST(); + goto yy9; + case '4': + yyctx0p3 = YYDIST(); + goto yy11; + default: goto yy7; + } yy9: YYSKIP (); yych = YYPEEK (); -yy10: switch (yych) { case '3': goto yy9; case '4': goto yy11; diff --git a/re2c/test/contexts/fix4_trail.i--contexts.c b/re2c/test/contexts/fix4_trail.i--contexts.c index 20ab25ac..f57b8ce1 100644 --- a/re2c/test/contexts/fix4_trail.i--contexts.c +++ b/re2c/test/contexts/fix4_trail.i--contexts.c @@ -23,16 +23,18 @@ yy3: { printf("error\n"); return; } yy4: yych = *(YYMARKER = ++YYCURSOR); - yyctx0p1 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '1': - case '2': goto yy6; + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy5; + case '2': + yyctx0p1 = (YYCURSOR - YYCTXMARKER); + goto yy8; default: goto yy3; } yy5: ++YYCURSOR; yych = *YYCURSOR; -yy6: switch (yych) { case '1': goto yy5; case '2': goto yy8; @@ -43,12 +45,18 @@ yy7: goto yy3; yy8: yych = *++YYCURSOR; - yyctx0p3 = (YYCURSOR - YYCTXMARKER); - goto yy10; + switch (yych) { + case '3': + yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy9; + case '4': + yyctx0p3 = (YYCURSOR - YYCTXMARKER); + goto yy11; + default: goto yy7; + } yy9: ++YYCURSOR; yych = *YYCURSOR; -yy10: switch (yych) { case '3': goto yy9; case '4': goto yy11; diff --git a/re2c/test/contexts/fix5.i--contexts.c b/re2c/test/contexts/fix5.i--contexts.c index d0315145..d3c157ac 100644 --- a/re2c/test/contexts/fix5.i--contexts.c +++ b/re2c/test/contexts/fix5.i--contexts.c @@ -31,10 +31,13 @@ yy4: } yy5: yych = *(YYMARKER = ++YYCURSOR); - yyctx0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '2': - case '3': goto yy11; + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; + case '3': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy12; default: goto yy3; } yy6: @@ -51,12 +54,18 @@ yy8: goto yy3; yy9: yych = *++YYCURSOR; - yyctx0p2 = (YYCURSOR - YYCTXMARKER); - goto yy11; + switch (yych) { + case '2': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; + case '3': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy12; + default: goto yy8; + } yy10: ++YYCURSOR; yych = *YYCURSOR; -yy11: switch (yych) { case '2': goto yy10; case '3': goto yy12; diff --git a/re2c/test/contexts/fix5_trail.i--contexts--input(custom).c b/re2c/test/contexts/fix5_trail.i--contexts--input(custom).c index d4880679..88c385a5 100644 --- a/re2c/test/contexts/fix5_trail.i--contexts--input(custom).c +++ b/re2c/test/contexts/fix5_trail.i--contexts--input(custom).c @@ -35,10 +35,13 @@ yy5: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - yyctx0p2 = YYDIST(); switch (yych) { case '2': - case '3': goto yy11; + yyctx0p2 = YYDIST(); + goto yy10; + case '3': + yyctx0p2 = YYDIST(); + goto yy12; default: goto yy3; } yy6: @@ -56,12 +59,18 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - yyctx0p2 = YYDIST(); - goto yy11; + switch (yych) { + case '2': + yyctx0p2 = YYDIST(); + goto yy10; + case '3': + yyctx0p2 = YYDIST(); + goto yy12; + default: goto yy8; + } yy10: YYSKIP (); yych = YYPEEK (); -yy11: switch (yych) { case '2': goto yy10; case '3': goto yy12; diff --git a/re2c/test/contexts/fix5_trail.i--contexts.c b/re2c/test/contexts/fix5_trail.i--contexts.c index eb372d70..1d346915 100644 --- a/re2c/test/contexts/fix5_trail.i--contexts.c +++ b/re2c/test/contexts/fix5_trail.i--contexts.c @@ -31,10 +31,13 @@ yy4: } yy5: yych = *(YYMARKER = ++YYCURSOR); - yyctx0p2 = (YYCURSOR - YYCTXMARKER); switch (yych) { case '2': - case '3': goto yy11; + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; + case '3': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy12; default: goto yy3; } yy6: @@ -51,12 +54,18 @@ yy8: goto yy3; yy9: yych = *++YYCURSOR; - yyctx0p2 = (YYCURSOR - YYCTXMARKER); - goto yy11; + switch (yych) { + case '2': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy10; + case '3': + yyctx0p2 = (YYCURSOR - YYCTXMARKER); + goto yy12; + default: goto yy8; + } yy10: ++YYCURSOR; yych = *YYCURSOR; -yy11: switch (yych) { case '2': goto yy10; case '3': goto yy12; diff --git a/re2c/test/contexts/overlap.i--input(custom).c b/re2c/test/contexts/overlap.i--input(custom).c index 4fb716a4..bb596524 100644 --- a/re2c/test/contexts/overlap.i--input(custom).c +++ b/re2c/test/contexts/overlap.i--input(custom).c @@ -2,9 +2,6 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; - YYBACKUPCTX (); if (YYLESSTHAN (3)) YYFILL(3); yych = YYPEEK (); switch (yych) { @@ -16,24 +13,27 @@ yy2: {} yy4: YYSKIP (); - yyctx1 = YYDIST(); + YYBACKUPCTX (); switch ((yych = YYPEEK ())) { case 'b': goto yy6; default: goto yy5; } yy5: - YYRESTORECTX (yyctx1); + YYRESTORECTX (); {} yy6: YYSKIP (); - yyctx0 = YYDIST(); switch ((yych = YYPEEK ())) { case 'b': goto yy8; - case 'c': goto yy10; - default: goto yy7; + case 'c': + YYBACKUPCTX (); + goto yy10; + default: + YYBACKUPCTX (); + goto yy7; } yy7: - YYRESTORECTX (yyctx0); + YYRESTORECTX (); {} yy8: YYSKIP (); diff --git a/re2c/test/contexts/overlap.i.c b/re2c/test/contexts/overlap.i.c index 11440770..8ae0b146 100644 --- a/re2c/test/contexts/overlap.i.c +++ b/re2c/test/contexts/overlap.i.c @@ -2,9 +2,6 @@ { YYCTYPE yych; - long yyctx0; - long yyctx1; - YYCTXMARKER = YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch (yych) { @@ -16,24 +13,27 @@ yy2: {} yy4: ++YYCURSOR; - yyctx1 = (YYCURSOR - YYCTXMARKER); + YYCTXMARKER = YYCURSOR; switch ((yych = *YYCURSOR)) { case 'b': goto yy6; default: goto yy5; } yy5: - YYCURSOR = YYCTXMARKER + yyctx1; + YYCURSOR = YYCTXMARKER; {} yy6: ++YYCURSOR; - yyctx0 = (YYCURSOR - YYCTXMARKER); switch ((yych = *YYCURSOR)) { case 'b': goto yy8; - case 'c': goto yy10; - default: goto yy7; + case 'c': + YYCTXMARKER = YYCURSOR; + goto yy10; + default: + YYCTXMARKER = YYCURSOR; + goto yy7; } yy7: - YYCURSOR = YYCTXMARKER + yyctx0; + YYCURSOR = YYCTXMARKER; {} yy8: ++YYCURSOR; diff --git a/re2c/test/contexts/selfoverlap1_trail.i.c b/re2c/test/contexts/selfoverlap1_trail.i.c index 9aa2e886..5d910e1d 100644 --- a/re2c/test/contexts/selfoverlap1_trail.i.c +++ b/re2c/test/contexts/selfoverlap1_trail.i.c @@ -20,17 +20,19 @@ yy3: { printf("error\n"); return; } yy4: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; switch (yych) { - case 'a': goto yy5; + case 'a': + YYCTXMARKER = YYCURSOR; + goto yy5; default: goto yy3; } yy5: ++YYCURSOR; yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; switch (yych) { - case 'a': goto yy5; + case 'a': + YYCTXMARKER = YYCURSOR; + goto yy5; default: goto yy7; } yy7: diff --git a/re2c/test/contexts/yyaccept1.i.c b/re2c/test/contexts/yyaccept1.i.c new file mode 100644 index 00000000..a072e678 --- /dev/null +++ b/re2c/test/contexts/yyaccept1.i.c @@ -0,0 +1,63 @@ +/* Generated by re2c */ +// Normally re2c generates one 'yyaccept' value for each rule +// that is shadowed by a longer rule. +// However, if two different accepting states accept the same +// rule, but their epsilon-transitions to this rule have +// different sets of tags, re2c should split 'yyaccept' value. + + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); + yych = *YYCURSOR; + switch (yych) { + case 'a': goto yy4; + default: goto yy2; + } +yy2: + ++YYCURSOR; + {} +yy4: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + YYCTXMARKER = YYCURSOR; + switch (yych) { + case 'b': goto yy6; + default: goto yy5; + } +yy5: + YYCURSOR = YYCTXMARKER; + {} +yy6: + yych = *++YYCURSOR; + switch (yych) { + case 'c': goto yy8; + default: goto yy7; + } +yy7: + YYCURSOR = YYMARKER; + if (yyaccept == 0) { + YYCTXMARKER = YYCURSOR; + goto yy5; + } else { + goto yy5; + } +yy8: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'd': goto yy9; + default: goto yy5; + } +yy9: + yych = *++YYCURSOR; + switch (yych) { + case 'e': goto yy10; + default: goto yy7; + } +yy10: + ++YYCURSOR; + {} +} + diff --git a/re2c/test/contexts/yyaccept1.i.re b/re2c/test/contexts/yyaccept1.i.re new file mode 100644 index 00000000..ed7a9f0a --- /dev/null +++ b/re2c/test/contexts/yyaccept1.i.re @@ -0,0 +1,11 @@ +// Normally re2c generates one 'yyaccept' value for each rule +// that is shadowed by a longer rule. +// However, if two different accepting states accept the same +// rule, but their epsilon-transitions to this rule have +// different sets of tags, re2c should split 'yyaccept' value. + +/*!re2c + "a" / "bc"? {} + "abcde" {} + * {} +*/ diff --git a/re2c/test/ctx.--skeleton.c b/re2c/test/ctx.--skeleton.c index e5e45dffaf191898e84e3e8f4ccbe9c3d6c92bb4..03c9598abd3029c1b0c12e60f1c5c3bc06fdf00b 100644 GIT binary patch delta 40 vcmcaLov~*Ik~LI#!qJ@^iu delta 30 mcmeB~!FX#r= ':') goto yy3; + YYCTXMARKER = YYCURSOR; yy10: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -140,7 +143,7 @@ yy12: YYCURSOR = YYCTXMARKER; #line 49 "ctx.b.re" { return KEYWORD; } -#line 144 "ctx.b.c" +#line 147 "ctx.b.c" yy13: ++YYCURSOR; if ((yych = *YYCURSOR) <= '/') goto yy14; @@ -149,7 +152,7 @@ yy14: YYCURSOR -= 1; #line 48 "ctx.b.re" { return KEYWORD; } -#line 153 "ctx.b.c" +#line 156 "ctx.b.c" } #line 63 "ctx.b.re" diff --git a/re2c/test/ctx.c b/re2c/test/ctx.c index 098ef334..fba78fe5 100644 --- a/re2c/test/ctx.c +++ b/re2c/test/ctx.c @@ -110,7 +110,6 @@ yy8: #line 111 "ctx.c" yy9: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; switch (yych) { case '0': case '2': @@ -120,8 +119,12 @@ yy9: case '6': case '7': case '8': - case '9': goto yy10; - case '1': goto yy13; + case '9': + YYCTXMARKER = YYCURSOR; + goto yy10; + case '1': + YYCTXMARKER = YYCURSOR; + goto yy13; default: goto yy3; } yy10: @@ -145,7 +148,7 @@ yy12: YYCURSOR = YYCTXMARKER; #line 49 "ctx.re" { return KEYWORD; } -#line 149 "ctx.c" +#line 152 "ctx.c" yy13: ++YYCURSOR; switch ((yych = *YYCURSOR)) { @@ -165,7 +168,7 @@ yy14: YYCURSOR -= 1; #line 48 "ctx.re" { return KEYWORD; } -#line 169 "ctx.c" +#line 172 "ctx.c" } #line 63 "ctx.re" diff --git a/re2c/test/ctx.s.c b/re2c/test/ctx.s.c index 1b9dd285..4a8707f7 100644 --- a/re2c/test/ctx.s.c +++ b/re2c/test/ctx.s.c @@ -93,10 +93,13 @@ yy8: #line 94 "ctx.s.c" yy9: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych <= '/') goto yy3; - if (yych == '1') goto yy13; + if (yych == '1') { + YYCTXMARKER = YYCURSOR; + goto yy13; + } if (yych >= ':') goto yy3; + YYCTXMARKER = YYCURSOR; yy10: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -107,7 +110,7 @@ yy12: YYCURSOR = YYCTXMARKER; #line 49 "ctx.s.re" { return KEYWORD; } -#line 111 "ctx.s.c" +#line 114 "ctx.s.c" yy13: ++YYCURSOR; if ((yych = *YYCURSOR) <= '/') goto yy14; @@ -116,7 +119,7 @@ yy14: YYCURSOR -= 1; #line 48 "ctx.s.re" { return KEYWORD; } -#line 120 "ctx.s.c" +#line 123 "ctx.s.c" } #line 63 "ctx.s.re" diff --git a/re2c/test/input_custom_default.--input(custom).c b/re2c/test/input_custom_default.--input(custom).c index d1e1bc9c..076118ac 100644 --- a/re2c/test/input_custom_default.--input(custom).c +++ b/re2c/test/input_custom_default.--input(custom).c @@ -106,9 +106,10 @@ yy14: yy15: YYSKIP (); yych = YYPEEK (); - YYBACKUPCTX (); switch (yych) { - case '[': goto yy16; + case '[': + YYBACKUPCTX (); + goto yy16; default: goto yy6; } yy16: @@ -150,7 +151,7 @@ yy19: YYRESTORECTX (); #line 15 "input_custom_default.--input(custom).re" { return true; } -#line 154 "input_custom_default.--input(custom).c" +#line 155 "input_custom_default.--input(custom).c" } #line 17 "input_custom_default.--input(custom).re" diff --git a/re2c/test/input_custom_default.--skeleton--input(custom).c b/re2c/test/input_custom_default.--skeleton--input(custom).c index c85e3d0dae607f03deb05c6507cfba195090a054..01e70e835a1835dc33c1026c0d6e4213ca74655b 100644 GIT binary patch delta 31 mcmaF$kLmkArVU1-lOOQQaYUoVN3ex}p delta 26 icmZqv&-Cpd(*`@y$vXTTlS@PeCfkWBZf+6%zY+kGmI`|S diff --git a/re2c/test/rexx.--skeleton.c b/re2c/test/rexx.--skeleton.c index 6063f5a0..cd599969 100644 --- a/re2c/test/rexx.--skeleton.c +++ b/re2c/test/rexx.--skeleton.c @@ -1992,7 +1992,6 @@ yy171: yy173: YYSKIP (); yych = YYPEEK (); - YYBACKUPCTX (); switch (yych) { case '!': case '.': @@ -2060,12 +2059,13 @@ yy173: case 'x': case 'y': case 'z': goto yy72; - default: goto yy248; + default: + YYBACKUPCTX (); + goto yy248; } yy174: YYSKIP (); yych = YYPEEK (); - YYBACKUPCTX (); switch (yych) { case '!': case '.': @@ -2133,7 +2133,9 @@ yy174: case 'x': case 'y': case 'z': goto yy72; - default: goto yy250; + default: + YYBACKUPCTX (); + goto yy250; } yy175: YYSKIP (); @@ -7128,13 +7130,16 @@ int lex_line290() if (YYLESSTHAN (2)) YYFILL(2); yych = YYPEEK (); - YYBACKUPCTX (); switch (yych) { case '\t': case ' ': goto yy427; case '\r': goto yy429; - case '/': goto yy431; - default: goto yy425; + case '/': + YYBACKUPCTX (); + goto yy431; + default: + YYBACKUPCTX (); + goto yy425; } yy425: YYSKIP (); diff --git a/re2c/test/scanner_re2c.bi.c b/re2c/test/scanner_re2c.bi.c index d960fd31..753f061f 100644 --- a/re2c/test/scanner_re2c.bi.c +++ b/re2c/test/scanner_re2c.bi.c @@ -365,7 +365,6 @@ yy49: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy50: if (yych <= 0x1F) { if (yych == '\t') goto yy49; @@ -373,7 +372,10 @@ yy50: } else { if (yych <= ' ') goto yy49; if (yych <= '0') goto yy13; - if (yych <= '9') goto yy57; + if (yych <= '9') { + YYCTXMARKER = YYCURSOR; + goto yy57; + } goto yy13; } yy51: @@ -891,7 +893,6 @@ yy135: goto yy126; yy136: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; goto yy174; yy137: yyaccept = 4; @@ -905,7 +906,6 @@ yy138: } yy139: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == 'e') goto yy182; goto yy174; yy140: @@ -1076,8 +1076,35 @@ yy165: } yy167: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; - goto yy194; + if (yych <= '9') { + if (yych <= '\t') { + if (yych <= 0x08) goto yy144; + YYCTXMARKER = YYCURSOR; + goto yy193; + } else { + if (yych == ' ') { + YYCTXMARKER = YYCURSOR; + goto yy193; + } + goto yy144; + } + } else { + if (yych <= '=') { + if (yych <= ':') { + YYCTXMARKER = YYCURSOR; + goto yy195; + } + if (yych <= '<') goto yy144; + YYCTXMARKER = YYCURSOR; + goto yy196; + } else { + if (yych == '{') { + YYCTXMARKER = YYCURSOR; + goto yy197; + } + goto yy144; + } + } yy168: ++YYCURSOR; yy169: @@ -1116,22 +1143,29 @@ yy173: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy174: if (yybm[0+yych] & 32) { goto yy173; } if (yych <= ' ') { - if (yych == '\t') goto yy170; + if (yych == '\t') { + YYCTXMARKER = YYCURSOR; + goto yy170; + } if (yych <= 0x1F) goto yy168; + YYCTXMARKER = YYCURSOR; goto yy170; } else { if (yych <= ',') { if (yych <= '+') goto yy168; + YYCTXMARKER = YYCURSOR; goto yy171; } else { if (yych <= '<') goto yy168; - if (yych <= '>') goto yy171; + if (yych <= '>') { + YYCTXMARKER = YYCURSOR; + goto yy171; + } goto yy168; } } @@ -1171,7 +1205,6 @@ yy180: } yy182: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == '2') goto yy206; goto yy174; yy183: @@ -1231,7 +1264,6 @@ yy193: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; -yy194: if (yych <= '9') { if (yych <= '\t') { if (yych <= 0x08) goto yy144; @@ -1305,7 +1337,6 @@ yy204: } yy206: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == 'c') goto yy214; goto yy174; yy207: @@ -1345,7 +1376,6 @@ yy213: goto yy144; yy214: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == ':') goto yy222; goto yy174; yy215: @@ -1429,7 +1459,6 @@ yy229: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy230: if (yych <= 0x1F) { if (yych == '\t') goto yy229; @@ -1437,7 +1466,10 @@ yy230: } else { if (yych <= ' ') goto yy229; if (yych <= '0') goto yy144; - if (yych <= '9') goto yy233; + if (yych <= '9') { + YYCTXMARKER = YYCURSOR; + goto yy233; + } goto yy144; } yy231: @@ -1813,7 +1845,6 @@ yy278: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy279: if (yych <= 0x1F) { if (yych == '\t') goto yy278; @@ -1822,6 +1853,7 @@ yy279: if (yych <= ' ') goto yy278; if (yych <= '0') goto yy265; if (yych >= ':') goto yy265; + YYCTXMARKER = YYCURSOR; } yy280: ++YYCURSOR; @@ -2024,7 +2056,6 @@ yy312: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy313: if (yych <= 0x1F) { if (yych == '\t') goto yy312; @@ -2033,6 +2064,7 @@ yy313: if (yych <= ' ') goto yy312; if (yych <= '0') goto yy301; if (yych >= ':') goto yy301; + YYCTXMARKER = YYCURSOR; } yy314: ++YYCURSOR; diff --git a/re2c/test/scanner_re2c_default.--emit-dot.c b/re2c/test/scanner_re2c_default.--emit-dot.c index 57ffc665..14a3c09f 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]"] @@ -326,7 +326,11 @@ digraph re2c { 164 [label="scanner_re2c_default.--emit-dot.re:258"] 165 -> 166 166 [label="scanner_re2c_default.--emit-dot.re:331"] -167 -> 194 +167 -> 144 [label="[0x00-0x08][0x0A-0x1F][!-9][;-<][>-z][|-0xFF]"] +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 @@ -334,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]"] @@ -433,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]"] @@ -534,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][ ]"] @@ -599,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/scanner_re2c_default.bi.c b/re2c/test/scanner_re2c_default.bi.c index 38f22a0c..3615b13f 100644 --- a/re2c/test/scanner_re2c_default.bi.c +++ b/re2c/test/scanner_re2c_default.bi.c @@ -365,7 +365,6 @@ yy49: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy50: if (yych <= 0x1F) { if (yych == '\t') goto yy49; @@ -373,7 +372,10 @@ yy50: } else { if (yych <= ' ') goto yy49; if (yych <= '0') goto yy13; - if (yych <= '9') goto yy57; + if (yych <= '9') { + YYCTXMARKER = YYCURSOR; + goto yy57; + } goto yy13; } yy51: @@ -891,7 +893,6 @@ yy135: goto yy126; yy136: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; goto yy174; yy137: yyaccept = 4; @@ -905,7 +906,6 @@ yy138: } yy139: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == 'e') goto yy182; goto yy174; yy140: @@ -1076,8 +1076,35 @@ yy165: } yy167: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; - goto yy194; + if (yych <= '9') { + if (yych <= '\t') { + if (yych <= 0x08) goto yy144; + YYCTXMARKER = YYCURSOR; + goto yy193; + } else { + if (yych == ' ') { + YYCTXMARKER = YYCURSOR; + goto yy193; + } + goto yy144; + } + } else { + if (yych <= '=') { + if (yych <= ':') { + YYCTXMARKER = YYCURSOR; + goto yy195; + } + if (yych <= '<') goto yy144; + YYCTXMARKER = YYCURSOR; + goto yy196; + } else { + if (yych == '{') { + YYCTXMARKER = YYCURSOR; + goto yy197; + } + goto yy144; + } + } yy168: ++YYCURSOR; yy169: @@ -1116,22 +1143,29 @@ yy173: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy174: if (yybm[0+yych] & 32) { goto yy173; } if (yych <= ' ') { - if (yych == '\t') goto yy170; + if (yych == '\t') { + YYCTXMARKER = YYCURSOR; + goto yy170; + } if (yych <= 0x1F) goto yy168; + YYCTXMARKER = YYCURSOR; goto yy170; } else { if (yych <= ',') { if (yych <= '+') goto yy168; + YYCTXMARKER = YYCURSOR; goto yy171; } else { if (yych <= '<') goto yy168; - if (yych <= '>') goto yy171; + if (yych <= '>') { + YYCTXMARKER = YYCURSOR; + goto yy171; + } goto yy168; } } @@ -1171,7 +1205,6 @@ yy180: } yy182: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == '2') goto yy206; goto yy174; yy183: @@ -1231,7 +1264,6 @@ yy193: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; -yy194: if (yych <= '9') { if (yych <= '\t') { if (yych <= 0x08) goto yy144; @@ -1305,7 +1337,6 @@ yy204: } yy206: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == 'c') goto yy214; goto yy174; yy207: @@ -1345,7 +1376,6 @@ yy213: goto yy144; yy214: yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; if (yych == ':') goto yy222; goto yy174; yy215: @@ -1429,7 +1459,6 @@ yy229: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy230: if (yych <= 0x1F) { if (yych == '\t') goto yy229; @@ -1437,7 +1466,10 @@ yy230: } else { if (yych <= ' ') goto yy229; if (yych <= '0') goto yy144; - if (yych <= '9') goto yy233; + if (yych <= '9') { + YYCTXMARKER = YYCURSOR; + goto yy233; + } goto yy144; } yy231: @@ -1819,7 +1851,6 @@ yy280: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy281: if (yych <= 0x1F) { if (yych == '\t') goto yy280; @@ -1828,6 +1859,7 @@ yy281: if (yych <= ' ') goto yy280; if (yych <= '0') goto yy265; if (yych >= ':') goto yy265; + YYCTXMARKER = YYCURSOR; } yy282: ++YYCURSOR; @@ -2030,7 +2062,6 @@ yy314: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYCTXMARKER = YYCURSOR; yy315: if (yych <= 0x1F) { if (yych == '\t') goto yy314; @@ -2039,6 +2070,7 @@ yy315: if (yych <= ' ') goto yy314; if (yych <= '0') goto yy303; if (yych >= ':') goto yy303; + YYCTXMARKER = YYCURSOR; } yy316: ++YYCURSOR; diff --git a/re2c/test/strip_003.b--skeleton.c b/re2c/test/strip_003.b--skeleton.c index 18639ed7..414efe66 100644 --- a/re2c/test/strip_003.b--skeleton.c +++ b/re2c/test/strip_003.b--skeleton.c @@ -164,8 +164,10 @@ yy4: YYSKIP (); YYBACKUP (); yych = YYPEEK (); - YYBACKUPCTX (); - if (yych == '/') goto yy7; + if (yych == '/') { + YYBACKUPCTX (); + goto yy7; + } goto yy3; yy5: YYSKIP (); @@ -189,8 +191,10 @@ yy8: yy9: YYSKIP (); yych = YYPEEK (); - YYBACKUPCTX (); - if (yych == '/') goto yy7; + if (yych == '/') { + YYBACKUPCTX (); + goto yy7; + } goto yy8; yy10: YYSKIP (); -- 2.40.0