From dc3f2833441d1a7e00cc04602aab8c72174d54b7 Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 16 Oct 2008 10:13:25 +0000 Subject: Moved parser building in the PGF interpreter to PGF.hs from PGF/Raw/Convert.hs, in preparation for doing something more clever about it (e.g. looking at the parser flag). --- src/PGF.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/PGF.hs') diff --git a/src/PGF.hs b/src/PGF.hs index dc777f4d5..96fd73c86 100644 --- a/src/PGF.hs +++ b/src/PGF.hs @@ -69,6 +69,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 @@ -204,7 +205,14 @@ complete :: PGF -> Language -> Category -> String 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 (mkCId lang) -- cgit v1.2.3