Fixed mssc
This commit is contained in:
parent
0f6742f005
commit
95f8b4dac1
|
@ -99,6 +99,7 @@ namespace lxs {
|
||||||
std::set<State> states;
|
std::set<State> states;
|
||||||
std::queue<State> statequeue;
|
std::queue<State> statequeue;
|
||||||
statequeue.push(s);
|
statequeue.push(s);
|
||||||
|
states.insert(s);
|
||||||
while(!statequeue.empty()) {
|
while(!statequeue.empty()) {
|
||||||
auto state = statequeue.front();
|
auto state = statequeue.front();
|
||||||
statequeue.pop();
|
statequeue.pop();
|
||||||
|
@ -276,19 +277,22 @@ namespace lxs {
|
||||||
return compress(d, reachable, dist);
|
return compress(d, reachable, dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace { // Utility functions for mssc
|
namespace { // Utility function for mssc
|
||||||
|
|
||||||
std::set<State> getNextState(std::set<State> oldstate, char symbol, const NFA& e) {
|
std::set<State> getNextState(std::set<State> oldstate, char symbol, const NFA& e) {
|
||||||
std::set<State> states;
|
std::set<State> states;
|
||||||
for(auto &state: oldstate) {
|
for(auto &state: oldstate) {
|
||||||
auto a = e.delta.find(state)->second;
|
auto a = e.delta.find(state);
|
||||||
auto newStates = a.find(symbol);
|
if(a != e.delta.end()) {
|
||||||
if(newStates != a.end()) {
|
auto newStates = a->second.find(symbol);
|
||||||
for(auto &newstate:newStates->second) {
|
if(newStates != a->second.end()) {
|
||||||
auto eclosestates = e.eClose(newstate);
|
for(auto &newstate:newStates->second) {
|
||||||
for(auto &eclosestate:eclosestates) {
|
auto eclosestates = e.eClose(newstate);
|
||||||
states.insert(eclosestate);
|
for(auto &eclosestate:eclosestates) {
|
||||||
}
|
states.insert(eclosestate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +304,6 @@ namespace lxs {
|
||||||
|
|
||||||
DFA mssc(const NFA& e) {
|
DFA mssc(const NFA& e) {
|
||||||
std::map<std::set<State>,std::map<char,std::set<State> > > dfa;
|
std::map<std::set<State>,std::map<char,std::set<State> > > dfa;
|
||||||
|
|
||||||
std::map<char, std::set<State> > trans;
|
std::map<char, std::set<State> > trans;
|
||||||
for (int c = 0; c < 256; c++) {
|
for (int c = 0; c < 256; c++) {
|
||||||
trans.insert(std::pair<char,std::set<State> >(c,{(unsigned long long) -1}));
|
trans.insert(std::pair<char,std::set<State> >(c,{(unsigned long long) -1}));
|
||||||
|
|
Loading…
Reference in New Issue