Fix minimisation accepting state merging problem

This commit is contained in:
Robin Jadoul 2016-05-27 16:11:11 +02:00
parent a25476139d
commit d5a7832746
1 changed files with 7 additions and 17 deletions

View File

@ -140,6 +140,7 @@ namespace lxs {
rev.numStates = d.numStates;
rev.accepting = d.accepting;
rev.acceptingToken = d.acceptingToken;
rev.starting = 0;
for (const auto& stateTransPair : d.delta) {
@ -195,6 +196,9 @@ namespace lxs {
for (State b = a + 1; b < rev.numStates; b++) {
if (rev.accepting.count(a) != rev.accepting.count(b)) {
q.push(std::make_pair(a, b));
} else if (rev.accepting.count(a) && rev.acceptingToken[a] != rev.acceptingToken[b]) {
//Do not merge accepting states that define different tokens, guaranteed problems...
q.push(std::make_pair(a, b));
}
}
if (rev.accepting.count(a) != rev.accepting.count(deadState)) {
@ -236,13 +240,6 @@ namespace lxs {
if (reachables.count(a) == 0 || done.count(a) > 0) continue;
Priority prior;
std::string acTok;
if (d.accepting.count(a) > 0) {
prior = d.priority.find(a)->second;
acTok = d.acceptingToken.find(a)->second;
}
newStates[a] = cur;
if (a == deadState)
newStates[a] = deadState;
@ -258,14 +255,6 @@ namespace lxs {
newStates[b] = cur;
if (b == deadState)
newStates[b] = deadState;
if (d.accepting.count(b) > 0) {
Priority bprior = d.priority.find(b)->second;
if (bprior < prior) {
prior = bprior;
acTok = d.acceptingToken.find(b)->second;
}
}
}
if (b == deadState)
@ -274,9 +263,10 @@ namespace lxs {
}
if (d.accepting.count(a) > 0) {
//Since different accepting tokens should never be merged, there is no need to check the priorities
min.accepting.insert(cur);
min.priority[cur] = prior;
min.acceptingToken[cur] = acTok;
min.priority[cur] = d.priority.find(a)->second;
min.acceptingToken[cur] = d.acceptingToken.find(a)->second;
}
if (a != deadState) {