diff options
| author | bjorn <bjorn@bringert.net> | 2008-10-20 14:05:39 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-10-20 14:05:39 +0000 |
| commit | 05343e78a93bc7a248cab402fc1f0c92450f2a91 (patch) | |
| tree | 9bdc77ddbbd1e2e02fe00c3a16c80a4f61f10463 /src | |
| parent | 5cbc5aeb9dd201a894a401f784c0635790bae8b4 (diff) | |
Added on-demand parser generation back in. It's pretty unproblematic, and can help with memory use in some cases.
Diffstat (limited to 'src')
| -rw-r--r-- | src/PGF.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/PGF.hs b/src/PGF.hs index d78a55108..17f1d8af8 100644 --- a/src/PGF.hs +++ b/src/PGF.hs @@ -71,6 +71,7 @@ import PGF.Raw.Parse import PGF.Raw.Print (printTree) import PGF.Parsing.FCFG import qualified PGF.Parsing.FCFG.Incremental as Incremental +import qualified GF.Compile.GeneratePMCFG as PMCFG import GF.Text.UTF8 import GF.Data.ErrM @@ -211,7 +212,14 @@ showLanguage = prCId readPGF f = do s <- readFile f >>= return . decodeUTF8 -- pgf is in UTF8, internal in unicode g <- parseGrammar s - return $! toPGF g + return $! addParsers $ toPGF g + +-- Adds parsers for all concretes that don't have a parser. +addParsers :: PGF -> PGF +addParsers pgf = pgf { concretes = Map.map conv (concretes pgf) } + where + conv cnc | isJust (parser cnc) = cnc + | otherwise = cnc { parser = Just (PMCFG.convertConcrete (abstract pgf) cnc) } linearize pgf lang = concat . take 1 . PGF.Linearize.linearizes pgf lang |
