summaryrefslogtreecommitdiff
path: root/src/GF/Compile
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-02-25 18:59:32 +0000
committeraarne <aarne@cs.chalmers.se>2006-02-25 18:59:32 +0000
commit3cbd135010a597aa4caf1098bd21b95814f5de64 (patch)
treeea2769c8dc81619830e56a9fe5fd406db143ee2a /src/GF/Compile
parent56a9e025d59d3c6df9f07a6304f7d1d56dfd96b2 (diff)
resource specialized to present tense ; preprocessor flag
Diffstat (limited to 'src/GF/Compile')
-rw-r--r--src/GF/Compile/Compile.hs7
-rw-r--r--src/GF/Compile/GetGrammar.hs19
2 files changed, 18 insertions, 8 deletions
diff --git a/src/GF/Compile/Compile.hs b/src/GF/Compile/Compile.hs
index c364e1adf..8655e0ae7 100644
--- a/src/GF/Compile/Compile.hs
+++ b/src/GF/Compile/Compile.hs
@@ -84,7 +84,7 @@ compileModule opts st0 file |
grammar1 <- case suff of
"cf" -> putp ("- parsing" +++ suff +++ file) $ getCFGrammar opts file
"ebnf" -> putp ("- parsing" +++ suff +++ file) $ getEBNFGrammar opts file
- "gfm" -> putp ("- parsing" +++ suff +++ file) $ getSourceGrammar file
+ "gfm" -> putp ("- parsing" +++ suff +++ file) $ getSourceGrammar opts file
_ -> putp ("- parsing old gf" +++ file) $ getOldGrammar opts file
let mods = modules grammar1
let env = compileEnvShSt st0 []
@@ -195,7 +195,7 @@ compileOne opts env@((_,srcgr,_),_) file = do
-- for compiled resource, parse and organize, then update environment
"gfr" -> do
- sm0 <- putp ("| reading" +++ file) $ getSourceModule file
+ sm0 <- putp ("| reading" +++ file) $ getSourceModule opts file
sm <- {- putp "creating indirections" $ -} ioeErr $ extendModule mos sm0
---- experiment with not optimizing gfr
---- sm:_ <- putp " optimizing " $ ioeErr $ evalModule mos sm1
@@ -206,7 +206,8 @@ compileOne opts env@((_,srcgr,_),_) file = do
-- for gf source, do full compilation
_ -> do
- sm0 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $ getSourceModule file
+ sm0 <- putpOpt ("- parsing" +++ file) ("- compiling" +++ file ++ "... ") $
+ getSourceModule opts file
(k',sm) <- makeSourceModule opts (fst env) sm0
cm <- putpp " generating code... " $ generateModuleCode opts path sm
ft <- getReadTimes file
diff --git a/src/GF/Compile/GetGrammar.hs b/src/GF/Compile/GetGrammar.hs
index 4eebc2845..019e2f3d2 100644
--- a/src/GF/Compile/GetGrammar.hs
+++ b/src/GF/Compile/GetGrammar.hs
@@ -44,16 +44,25 @@ import GF.Infra.ReadFiles ----
import Data.Char (toUpper)
import Data.List (nub)
import Control.Monad (foldM)
-
-getSourceModule :: FilePath -> IOE SourceModule
-getSourceModule file = do
+import System (system)
+
+getSourceModule :: Options -> FilePath -> IOE SourceModule
+getSourceModule opts file0 = do
+ file <- case getOptVal opts usePreprocessor of
+ Just p -> do
+ let tmp = "_gf_preproc.tmp"
+ cmd = p +++ file0 ++ ">" ++ tmp
+ ioeIO $ system cmd
+ -- ioeIO $ putStrLn $ "preproc" +++ cmd
+ return tmp
+ _ -> return file0
string <- readFileIOE file
let tokens = myLexer string
mo1 <- ioeErr $ {- err2err $ -} pModDef tokens
ioeErr $ transModDef mo1
-getSourceGrammar :: FilePath -> IOE SourceGrammar
-getSourceGrammar file = do
+getSourceGrammar :: Options -> FilePath -> IOE SourceGrammar
+getSourceGrammar opts file = do
string <- readFileIOE file
let tokens = myLexer string
gr1 <- ioeErr $ {- err2err $ -} pGrammar tokens