ppRegExpFm
functor
signature PPREGEXPFM
functor ppRegExpFm
(LABEL) : PPREGEXPFM
This functor generates funtions that translate between regular expressions (without variables) and finite automata (without epsilon-transitions). Moreover, printing functions for regular expressions and displaying of finite automata are generated, using printnames as provided by the argument structure.
More detailed printing functions showing equivalence classes of states are contained in the substructure M.
structure E : PPREGEQNS
structure M : PPFM
sharing type M.label = E.alph
type ''a machine = ''a M.machine
type label = M.label
datatype re = datatype E.re
val printExp : label re -> unit
val accept : ''a machine -> ''a list -> bool
val display : label machine -> string -> OS.Process.status
val retofm : ''a re -> ''a machine
val retominfm : ''a re -> ''a machine
val fmtore : ''a machine -> ''a re
structure E : PPREGEQNS
structure M : PPFM
sharing type M.label = E.alph
type ''a machine = ''a M.machine
type label = M.label
datatype re = datatype E.re
printExp r
accept m l
display m s
retofm r
retominfm r
fmtore m
LABEL, PPREGEXP, PPFM
Example:
Translation from regular expressions (a+b)^*a(a+b)^n to finite machines; minimal deterministic version is exponential in n:
structure Tr = ppRegExpFm(StringLabels); val a = Tr.E.Atom "a" and b = Tr.E.Atom "b"; fun expr n = Tr.E.Times[Tr.E.Star(Tr.E.Plus[a,b]),a,Tr.E.Power (Tr.E.Plus[a,b]) n] and mach n = Tr.retominfm (expr n); Tr.display (mach 2) "testfile";