1
0
forked from GitHub/gf-core

refactor the API for random generation again. Now PGF contains probabilities in the abstract syntax

This commit is contained in:
krasimir
2010-10-02 13:03:57 +00:00
parent 72cc4ddb59
commit cb8795c222
23 changed files with 177 additions and 194 deletions

View File

@@ -42,6 +42,7 @@ import PGF.CId
import PGF.Data
import PGF.Macros
import PGF.Optimize
import PGF.Probabilistic
-- | Compiles a number of source files and builds a 'PGF' structure for them.
@@ -55,9 +56,13 @@ link :: Options -> Ident -> SourceGrammar -> IOE PGF
link opts cnc gr = do
let isv = (verbAtLeast opts Normal)
putPointE Normal opts "linking ... " $ do
gc <- ioeIO (mkCanon2pgf opts cnc gr)
ioeIO $ putStrLn "OK"
return $ if flag optOptimizePGF opts then optimizePGF gc else gc
pgf <- ioeIO (mkCanon2pgf opts cnc gr)
probs <- ioeIO (maybe (return . defaultProbabilities) readProbabilitiesFromFile (flag optProbsFile opts) pgf)
ioeIO $ putStrLn "OK"
pgf <- return $ setProbabilities probs
$ if flag optOptimizePGF opts then optimizePGF pgf else pgf
ioeIO $ putStrLn (showProbabilities (getProbabilities pgf))
return pgf
batchCompile :: Options -> [FilePath] -> IOE SourceGrammar
batchCompile opts files = do