From 7676ab8e0072263ee52415614eaf94e50bce0995 Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 15 Oct 2008 14:24:23 +0000 Subject: [PATCH] Copy command-line options to module flags when compiling to .gfo. --- src/GF/Compile.hs | 4 ++-- src/GF/Grammar/Grammar.hs | 4 ++++ src/GF/Infra/Modules.hs | 11 +++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/GF/Compile.hs b/src/GF/Compile.hs index 226602616..7aeab6b08 100644 --- a/src/GF/Compile.hs +++ b/src/GF/Compile.hs @@ -158,8 +158,9 @@ compileOne opts env@(_,srcgr,_) file = do then compileOne opts env $ gfo else do - sm00 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $ + sm000 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $ getSourceModule opts file + let sm00 = mapSourceModule (\m -> m { flags = flags m `addOptions` opts }) sm000 let sm0 = decodeStringsInModule sm00 (k',sm) <- compileSourceModule opts env sm0 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 _ -> False - compileSourceModule :: Options -> CompileEnv -> SourceModule -> IOE (Int,SourceModule) compileSourceModule opts env@(k,gr,_) mo@(i,mi) = do diff --git a/src/GF/Grammar/Grammar.hs b/src/GF/Grammar/Grammar.hs index 4210358f1..5259e5618 100644 --- a/src/GF/Grammar/Grammar.hs +++ b/src/GF/Grammar/Grammar.hs @@ -21,6 +21,7 @@ module GF.Grammar.Grammar (SourceGrammar, SourceAbs, SourceRes, SourceCnc, + mapSourceModule, Info(..), PValues, Perh, @@ -75,6 +76,9 @@ type SourceAbs = Module Ident Info type SourceRes = 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 type PValues = [Term] diff --git a/src/GF/Infra/Modules.hs b/src/GF/Infra/Modules.hs index 9d8438f0f..3b9cf6b6a 100644 --- a/src/GF/Infra/Modules.hs +++ b/src/GF/Infra/Modules.hs @@ -23,7 +23,7 @@ module GF.Infra.Modules ( MReuseType(..), MInclude (..), extends, isInherited,inheritAll, updateMGrammar, updateModule, replaceJudgements, addFlag, - addOpenQualif, flagsModule, allFlags, mapModules, + addOpenQualif, flagsModule, allFlags, mapModules, mapModules', MainGrammar(..), MainConcreteSpec(..), OpenSpec(..), OpenQualif(..), oSimple, oQualif, ModuleStatus(..), @@ -141,9 +141,12 @@ allFlags gr = concatOptions $ map flags $ [m | (_, ModMod m) <- modules gr] mapModules :: (Module i a -> Module i a) -> MGrammar i a -> MGrammar i a -mapModules f = MGrammar . map (onSnd mapModules') . modules - where mapModules' (ModMod m) = ModMod (f m) - mapModules' m = m +mapModules f = MGrammar . map (onSnd (mapModules' f)) . modules + +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 { mainAbstract :: i ,