From 676b0d6e8192c3cab92ca4cb8247cba00533402d Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 8 Dec 2014 14:48:14 +0000 Subject: [PATCH] Haddock documentation: expose exportPGF, some other small improvements --- src/compiler/GF.hs | 4 ++++ src/compiler/GF/Compile/Export.hs | 2 ++ src/compiler/GF/CompileOne.hs | 6 +++--- src/compiler/GF/Compiler.hs | 6 ++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/compiler/GF.hs b/src/compiler/GF.hs index b41a75f37..8938a053e 100644 --- a/src/compiler/GF.hs +++ b/src/compiler/GF.hs @@ -1,3 +1,4 @@ +-- | GF, the Grammatical Framework, as a library module GF( -- * Command line interface module GF.Main, @@ -7,6 +8,8 @@ module GF( -- * Compiling GF grammars module GF.Compile, module GF.CompileInParallel, +-- module PF.Compile.Export, -- haddock does the wrong thing with this + exportPGF, module GF.CompileOne, -- * Abstract syntax, parsing, pretty printing and serialisation @@ -25,6 +28,7 @@ import GF.Interactive import GF.Compile import GF.CompileInParallel import GF.CompileOne +import GF.Compile.Export(exportPGF) import GF.Compile.GetGrammar import GF.Grammar.Grammar diff --git a/src/compiler/GF/Compile/Export.hs b/src/compiler/GF/Compile/Export.hs index 432d98db9..5518d2ee2 100644 --- a/src/compiler/GF/Compile/Export.hs +++ b/src/compiler/GF/Compile/Export.hs @@ -25,6 +25,8 @@ import GF.Text.Pretty -- top-level access to code generation +-- | Export a PGF to the given 'OutputFormat'. For many output formats, +-- additional 'Options' can be used to control the output. exportPGF :: Options -> OutputFormat -> PGF diff --git a/src/compiler/GF/CompileOne.hs b/src/compiler/GF/CompileOne.hs index 0a6572134..8443ec932 100644 --- a/src/compiler/GF/CompileOne.hs +++ b/src/compiler/GF/CompileOne.hs @@ -105,7 +105,7 @@ compileSourceModule opts cwd mb_gfFile gr = -- Apply to complete modules when not generating tags backend mo3 = - do mo4 <- runPassE id Optimize "optimizing" $ optimizeModule opts gr mo3 + do mo4 <- runPassE Optimize "optimizing" $ optimizeModule opts gr mo3 if isModCnc (snd mo4) && flag optPMCFG opts then runPassI "generating PMCFG" $ generatePMCFG opts gr mb_gfFile mo4 else runPassI "" $ return mo4 @@ -126,9 +126,9 @@ compileSourceModule opts cwd mb_gfFile gr = -- * Running a compiler pass, with impedance matching runPass = runPass' fst fst snd (liftErr . runCheck' opts) - runPassE = runPass2e liftErr + runPassE = runPass2e liftErr id runPassI = runPass2e id id Canon - runPass2e lift f = runPass' id f (const "") lift + runPass2e lift dump = runPass' id dump (const "") lift runPass' ret dump warn lift pass pp m = do out <- putpp pp $ lift m diff --git a/src/compiler/GF/Compiler.hs b/src/compiler/GF/Compiler.hs index 57855b1b9..57d0b6e03 100644 --- a/src/compiler/GF/Compiler.hs +++ b/src/compiler/GF/Compiler.hs @@ -1,4 +1,4 @@ -module GF.Compiler (mainGFC, writePGF, linkGrammars) where +module GF.Compiler (mainGFC, linkGrammars, writePGF, writeOutputs) where import PGF import PGF.Internal(concretes,optimizePGF,unionPGF) @@ -56,7 +56,7 @@ compileSourceFiles opts fs = -- in the 'Options') from the output of 'parallelBatchCompile'. -- If a @.pgf@ file by the same name already exists and it is newer than the -- source grammar files (as indicated by the 'UTCTime' argument), it is not --- recreated. +-- recreated. Calls 'writePGF' and 'writeOutputs'. linkGrammars opts (t_src,~cnc_grs@(~(cnc,gr):_)) = do let abs = render (srcAbsName gr cnc) pgfFile = outputPath opts (grammarName' opts abs<.>"pgf") @@ -111,6 +111,8 @@ unionPGFFiles opts fs = readPGFVerbose f = putPointE Normal opts ("Reading " ++ f ++ "...") $ liftIO $ readPGF f +-- | Export the PGF to the 'OutputFormat's specified in the 'Options'. +-- Calls 'exportPGF'. writeOutputs :: Options -> PGF -> IOE () writeOutputs opts pgf = do sequence_ [writeOutput opts name str