mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
Some work on the haddock documentation
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
module GF(
|
module GF(
|
||||||
-- * Command line interface
|
-- * Command line interface
|
||||||
module GF.Main,
|
module GF.Main,
|
||||||
module GF.Compiler,
|
|
||||||
module GF.Interactive,
|
module GF.Interactive,
|
||||||
|
module GF.Compiler,
|
||||||
|
|
||||||
-- * Compiling GF grammars
|
-- * Compiling GF grammars
|
||||||
module GF.Compile,
|
module GF.Compile,
|
||||||
@@ -11,7 +11,10 @@ module GF(
|
|||||||
|
|
||||||
-- * Abstract syntax, parsing and pretty printing
|
-- * Abstract syntax, parsing and pretty printing
|
||||||
module GF.Compile.GetGrammar,
|
module GF.Compile.GetGrammar,
|
||||||
module GF.Grammar,
|
module GF.Grammar.Grammar,
|
||||||
|
module GF.Grammar.Macros,
|
||||||
|
module GF.Grammar.Printer,
|
||||||
|
module GF.Infra.Ident,
|
||||||
|
|
||||||
-- * Supporting infrastructure and system utilities
|
-- * Supporting infrastructure and system utilities
|
||||||
module GF.Data.Operations,
|
module GF.Data.Operations,
|
||||||
@@ -28,7 +31,10 @@ import GF.CompileInParallel
|
|||||||
import GF.CompileOne
|
import GF.CompileOne
|
||||||
|
|
||||||
import GF.Compile.GetGrammar
|
import GF.Compile.GetGrammar
|
||||||
import GF.Grammar
|
import GF.Grammar.Grammar
|
||||||
|
import GF.Grammar.Macros
|
||||||
|
import GF.Grammar.Printer
|
||||||
|
import GF.Infra.Ident
|
||||||
|
|
||||||
import GF.Data.Operations
|
import GF.Data.Operations
|
||||||
import GF.Infra.Option
|
import GF.Infra.Option
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import PGF.Internal(optimizePGF)
|
|||||||
import PGF(PGF,defaultProbabilities,setProbabilities,readProbabilitiesFromFile)
|
import PGF(PGF,defaultProbabilities,setProbabilities,readProbabilitiesFromFile)
|
||||||
|
|
||||||
-- | Compiles a number of source files and builds a 'PGF' structure for them.
|
-- | Compiles a number of source files and builds a 'PGF' structure for them.
|
||||||
|
-- This is a composition of 'batchCompile' and 'link'.
|
||||||
compileToPGF :: Options -> [FilePath] -> IOE PGF
|
compileToPGF :: Options -> [FilePath] -> IOE PGF
|
||||||
compileToPGF opts fs = link opts =<< batchCompile opts fs
|
compileToPGF opts fs = link opts =<< batchCompile opts fs
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module GF.Compile.Compute.ConcreteNew
|
|||||||
|
|
||||||
import GF.Grammar hiding (Env, VGen, VApp, VRecType)
|
import GF.Grammar hiding (Env, VGen, VApp, VRecType)
|
||||||
import GF.Grammar.Lookup(lookupResDefLoc,allParamValues)
|
import GF.Grammar.Lookup(lookupResDefLoc,allParamValues)
|
||||||
import GF.Grammar.Predef(cPredef,cErrorType,cTok,cStr)
|
import GF.Grammar.Predef(cPredef,cErrorType,cTok,cStr,isPredefCat)
|
||||||
import GF.Grammar.PatternMatch(matchPattern,measurePatt)
|
import GF.Grammar.PatternMatch(matchPattern,measurePatt)
|
||||||
import GF.Grammar.Lockfield(lockLabel,isLockLabel,lockRecType) --unlockRecord
|
import GF.Grammar.Lockfield(lockLabel,isLockLabel,lockRecType) --unlockRecord
|
||||||
import GF.Compile.Compute.Value hiding (Error)
|
import GF.Compile.Compute.Value hiding (Error)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module GF.Compiler (mainGFC, writePGF) where
|
module GF.Compiler (mainGFC, writePGF, linkGrammars) where
|
||||||
|
|
||||||
import PGF
|
import PGF
|
||||||
import PGF.Internal(concretes,optimizePGF,unionPGF)
|
import PGF.Internal(concretes,optimizePGF,unionPGF)
|
||||||
@@ -23,6 +23,8 @@ import qualified Data.ByteString.Lazy as BSL
|
|||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Control.Monad(unless,forM_)
|
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 :: Options -> [FilePath] -> IO ()
|
||||||
mainGFC opts fs = do
|
mainGFC opts fs = do
|
||||||
r <- appIOE (case () of
|
r <- appIOE (case () of
|
||||||
@@ -41,25 +43,29 @@ mainGFC opts fs = do
|
|||||||
|
|
||||||
compileSourceFiles :: Options -> [FilePath] -> IOE ()
|
compileSourceFiles :: Options -> [FilePath] -> IOE ()
|
||||||
compileSourceFiles opts fs =
|
compileSourceFiles opts fs =
|
||||||
do (t_src,~cnc_grs@(~(cnc,gr):_)) <- batchCompile opts fs
|
do output <- batchCompile opts fs
|
||||||
unless (flag optStopAfterPhase opts == Compile) $
|
unless (flag optStopAfterPhase opts == Compile) $
|
||||||
do let abs = showIdent (srcAbsName gr cnc)
|
linkGrammars opts output
|
||||||
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
|
|
||||||
where
|
where
|
||||||
batchCompile = maybe batchCompile' parallelBatchCompile (flag optJobs opts)
|
batchCompile = maybe batchCompile' parallelBatchCompile (flag optJobs opts)
|
||||||
batchCompile' opts fs = do (cnc,t,gr) <- S.batchCompile opts fs
|
batchCompile' opts fs = do (cnc,t,gr) <- S.batchCompile opts fs
|
||||||
return (t,[(cnc,gr)])
|
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 :: Options -> [FilePath] -> IOE ()
|
||||||
compileCFFiles opts fs = do
|
compileCFFiles opts fs = do
|
||||||
rules <- fmap concat $ mapM (getCFRules opts) fs
|
rules <- fmap concat $ mapM (getCFRules opts) fs
|
||||||
@@ -107,6 +113,9 @@ writeOutputs opts pgf = do
|
|||||||
| fmt <- outputFormats opts,
|
| fmt <- outputFormats opts,
|
||||||
(name,str) <- exportPGF opts fmt pgf]
|
(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 :: Options -> PGF -> IOE ()
|
||||||
writePGF opts pgf =
|
writePGF opts pgf =
|
||||||
if flag optSplitPGF opts then writeSplitPGF else writeNormalPGF
|
if flag optSplitPGF opts then writeSplitPGF else writeNormalPGF
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import GF.Infra.BuildInfo(buildInfo)
|
|||||||
import Data.Version(showVersion)
|
import Data.Version(showVersion)
|
||||||
import Paths_gf(version)
|
import Paths_gf(version)
|
||||||
|
|
||||||
-- | Run the GF Shell in quiet mode
|
-- | Run the GF Shell in quiet mode (@gf -run@).
|
||||||
mainRunGFI :: Options -> [FilePath] -> IO ()
|
mainRunGFI :: Options -> [FilePath] -> IO ()
|
||||||
mainRunGFI opts files = shell (beQuiet opts) files
|
mainRunGFI opts files = shell (beQuiet opts) files
|
||||||
|
|
||||||
@@ -68,7 +68,8 @@ mainGFI opts files = do
|
|||||||
shell opts files = loop opts =<< runSIO (importInEnv emptyGFEnv opts files)
|
shell opts files = loop opts =<< runSIO (importInEnv emptyGFEnv opts files)
|
||||||
|
|
||||||
#ifdef SERVER_MODE
|
#ifdef SERVER_MODE
|
||||||
-- | Start GF Server
|
-- | Run the GF Server (@gf -server@).
|
||||||
|
-- The 'Int' argument is the port number for the HTTP service.
|
||||||
mainServerGFI opts0 port files =
|
mainServerGFI opts0 port files =
|
||||||
server port root (execute1 opts)
|
server port root (execute1 opts)
|
||||||
=<< runSIO (importInEnv emptyGFEnv opts files)
|
=<< runSIO (importInEnv emptyGFEnv opts files)
|
||||||
|
|||||||
Reference in New Issue
Block a user