Serialisation/deserialisation of FSM
s and
Action
s as adjacency matrices.
An Action
may be represented as an adjacency matrix of
0s and 1s. The rows and columns of the matrix correspond to states of
the Data.FA.Core.FSM
: a 1 in a cell indicates that the
Action
causes a transition from the 'row' state to
the 'column' state. If any of the rows in the matrix contain more
than one 1, the corresponding Action
is a
nondeterministic: an Data.FsmActions.NAction
.
- readFSMFromMxFiles :: Ord sy => [(sy, String)] -> IO (FSM sy)
- readAdjMxFromFile :: String -> IO Action
- readAdjMxFromString :: ByteString -> ReadMxMonad Action
Documentation
readFSMFromMxFiles :: Ord sy => [(sy, String)] -> IO (FSM sy)Source
Given a list of (symbol, path) pairs, compute an
FSM
whose actions are read from matrices in each of
the paths using readAdjMxFromFile
(and associated with their
corresponding symbols).
Note that if the same symbol appears multiple times, only one
instance will appear in the FSM
; the choice of which
appears is not defined.
readFSMFromMxFiles :: Ord sy => [(sy, String)] -> IO (FSM sy)
readAdjMxFromFile :: String -> IO ActionSource
Read an action matrix from a specified file; uses
readAdjMxFromString
to interpret the file contents.
readAdjMxFromString :: ByteString -> ReadMxMonad ActionSource
Given a bytestring we expect to contain a serialisation of an
adjacency matrix, compute the corresponding Action
.
The serialisation format for an Action
on an
n-state FSM
is as follows: there are n
(newline-separated) lines, each containing n (comma-separated) 0s
or 1s. No other characters are allowed (not even whitespace), and
it is an error for any of the rows to contain anything other than
n cells. (Note that n is not specified, but inferred from the
number of lines in the string).