From: Ulya Trofimovich Date: Mon, 13 Feb 2017 21:00:49 +0000 (+0000) Subject: Don't trace tags in epcilon-cycles when building tagged epsilon-closure. X-Git-Tag: 1.0~39^2~127 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab269c6970bcd7bbfcda49a88b96b188959c1986;p=re2c Don't trace tags in epcilon-cycles when building tagged epsilon-closure. --- diff --git a/re2c/src/ir/dfa/closure.cc b/re2c/src/ir/dfa/closure.cc index f0b9fd0a..37d3acde 100644 --- a/re2c/src/ir/dfa/closure.cc +++ b/re2c/src/ir/dfa/closure.cc @@ -62,13 +62,9 @@ void closure(closure_t &clos1, closure_t &clos2, Tagpool &tagpool, void closure_one(closure_t &clos, Tagpool &tagpool, clos_t &c0, nfa_state_t *n, tagver_t *tags, closure_t *shadow) { - // trace the first iteration of each loop: - // epsilon-loops may add ney tags and reveal conflicts - if (n->loop > 1) { - return; - } + if (n->loop) return; - ++n->loop; + n->loop = true; switch (n->type) { case nfa_state_t::NIL: closure_one(clos, tagpool, c0, n->nil.out, tags, shadow); @@ -106,7 +102,7 @@ void closure_one(closure_t &clos, Tagpool &tagpool, clos_t &c0, break; } } - --n->loop; + n->loop = false; } /* diff --git a/re2c/src/ir/nfa/nfa.h b/re2c/src/ir/nfa/nfa.h index 8cb2e530..5b39c043 100644 --- a/re2c/src/ir/nfa/nfa.h +++ b/re2c/src/ir/nfa/nfa.h @@ -42,7 +42,7 @@ struct nfa_state_t } nil; }; size_t rule; - uint8_t loop; + bool loop; void make_alt(size_t r, nfa_state_t *s1, nfa_state_t *s2) { @@ -50,7 +50,7 @@ struct nfa_state_t alt.out1 = s1; alt.out2 = s2; rule = r; - loop = 0; + loop = false; } void make_ran(size_t r, nfa_state_t *s, const Range *p) { @@ -58,7 +58,7 @@ struct nfa_state_t ran.out = s; ran.ran = p; rule = r; - loop = 0; + loop = false; } void make_tag(size_t r, nfa_state_t *s, size_t i, bool bottom) { @@ -67,20 +67,20 @@ struct nfa_state_t tag.info = i; tag.bottom = bottom; rule = r; - loop = 0; + loop = false; } void make_fin(size_t r) { type = FIN; rule = r; - loop = 0; + loop = false; } void make_nil(size_t r, nfa_state_t *s) { type = NIL; nil.out = s; rule = r; - loop = 0; + loop = false; } }; diff --git a/re2c/test/tags/nondet_iter.--tags.c b/re2c/test/tags/nondet_iter.--tags.c index f3779a16..1321af70 100644 --- a/re2c/test/tags/nondet_iter.--tags.c +++ b/re2c/test/tags/nondet_iter.--tags.c @@ -10,7 +10,9 @@ case 'a': yyt1 = YYCURSOR; goto yy3; - case 'b': goto yy5; + case 'b': + yyt1 = YYCURSOR; + goto yy5; case 'c': yyt1 = YYCURSOR; goto yy8; @@ -25,7 +27,7 @@ yy2: a = yyt1; #line 2 "tags/nondet_iter.--tags.re" { @a } -#line 29 "tags/nondet_iter.--tags.c" +#line 31 "tags/nondet_iter.--tags.c" yy3: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -41,16 +43,16 @@ yy5: if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { - case 'b': goto yy5; - default: + case 'b': yyt1 = YYCURSOR; - goto yy7; + goto yy5; + default: goto yy7; } yy7: b = yyt1; #line 5 "tags/nondet_iter.--tags.re" { @b } -#line 54 "tags/nondet_iter.--tags.c" +#line 56 "tags/nondet_iter.--tags.c" yy8: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -65,7 +67,7 @@ yy10: c = yyt1; #line 8 "tags/nondet_iter.--tags.re" { @c } -#line 69 "tags/nondet_iter.--tags.c" +#line 71 "tags/nondet_iter.--tags.c" yy11: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -80,7 +82,7 @@ yy13: d = yyt1; #line 3 "tags/nondet_iter.--tags.re" { @d } -#line 84 "tags/nondet_iter.--tags.c" +#line 86 "tags/nondet_iter.--tags.c" yy14: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -95,7 +97,7 @@ yy16: e = yyt1; #line 6 "tags/nondet_iter.--tags.re" { @e } -#line 99 "tags/nondet_iter.--tags.c" +#line 101 "tags/nondet_iter.--tags.c" yy17: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -110,7 +112,7 @@ yy19: f = yyt1; #line 9 "tags/nondet_iter.--tags.re" { @f } -#line 114 "tags/nondet_iter.--tags.c" +#line 116 "tags/nondet_iter.--tags.c" } #line 10 "tags/nondet_iter.--tags.re"