summaryrefslogtreecommitdiff
path: root/src/GF/Compile
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Compile')
-rw-r--r--src/GF/Compile/Compile.hs20
-rw-r--r--src/GF/Compile/ShellState.hs19
2 files changed, 28 insertions, 11 deletions
diff --git a/src/GF/Compile/Compile.hs b/src/GF/Compile/Compile.hs
index 4822cf2b4..a1b1758fb 100644
--- a/src/GF/Compile/Compile.hs
+++ b/src/GF/Compile/Compile.hs
@@ -47,15 +47,27 @@ batchCompileOld f = compileOld defOpts f
defOpts = options [beVerbose, emitCode]
-- compile with one module as starting point
+-- command-line options override options (marked by --#) in the file
+-- As for path: if it is read from file, the file path is prepended to each name.
+-- If from command line, it is used as it is.
compileModule :: Options -> ShellState -> FilePath ->
IOE (GFC.CanonGrammar, (SourceGrammar,[(FilePath,ModTime)]))
-compileModule opts st file = do
- let ps = pathListOpts opts
+compileModule opts1 st0 file = do
+ opts0 <- ioeIO $ getOptionsFromFile file
+ let useFileOpt = maybe False (const True) $ getOptVal opts0 pathList
+ let opts = addOptions opts1 opts0
+ let ps0 = pathListOpts opts
+ let fpath = justInitPath file
+ let ps = if useFileOpt
+ then (map (prefixPathName fpath) ps0)
+ else ps0
ioeIO $ print ps ----
let putp = putPointE opts
- let rfs = readFiles st
- files <- getAllFiles ps rfs file
+ let st = st0 --- if useFileOpt then emptyShellState else st0
+ let rfs = readFiles st
+ let file' = if useFileOpt then justFileName file else file -- to find file itself
+ files <- getAllFiles ps rfs file'
ioeIO $ print files ----
let names = map (fileBody . justFileName) files
ioeIO $ print names ----
diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs
index 51e05abd0..ad1566f1f 100644
--- a/src/GF/Compile/ShellState.hs
+++ b/src/GF/Compile/ShellState.hs
@@ -70,7 +70,8 @@ data StateGrammar = StGr {
grammar :: CanonGrammar,
cf :: CF,
---- parser :: StaticParserInfo,
- morpho :: Morpho
+ morpho :: Morpho,
+ loptions :: Options
}
emptyStateGrammar = StGr {
@@ -78,14 +79,15 @@ emptyStateGrammar = StGr {
cncId = identC "#EMPTY", ---
grammar = M.emptyMGrammar,
cf = emptyCF,
- morpho = emptyMorpho
+ morpho = emptyMorpho,
+ loptions = noOptions
}
-- analysing shell grammar into parts
stateGrammarST = grammar
stateCF = cf
stateMorpho = morpho
-stateOptions _ = noOptions ----
+stateOptions = loptions ----
cncModuleIdST = stateGrammarST
@@ -122,16 +124,17 @@ updateShellState opts sh (gr,(sgr,rts)) = do
| (c,co) <- cats, let tc = cat2val co c]
let deps = True ---- not $ null $ allDepCats cgr
let binds = [] ---- allCatsWithBind cgr
+ let src = M.updateMGrammar (srcModules sh) sgr
return $ ShSt {
abstract = abstr0,
concrete = concr0,
concretes = zip concrs concrs,
canModules = cgr,
- srcModules = M.updateMGrammar (srcModules sh) sgr,
+ srcModules = src,
cfs = zip concrs cfs,
morphos = zip concrs (repeat emptyMorpho),
- gloptions = opts, ---- -- global options
+ gloptions = options (M.allFlags src), ---- canModules
readFiles = [ft | ft@(f,_) <- readFiles sh, notInrts f] ++ rts,
absCats = csi,
statistics = [StDepTypes deps,StBoundVars binds]
@@ -194,7 +197,8 @@ stateGrammarOfLang st l = StGr {
cncId = l,
grammar = canModules st, ---- only those needed for l
cf = maybe emptyCF id (lookup l (cfs st)),
- morpho = maybe emptyMorpho id (lookup l (morphos st))
+ morpho = maybe emptyMorpho id (lookup l (morphos st)),
+ loptions = gloptions st ---- only the own ones!
}
grammarOfLang st = stateGrammarST . stateGrammarOfLang st
@@ -218,7 +222,8 @@ stateAbstractGrammar st = StGr {
cncId = identC "#Cnc", ---
grammar = canModules st, ---- only abstarct ones
cf = emptyCF,
- morpho = emptyMorpho
+ morpho = emptyMorpho,
+ loptions = gloptions st ----
}