Visualize the automata using GraphViz
This commit is contained in:
parent
34a3a2027c
commit
10db66edc0
5 changed files with 98 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ module Rextra.Dfa (
|
|||
-- ** Properties
|
||||
, stateMap
|
||||
, entryState
|
||||
, exitStates
|
||||
-- ** Executing
|
||||
, transition
|
||||
, execute
|
||||
|
|
@ -34,6 +35,13 @@ data Dfa s t = Dfa
|
|||
getState :: (Ord s) => Dfa s t -> s -> State s t
|
||||
getState dfa s = stateMap dfa Map.! s
|
||||
|
||||
exitStates :: (Ord s) => Dfa s t -> Set.Set s
|
||||
exitStates dfa = Set.fromList
|
||||
. map fst
|
||||
. filter (accepting . snd)
|
||||
. Map.assocs
|
||||
$ stateMap dfa
|
||||
|
||||
data State s t = State
|
||||
{ transitions :: Map.Map t s
|
||||
, defaultTransition :: s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue