12 return std::lexicographical_compare(
a.begin(),
a.end(), b.begin(), b.end(), NFANode::Lt{});
40 auto dfa = std::make_unique<DFA>();
41 std::map<NFASet, DFANode*, NFASetLt> dfaStates;
42 std::queue<NFASet> stateQueue;
44 dfaStates.emplace(startState, dfa->add_state());
45 stateQueue.push(startState);
46 while (!stateQueue.empty()) {
47 auto currentState = stateQueue.front();
49 auto currentDfaState = dfaStates[currentState];
50 std::map<std::uint16_t, NFASet> nextStates;
52 for (
auto& nfaState : currentState) {
53 nfaState->for_transitions([&](
auto c,
auto to) {
55 nextStates[c].insert(to);
59 for (
auto& [c, tos] : nextStates) {
60 auto toStateClosure = epsilonClosure(tos);
61 auto [i, fresh] = dfaStates.try_emplace(toStateClosure);
63 i->second = dfa->add_state();
64 stateQueue.push(std::move(toStateClosure));
66 currentDfaState->add_transition(i->second, c);
69 dfa->set_start(dfaStates[startState]);
70 for (
auto& [state, dfaState] : dfaStates) {
71 for (
auto& nfaState : state) {
72 if (nfaState->is_accepting()) dfaState->set_accepting(
true);
73 if (nfaState->is_erroring()) {
74 dfaState->set_accepting(
false);
75 dfaState->set_erroring(
true);