From: Ulya Trofimovich Date: Tue, 4 Oct 2016 16:05:20 +0000 (+0100) Subject: Fixed tags comparison in table minimization. X-Git-Tag: 1.0~39^2~265 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71e94f3e4ebac528c7dd22e43121b8aac797cc02;p=re2c Fixed tags comparison in table minimization. Bug was introduced in commit 5958a2366cdb1361b5158076924014a36ff19dcc "Bind contexts (a.k.a. tags) to DFA transitions, not states.": instead of comparing tags of single transition on one particular symbol, we compared tags for all outgoing transitions at once (probably copy-paste from Moore minimization). The bug was revealed by multiple tests (including '--skeleton' ones) as soon as I ran testsute with '--dfa-determinization table'. --- diff --git a/re2c/src/ir/dfa/minimization.cc b/re2c/src/ir/dfa/minimization.cc index c742f786..2dcffcb6 100644 --- a/re2c/src/ir/dfa/minimization.cc +++ b/re2c/src/ir/dfa/minimization.cc @@ -67,11 +67,11 @@ static void minimization_table( { std::swap(oi, oj); } - if (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)) + if (states[i]->tags[k] != states[j]->tags[k] + || (oi != oj + && (oi == dfa_t::NIL + || oj == dfa_t::NIL + || tbl[oi][oj]))) { tbl[i][j] = true; loop = true; @@ -188,8 +188,10 @@ static void minimization_moore( if (memcmp(&out[j * nchars], &out[k * nchars], nchars * sizeof(size_t)) == 0 - && memcmp(states[j]->tags, states[k]->tags, nchars * sizeof(size_t)) == 0) - { + && memcmp(states[j]->tags, + states[k]->tags, + nchars * sizeof(size_t)) == 0 + ) { part[j] = k; next[j] = next[k]; next[k] = j;