diff --git a/src/automata.cpp b/src/automata.cpp index 2f4406e..b0fbf9e 100644 --- a/src/automata.cpp +++ b/src/automata.cpp @@ -99,6 +99,7 @@ namespace lxs { std::set states; std::queue statequeue; statequeue.push(s); + states.insert(s); while(!statequeue.empty()) { auto state = statequeue.front(); statequeue.pop(); @@ -276,19 +277,22 @@ namespace lxs { return compress(d, reachable, dist); } - namespace { // Utility functions for mssc + namespace { // Utility function for mssc std::set getNextState(std::set oldstate, char symbol, const NFA& e) { std::set states; for(auto &state: oldstate) { - auto a = e.delta.find(state)->second; - auto newStates = a.find(symbol); - if(newStates != a.end()) { - for(auto &newstate:newStates->second) { - auto eclosestates = e.eClose(newstate); - for(auto &eclosestate:eclosestates) { - states.insert(eclosestate); - } + auto a = e.delta.find(state); + if(a != e.delta.end()) { + auto newStates = a->second.find(symbol); + if(newStates != a->second.end()) { + for(auto &newstate:newStates->second) { + auto eclosestates = e.eClose(newstate); + for(auto &eclosestate:eclosestates) { + states.insert(eclosestate); + } + } + } } } @@ -300,7 +304,6 @@ namespace lxs { DFA mssc(const NFA& e) { std::map,std::map > > dfa; - std::map > trans; for (int c = 0; c < 256; c++) { trans.insert(std::pair >(c,{(unsigned long long) -1}));