1
0
forked from GitHub/gf-core

simple profiler for PMCFG

This commit is contained in:
krasimir
2009-09-05 14:04:39 +00:00
parent e0930e51e2
commit 8b67bc92dd
6 changed files with 76 additions and 29 deletions

View File

@@ -44,14 +44,15 @@ mkCanon2gfcc opts cnc gr =
pars = mkParamLincat gr
-- Adds parsers for all concretes
addParsers :: Options -> D.PGF -> D.PGF
addParsers opts pgf = CM.mapConcretes conv pgf
addParsers :: Options -> D.PGF -> IO D.PGF
addParsers opts pgf = do cncs <- sequence [conv lang cnc | (lang,cnc) <- Map.toList (D.concretes pgf)]
return pgf { D.concretes = Map.fromList cncs }
where
conv cnc = cnc { D.parser = Just pinfo }
conv lang cnc = do pinfo <- if flag optErasing (erasingFromCnc `addOptions` opts)
then PMCFG.convertConcrete opts (D.abstract pgf) lang cnc
else return $ FCFG.convertConcrete (D.abstract pgf) cnc
return (lang,cnc { D.parser = Just pinfo })
where
pinfo
| flag optErasing (erasingFromCnc `addOptions` opts) = PMCFG.convertConcrete (D.abstract pgf) cnc
| otherwise = FCFG.convertConcrete (D.abstract pgf) cnc
erasingFromCnc = modifyFlags (\o -> o { optErasing = Map.lookup (mkCId "erasing") (D.cflags cnc) == Just "on"})
-- Generate PGF from GFCM.