Changed all SRG printer to take Options and StateGrammar arguments. This makes Custom a lot cleaner.

This commit is contained in:
bringert
2007-01-05 15:38:47 +00:00
parent 741dde5a2a
commit 6ee7296f9d
10 changed files with 83 additions and 123 deletions

View File

@@ -24,6 +24,7 @@ module GF.Speech.TransformCFG {- (CFRule_, CFRules,
removeEmptyCats, removeIdenticalRules) -} where
import GF.Conversion.Types
import GF.CF.PPrCF (prCFCat)
import GF.Data.Utilities
import GF.Formalism.CFG
import GF.Formalism.Utilities (Symbol(..), mapSymbol, filterCats, symbol,
@@ -32,7 +33,7 @@ import GF.Infra.Ident
import GF.Infra.Option
import GF.Infra.Print
import GF.Speech.Relation
import GF.Compile.ShellState (StateGrammar, stateCFG)
import GF.Compile.ShellState (StateGrammar, stateCFG, startCatStateOpts)
import Control.Monad
import Control.Monad.State (State, get, put, evalState)
@@ -76,6 +77,13 @@ cfgToCFRules s =
profileToTerm (Unify xs) = CFRes (last xs) -- FIXME: unify
profileToTerm (Constant f) = maybe CFMeta (\x -> CFObj x []) (forestName f)
getStartCat :: Options -> StateGrammar -> String
getStartCat opts sgr = prCFCat (startCatStateOpts opts sgr)
getStartCatCF :: Options -> StateGrammar -> String
getStartCatCF opts sgr = getStartCat opts sgr ++ "{}.s"
-- | Remove productions which use categories which have no productions
removeEmptyCats :: CFRules -> CFRules
removeEmptyCats = fix removeEmptyCats'