1
0
forked from GitHub/gf-core

Copy command-line options to module flags when compiling to .gfo.

This commit is contained in:
bjorn
2008-10-15 14:24:23 +00:00
parent 58381a95a4
commit f898c7543d
3 changed files with 13 additions and 6 deletions

View File

@@ -158,8 +158,9 @@ compileOne opts env@(_,srcgr,_) file = do
then compileOne opts env $ gfo then compileOne opts env $ gfo
else do else do
sm00 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $ sm000 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $
getSourceModule opts file getSourceModule opts file
let sm00 = mapSourceModule (\m -> m { flags = flags m `addOptions` opts }) sm000
let sm0 = decodeStringsInModule sm00 let sm0 = decodeStringsInModule sm00
(k',sm) <- compileSourceModule opts env sm0 (k',sm) <- compileSourceModule opts env sm0
let sm1 = if isConcr sm then shareModule sm else sm -- cannot expand Str let sm1 = if isConcr sm then shareModule sm else sm -- cannot expand Str
@@ -171,7 +172,6 @@ compileOne opts env@(_,srcgr,_) file = do
ModMod m -> isModCnc m && mstatus m /= MSIncomplete ModMod m -> isModCnc m && mstatus m /= MSIncomplete
_ -> False _ -> False
compileSourceModule :: Options -> CompileEnv -> compileSourceModule :: Options -> CompileEnv ->
SourceModule -> IOE (Int,SourceModule) SourceModule -> IOE (Int,SourceModule)
compileSourceModule opts env@(k,gr,_) mo@(i,mi) = do compileSourceModule opts env@(k,gr,_) mo@(i,mi) = do

View File

@@ -21,6 +21,7 @@ module GF.Grammar.Grammar (SourceGrammar,
SourceAbs, SourceAbs,
SourceRes, SourceRes,
SourceCnc, SourceCnc,
mapSourceModule,
Info(..), Info(..),
PValues, PValues,
Perh, Perh,
@@ -75,6 +76,9 @@ type SourceAbs = Module Ident Info
type SourceRes = Module Ident Info type SourceRes = Module Ident Info
type SourceCnc = Module Ident Info type SourceCnc = Module Ident Info
mapSourceModule :: (Module Ident Info -> Module Ident Info) -> SourceModule -> SourceModule
mapSourceModule f (i,mi) = (i, mapModules' f mi)
-- this is created in CheckGrammar, and so are Val and PVal -- this is created in CheckGrammar, and so are Val and PVal
type PValues = [Term] type PValues = [Term]

View File

@@ -23,7 +23,7 @@ module GF.Infra.Modules (
MReuseType(..), MInclude (..), MReuseType(..), MInclude (..),
extends, isInherited,inheritAll, extends, isInherited,inheritAll,
updateMGrammar, updateModule, replaceJudgements, addFlag, updateMGrammar, updateModule, replaceJudgements, addFlag,
addOpenQualif, flagsModule, allFlags, mapModules, addOpenQualif, flagsModule, allFlags, mapModules, mapModules',
MainGrammar(..), MainConcreteSpec(..), OpenSpec(..), OpenQualif(..), MainGrammar(..), MainConcreteSpec(..), OpenSpec(..), OpenQualif(..),
oSimple, oQualif, oSimple, oQualif,
ModuleStatus(..), ModuleStatus(..),
@@ -141,9 +141,12 @@ allFlags gr = concatOptions $ map flags $ [m | (_, ModMod m) <- modules gr]
mapModules :: (Module i a -> Module i a) mapModules :: (Module i a -> Module i a)
-> MGrammar i a -> MGrammar i a -> MGrammar i a -> MGrammar i a
mapModules f = MGrammar . map (onSnd mapModules') . modules mapModules f = MGrammar . map (onSnd (mapModules' f)) . modules
where mapModules' (ModMod m) = ModMod (f m)
mapModules' m = m mapModules' :: (Module i a -> Module i a)
-> ModInfo i a -> ModInfo i a
mapModules' f (ModMod m) = ModMod (f m)
mapModules' _ m = m
data MainGrammar i = MainGrammar { data MainGrammar i = MainGrammar {
mainAbstract :: i , mainAbstract :: i ,