forked from GitHub/gf-core
resource specialized to present tense ; preprocessor flag
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -44,16 +44,25 @@ import GF.Infra.ReadFiles ----
|
||||
import Data.Char (toUpper)
|
||||
import Data.List (nub)
|
||||
import Control.Monad (foldM)
|
||||
import System (system)
|
||||
|
||||
getSourceModule :: FilePath -> IOE SourceModule
|
||||
getSourceModule file = do
|
||||
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
|
||||
|
||||
@@ -313,6 +313,7 @@ pathList = aOpt "path"
|
||||
uniCoding = aOpt "coding"
|
||||
probFile = aOpt "probs"
|
||||
noparseFile = aOpt "noparse"
|
||||
usePreprocessor = aOpt "preproc"
|
||||
|
||||
-- peb 16/3-05:
|
||||
gfcConversion :: String -> Option
|
||||
|
||||
@@ -74,6 +74,7 @@ txtHelpFile =
|
||||
"\n -optimize select an optimization to override file-defined flags" ++
|
||||
"\n -conversion select parsing method (values strict|nondet)" ++
|
||||
"\n -probs read probabilities from file (format (--# prob) Fun Double)" ++
|
||||
"\n -preproc use a preprocessor on each source file" ++
|
||||
"\n -noparse read nonparsable functions from file (format --# noparse Funs) " ++
|
||||
"\n examples:" ++
|
||||
"\n i English.gf -- ordinary import of Concrete" ++
|
||||
|
||||
@@ -170,7 +170,7 @@ optionsOfCommand co = case co of
|
||||
"cat lang lexer parser number depth rawtrees unlexer optimize path conversion printer"
|
||||
|
||||
CImport _ -> both "old v s src gfc retain nocf nocheckcirc cflexer noemit o ex prob"
|
||||
"abs cnc res path optimize conversion cat probs noparse"
|
||||
"abs cnc res path optimize conversion cat preproc probs noparse"
|
||||
CRemoveLanguage _ -> none
|
||||
CEmptyState -> none
|
||||
CStripState -> none
|
||||
|
||||
@@ -45,6 +45,7 @@ i, import: i File
|
||||
-optimize select an optimization to override file-defined flags
|
||||
-conversion select parsing method (values strict|nondet)
|
||||
-probs read probabilities from file (format (--# prob) Fun Double)
|
||||
-preproc use a preprocessor on each source file
|
||||
-noparse read nonparsable functions from file (format --# noparse Funs)
|
||||
examples:
|
||||
i English.gf -- ordinary import of Concrete
|
||||
|
||||
Reference in New Issue
Block a user