summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command/Importing.hs
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-05-24 07:47:06 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-05-24 07:47:06 +0000
commit67f64cb233edb899b2b1ad550ae8c832960fb7a2 (patch)
tree630dea18b83e342ec817e8ab5a2ba6d3e48c80a2 /src/compiler/GF/Command/Importing.hs
parentdbb4fdd0f7897943c9b9063fbdb256bb510a2b2b (diff)
now we compile context-free grammars directly to PGF without going via GF source code. This makes it quick and lightweight to compile big grammars such as the Berkley grammar
Diffstat (limited to 'src/compiler/GF/Command/Importing.hs')
-rw-r--r--src/compiler/GF/Command/Importing.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/compiler/GF/Command/Importing.hs b/src/compiler/GF/Command/Importing.hs
index 78c019bd4..3cf7674a0 100644
--- a/src/compiler/GF/Command/Importing.hs
+++ b/src/compiler/GF/Command/Importing.hs
@@ -2,11 +2,12 @@ module GF.Command.Importing (importGrammar, importSource) where
import PGF
import PGF.Data
+import PGF.Optimize
import GF.Compile
import GF.Compile.Multi (readMulti)
import GF.Compile.GetGrammar (getCFRules, getEBNFRules)
-import GF.Grammar (identS, SourceGrammar) -- for cc command
+import GF.Grammar (SourceGrammar) -- for cc command
import GF.Grammar.CFG
import GF.Grammar.EBNF
import GF.Compile.CFGtoPGF
@@ -65,6 +66,7 @@ importCF opts files get convert = do
startCat <- case rules of
(CFRule cat _ _ : _) -> return cat
_ -> fail "empty CFG"
- let gf = cf2gf (last files) (uniqueFuns (mkCFG startCat Set.empty rules))
- gr <- compileSourceGrammar opts gf
- link opts (identS (justModuleName (last files) ++ "Abs"), (), gr)
+ let pgf = cf2pgf (last files) (uniqueFuns (mkCFG startCat Set.empty rules))
+ probs <- liftIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf)
+ return $ setProbabilities probs
+ $ if flag optOptimizePGF opts then optimizePGF pgf else pgf