diff options
| author | hallgren <hallgren@chalmers.se> | 2014-10-16 16:28:54 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2014-10-16 16:28:54 +0000 |
| commit | 6375bacc73c5ba2f0dd660fab18b590506027822 (patch) | |
| tree | c151726dc25b54b2f991be0111afb50d2f65a0ab /src/compiler/GF/Compiler.hs | |
| parent | 070057e6950d7d07d05c91bb90033d012c6e8f01 (diff) | |
Some work on the haddock documentation
Diffstat (limited to 'src/compiler/GF/Compiler.hs')
| -rw-r--r-- | src/compiler/GF/Compiler.hs | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/compiler/GF/Compiler.hs b/src/compiler/GF/Compiler.hs index 407ef4e64..e607c7acc 100644 --- a/src/compiler/GF/Compiler.hs +++ b/src/compiler/GF/Compiler.hs @@ -1,4 +1,4 @@ -module GF.Compiler (mainGFC, writePGF) where +module GF.Compiler (mainGFC, writePGF, linkGrammars) where import PGF import PGF.Internal(concretes,optimizePGF,unionPGF) @@ -23,6 +23,8 @@ import qualified Data.ByteString.Lazy as BSL import System.FilePath import Control.Monad(unless,forM_) +-- | Compile the given GF grammar files. The result is a number of @.gfo@ files +-- and, depending on the options, a @.pgf@ file. (@gf -batch@, @gf -make@) mainGFC :: Options -> [FilePath] -> IO () mainGFC opts fs = do r <- appIOE (case () of @@ -41,25 +43,29 @@ mainGFC opts fs = do compileSourceFiles :: Options -> [FilePath] -> IOE () compileSourceFiles opts fs = - do (t_src,~cnc_grs@(~(cnc,gr):_)) <- batchCompile opts fs + do output <- batchCompile opts fs unless (flag optStopAfterPhase opts == Compile) $ - do let abs = showIdent (srcAbsName gr cnc) - pgfFile = outputPath opts (grammarName' opts abs<.>"pgf") - t_pgf <- if outputJustPGF opts - then maybeIO $ getModificationTime pgfFile - else return Nothing - if t_pgf >= Just t_src - then putIfVerb opts $ pgfFile ++ " is up-to-date." - else do pgfs <- mapM (link opts) - [(cnc,t_src,gr)|(cnc,gr)<-cnc_grs] - let pgf = foldl1 unionPGF pgfs - writePGF opts pgf - writeOutputs opts pgf + linkGrammars opts output where batchCompile = maybe batchCompile' parallelBatchCompile (flag optJobs opts) batchCompile' opts fs = do (cnc,t,gr) <- S.batchCompile opts fs return (t,[(cnc,gr)]) +-- | Create a @.pgf@ file from the output of 'parallelBatchCompile'. +linkGrammars opts (t_src,~cnc_grs@(~(cnc,gr):_)) = + do let abs = showIdent (srcAbsName gr cnc) + pgfFile = outputPath opts (grammarName' opts abs<.>"pgf") + t_pgf <- if outputJustPGF opts + then maybeIO $ getModificationTime pgfFile + else return Nothing + if t_pgf >= Just t_src + then putIfVerb opts $ pgfFile ++ " is up-to-date." + else do pgfs <- mapM (link opts) + [(cnc,t_src,gr)|(cnc,gr)<-cnc_grs] + let pgf = foldl1 unionPGF pgfs + writePGF opts pgf + writeOutputs opts pgf + compileCFFiles :: Options -> [FilePath] -> IOE () compileCFFiles opts fs = do rules <- fmap concat $ mapM (getCFRules opts) fs @@ -107,6 +113,9 @@ writeOutputs opts pgf = do | fmt <- outputFormats opts, (name,str) <- exportPGF opts fmt pgf] +-- | Write the result of compiling a grammar (e.g. with 'compileToPGF' or +-- 'link') to a @.pgf@ file. +-- A split PGF file is output if the @-split-pgf@ option is used. writePGF :: Options -> PGF -> IOE () writePGF opts pgf = if flag optSplitPGF opts then writeSplitPGF else writeNormalPGF |
