Fix error converting NFA to DFA
I didn't handle epsilon transitions correctly, now I hopefully do.
This commit is contained in:
parent
0082c427ed
commit
152335e267
2 changed files with 2 additions and 1 deletions
|
|
@ -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 :: (Ord s, Ord t) => Nfa.Nfa s t -> Nfa.NdState s -> Dfa.State (Nfa.NdState s) t
|
||||||
ndStateToDfaState nfa ns =
|
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
|
in Dfa.State { Dfa.transitions = Map.fromSet (\t -> Nfa.transition nfa t ns) specialTokens
|
||||||
, Dfa.defaultTransition = Nfa.defaultTransition nfa ns
|
, Dfa.defaultTransition = Nfa.defaultTransition nfa ns
|
||||||
, Dfa.accepting = Nfa.accepting nfa ns
|
, Dfa.accepting = Nfa.accepting nfa ns
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ module Rextra.Nfa (
|
||||||
, NdState
|
, NdState
|
||||||
, getNdState
|
, getNdState
|
||||||
-- *** Transitions
|
-- *** Transitions
|
||||||
|
, epsilonStep
|
||||||
, transition
|
, transition
|
||||||
, defaultTransition
|
, defaultTransition
|
||||||
-- *** Running the whole automaton
|
-- *** Running the whole automaton
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue