From 152335e2672e00cc3afbe7a4aabd6604ce88b273 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 26 Oct 2019 19:47:22 +0000 Subject: [PATCH] Fix error converting NFA to DFA I didn't handle epsilon transitions correctly, now I hopefully do. --- src/Rextra/Automaton.hs | 2 +- src/Rextra/Nfa.hs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Rextra/Automaton.hs b/src/Rextra/Automaton.hs index 64005c9..fabd9dc 100644 --- a/src/Rextra/Automaton.hs +++ b/src/Rextra/Automaton.hs @@ -64,7 +64,7 @@ allNextStates s = ndStateToDfaState :: (Ord s, Ord t) => Nfa.Nfa s t -> Nfa.NdState s -> Dfa.State (Nfa.NdState s) t ndStateToDfaState nfa ns = - let specialTokens = allSpecialTokens $ Nfa.getNdState nfa ns + let specialTokens = allSpecialTokens . Nfa.getNdState nfa $ Nfa.epsilonStep nfa ns in Dfa.State { Dfa.transitions = Map.fromSet (\t -> Nfa.transition nfa t ns) specialTokens , Dfa.defaultTransition = Nfa.defaultTransition nfa ns , Dfa.accepting = Nfa.accepting nfa ns diff --git a/src/Rextra/Nfa.hs b/src/Rextra/Nfa.hs index 9649135..1cecf91 100644 --- a/src/Rextra/Nfa.hs +++ b/src/Rextra/Nfa.hs @@ -21,6 +21,7 @@ module Rextra.Nfa ( , NdState , getNdState -- *** Transitions + , epsilonStep , transition , defaultTransition -- *** Running the whole automaton