diff options
| author | peb <unknown> | 2005-04-18 13:55:32 +0000 |
|---|---|---|
| committer | peb <unknown> | 2005-04-18 13:55:32 +0000 |
| commit | c1592825c71867711a63293b588fcbc97e52bfc4 (patch) | |
| tree | 5b042471de94431e15f8fda2c6ff9a85bce99cef /src/GF/Conversion/MCFGtoCFG.hs | |
| parent | 1323b7406376c72f40b1e561e079f8824f79aabf (diff) | |
"Committed_by_peb"
Diffstat (limited to 'src/GF/Conversion/MCFGtoCFG.hs')
| -rw-r--r-- | src/GF/Conversion/MCFGtoCFG.hs | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/src/GF/Conversion/MCFGtoCFG.hs b/src/GF/Conversion/MCFGtoCFG.hs index 236a90aca..add87c9d3 100644 --- a/src/GF/Conversion/MCFGtoCFG.hs +++ b/src/GF/Conversion/MCFGtoCFG.hs @@ -4,16 +4,16 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/04/16 05:40:49 $ +-- > CVS $Date: 2005/04/18 14:55:32 $ -- > CVS $Author: peb $ --- > CVS $Revision: 1.3 $ +-- > CVS $Revision: 1.4 $ -- -- Converting MCFG grammars to (possibly overgenerating) CFG ----------------------------------------------------------------------------- module GF.Conversion.MCFGtoCFG - (convertGrammar, convertNEGrammar) where + (convertGrammar) where import GF.System.Tracing import GF.Infra.Print @@ -28,11 +28,11 @@ import GF.Conversion.Types ---------------------------------------------------------------------- -- * converting (possibly erasing) MCFG grammars -convertGrammar :: MGrammar -> CGrammar -convertGrammar gram = tracePrt "#context-free rules" (prt.length) $ +convertGrammar :: EGrammar -> CGrammar +convertGrammar gram = tracePrt "MCFGtoCFG - nr. context-free rules" (prt.length) $ concatMap convertRule gram -convertRule :: MRule -> [CRule] +convertRule :: ERule -> [CRule] convertRule (Rule (Abs cat args (Name fun mprofile)) (Cnc _ _ record)) = [ CFRule (CCat cat lbl) rhs (Name fun profile) | Lin lbl lin <- record, @@ -41,34 +41,13 @@ convertRule (Rule (Abs cat args (Name fun mprofile)) (Cnc _ _ record)) let profile = mprofile `composeProfiles` cprofile ] -convertArg :: (MCat, MLabel, Int) -> CCat +convertArg :: (ECat, ELabel, Int) -> CCat convertArg (cat, lbl, _) = CCat cat lbl argPlaces :: [Symbol (cat, lbl, Int) tok] -> Int -> [Int] argPlaces lin nr = [ place | (nr', place) <- zip linArgs [0..], nr == nr' ] where linArgs = [ nr' | (_, _, nr') <- filterCats lin ] ----------------------------------------------------------------------- --- * converting nonerasing MCFG grammars - -convertNEGrammar :: NGrammar -> CGrammar -convertNEGrammar gram = tracePrt "#context-free rules" (prt.length) $ - concatMap convertNERule gram - -convertNERule :: NRule -> [CRule] -convertNERule (Rule (Abs ncat args (Name fun mprofile)) (Cnc _ _ record)) - = [ CFRule (CCat (ncat2mcat ncat) lbl) rhs (Name fun profile) | - Lin lbl lin <- record, - let rhs = map (mapSymbol convertNEArg id) lin, - let cprofile = map (Unify . argPlaces lin) [0 .. length args-1], - let profile = mprofile `composeProfiles` cprofile - ] - -convertNEArg :: (NCat, NLabel, Int) -> CCat -convertNEArg (ncat, lbl, _) = CCat (ncat2mcat ncat) lbl - ----------------------------------------------------------------------- - |
