summaryrefslogtreecommitdiff
path: root/src/GF/Speech/CFGToFiniteState.hs
diff options
context:
space:
mode:
authorbringert <unknown>2005-09-14 15:08:35 +0000
committerbringert <unknown>2005-09-14 15:08:35 +0000
commitb109bcaafad0cdcadd38831799346257aae76c17 (patch)
tree703e1090e2917df0d4179e126fb862954424c711 /src/GF/Speech/CFGToFiniteState.hs
parent6381c27bff7aa11c50e2a7d78f44fbf40a79b33a (diff)
Parametrized the type of FAs over the state type.
Diffstat (limited to 'src/GF/Speech/CFGToFiniteState.hs')
-rw-r--r--src/GF/Speech/CFGToFiniteState.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/GF/Speech/CFGToFiniteState.hs b/src/GF/Speech/CFGToFiniteState.hs
index 1816e4502..73765aed0 100644
--- a/src/GF/Speech/CFGToFiniteState.hs
+++ b/src/GF/Speech/CFGToFiniteState.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/09/14 15:17:29 $
+-- > CVS $Date: 2005/09/14 16:08:35 $
-- > CVS $Author: bringert $
--- > CVS $Revision: 1.3 $
+-- > CVS $Revision: 1.4 $
--
-- Approximates CFGs with finite state networks.
-----------------------------------------------------------------------------
@@ -27,7 +27,7 @@ import GF.Speech.FiniteState
import GF.Speech.TransformCFG
cfgToFA :: Ident -- ^ Grammar name
- -> Options -> CGrammar -> FA () (Maybe String)
+ -> Options -> CGrammar -> NFA String
cfgToFA name opts = minimize . compileAutomaton start . makeSimpleRegular
where start = getStartCat opts
@@ -67,7 +67,7 @@ mutRecCats incAll g = equivalenceClasses $ symmetricSubrelation $ transitiveClos
-- Convert a strongly regular grammar to a finite automaton.
compileAutomaton :: Cat_ -- ^ Start category
-> CFRules
- -> FA () (Maybe Token)
+ -> NFA Token
compileAutomaton start g = make_fa s [Cat start] f fa''
where fa = newFA ()
s = startState fa
@@ -77,7 +77,7 @@ compileAutomaton start g = make_fa s [Cat start] f fa''
-- | The make_fa algorithm from \"Regular approximation of CFLs: a grammatical view\",
-- Mark-Jan Nederhof. International Workshop on Parsing Technologies, 1997.
make_fa :: State -> [Symbol Cat_ Token] -> State
- -> FA () (Maybe Token) -> FA () (Maybe Token)
+ -> NFA Token -> NFA Token
make_fa q0 alpha q1 fa =
case alpha of
[] -> newTransition q0 q1 Nothing fa