summaryrefslogtreecommitdiff
path: root/src/GF/Speech/TransformCFG.hs
diff options
context:
space:
mode:
authorbringert <unknown>2005-06-17 11:46:04 +0000
committerbringert <unknown>2005-06-17 11:46:04 +0000
commit05b5ffe5bf03a870f6fe0728ace6c0d8de69b89e (patch)
tree18298275e8397f200013b6aec8ee38bbd93e32b1 /src/GF/Speech/TransformCFG.hs
parent30e3a8fd991c7bad3d21b03749d6a8a0e7a7f8e5 (diff)
Added beginnings of ATK SLF generation.
Diffstat (limited to 'src/GF/Speech/TransformCFG.hs')
-rw-r--r--src/GF/Speech/TransformCFG.hs29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/GF/Speech/TransformCFG.hs b/src/GF/Speech/TransformCFG.hs
index 71b3ca296..db9b009a6 100644
--- a/src/GF/Speech/TransformCFG.hs
+++ b/src/GF/Speech/TransformCFG.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/04/21 16:23:33 $
+-- > CVS $Date: 2005/06/17 12:46:05 $
-- > CVS $Author: bringert $
--- > CVS $Revision: 1.12 $
+-- > CVS $Revision: 1.13 $
--
-- This module does some useful transformations on CFGs.
--
@@ -16,7 +16,7 @@
-- peb thinks: most of this module should be moved to GF.Conversion...
-----------------------------------------------------------------------------
-module GF.Speech.TransformCFG (makeNice, CFRule_) where
+module GF.Speech.TransformCFG (makeNice, CFRule_, makeRegular) where
import GF.Infra.Ident
import GF.Formalism.CFG
@@ -37,6 +37,8 @@ type Cat_ = String
type CFRules = FiniteMap Cat_ [CFRule_]
+-- | Remove left-recursion and categories with no productions
+-- from a context-free grammar.
makeNice :: CGrammar -> [CFRule_]
makeNice = concat . eltsFM . makeNice' . groupProds . cfgToCFRules
where makeNice' = removeLeftRecursion . removeEmptyCats
@@ -94,6 +96,27 @@ isDirectLeftRecursive (CFRule c (Cat c':_) _) = c == c'
isDirectLeftRecursive _ = False
+-- Use the transformation algorithm from \"Regular Approximation of Context-free
+-- Grammars through Approximation\", Mohri and Nederhof, 2000
+-- to create an over-generating regular frammar for a context-free
+-- grammar
+makeRegular :: [CFRule_] -> [CFRule_]
+makeRegular = undefined
+
+{-
+isRightLinear :: [Cat_] -- ^ The categories to consider
+ -> CFRule_
+ -> Bool
+isRightLinear _ (CFRule _ ss _) | all isTerminal ss = True
+isRightLinear cs
+-}
+
+-- Use the strongly regular grammar to finite automaton
+-- compilation algorithm from \"Regular Approximation of Context-free
+-- Grammars through Approximation\", Mohri and Nederhof, 2000
+-- compileAutomaton ::
+
+
fix :: Eq a => (a -> a) -> a -> a
fix f x = let x' = f x in if x' == x then x else fix f x'