"Committed_by_peb"

This commit is contained in:
peb
2005-05-09 08:25:56 +00:00
parent 1775e9bdc9
commit 73df27b409
31 changed files with 1390 additions and 482 deletions

View File

@@ -4,20 +4,24 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/04/11 13:52:50 $
-- > CVS $Date: 2005/05/09 09:28:45 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.1 $
-- > CVS $Revision: 1.2 $
--
-- Definitions of multiple context-free grammars
-----------------------------------------------------------------------------
module GF.Formalism.MCFG where
import Control.Monad (liftM)
import Data.List (groupBy)
import GF.Formalism.Utilities
import GF.Formalism.GCFG
import GF.Infra.Print
------------------------------------------------------------
-- grammar types
@@ -35,6 +39,13 @@ instantiateArgs args (Lin lbl lin) = Lin lbl (map instSym lin)
where instSym = mapSymbol instCat id
instCat (_, lbl, nr) = (args !! nr, lbl, nr)
expandVariants :: Eq lbl => MCFRule cat name lbl tok -> [MCFRule cat name lbl tok]
expandVariants (Rule abs (Cnc typ typs lins)) = liftM (Rule abs . Cnc typ typs) $
expandLins lins
where expandLins = sequence . groupBy eqLbl
eqLbl (Lin l1 _) (Lin l2 _) = l1 == l2
------------------------------------------------------------
-- pretty-printing