From c5666fabddca9eaf9786a310bc14d77ffc0bc51e Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 23 Feb 2006 09:58:59 +0000 Subject: [PATCH] the -gfc option --- src/GF/Infra/ReadFiles.hs | 11 +++++++---- src/GF/Shell/HelpFile.hs | 3 ++- src/GF/Shell/ShellCommands.hs | 2 +- src/HelpFile | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/GF/Infra/ReadFiles.hs b/src/GF/Infra/ReadFiles.hs index 538af5b8f..bb0d5e630 100644 --- a/src/GF/Infra/ReadFiles.hs +++ b/src/GF/Infra/ReadFiles.hs @@ -62,7 +62,7 @@ getAllFiles opts ps env file = do else do - ds2 <- ioeIO $ mapM (selectFormat env) pds1 + ds2 <- ioeIO $ mapM (selectFormat opts env) pds1 let ds4 = needCompile opts (map fst ds0) ds2 return ds4 @@ -80,15 +80,19 @@ data CompStatus = -- for gfc, we also return ModTime to cope with earlier compilation of libs -selectFormat :: ModEnv -> (InitPath,ModName) -> +selectFormat :: Options -> ModEnv -> (InitPath,ModName) -> IO (ModName,(InitPath,(CompStatus,Maybe ModTime))) -selectFormat env (p,f) = do + +selectFormat opts env (p,f) = do let pf = prefixPathName p f let mtenv = lookup f env -- Nothing if f is not in env let rtenv = lookup (resModName f) env + let fromComp = oElem isCompiled opts -- i -gfc mtgfc <- getModTime $ gfcFile pf mtgf <- getModTime $ gfFile pf let stat = case (rtenv,mtenv,mtgfc,mtgf) of + (_,Just tenv,_,_) | fromComp -> (CSEnv, Just tenv) + (_,_,Just tgfc,_) | fromComp -> (CSRead,Just tgfc) (Just tenv,_,_,Just tgf) | laterModTime tenv tgf -> (CSEnvR,Just tenv) (_,Just tenv,_,Just tgf) | laterModTime tenv tgf -> (CSEnv, Just tenv) (_,_,Just tgfc,Just tgf) | laterModTime tgfc tgf -> (CSRead,Just tgfc) @@ -96,7 +100,6 @@ selectFormat env (p,f) = do _ -> (CSComp,Nothing) return $ (f, (p,stat)) - needCompile :: Options -> [ModuleHeader] -> [(ModName,(InitPath,(CompStatus,Maybe ModTime)))] -> [FullPath] diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs index 5764e9f14..ecb8c5bc4 100644 --- a/src/GF/Shell/HelpFile.hs +++ b/src/GF/Shell/HelpFile.hs @@ -56,7 +56,8 @@ txtHelpFile = "\n -old old: parse in GF<2.0 format (not necessary)" ++ "\n -v verbose: give lots of messages " ++ "\n -s silent: don't give error messages" ++ - "\n -src source: ignore precompiled gfc and gfr files" ++ + "\n -src from source: ignore precompiled gfc and gfr files" ++ + "\n -gfc from gfc: use compiled modules whenever they exist" ++ "\n -retain retain operations: read resource modules (needed in comm cc) " ++ "\n -nocf don't build context-free grammar (thus no parser)" ++ "\n -nocheckcirc don't eliminate circular rules from CF " ++ diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs index 7d10ef882..9918e5225 100644 --- a/src/GF/Shell/ShellCommands.hs +++ b/src/GF/Shell/ShellCommands.hs @@ -169,7 +169,7 @@ optionsOfCommand co = case co of CSetFlag -> both "utf8 table struct record all multi" "cat lang lexer parser number depth rawtrees unlexer optimize path conversion printer" - CImport _ -> both "old v s src retain nocf nocheckcirc cflexer noemit o ex prob" + CImport _ -> both "old v s src gfc retain nocf nocheckcirc cflexer noemit o ex prob" "abs cnc res path optimize conversion cat probs noparse" CRemoveLanguage _ -> none CEmptyState -> none diff --git a/src/HelpFile b/src/HelpFile index 0f6a12d8b..7edc19af7 100644 --- a/src/HelpFile +++ b/src/HelpFile @@ -27,7 +27,8 @@ i, import: i File -old old: parse in GF<2.0 format (not necessary) -v verbose: give lots of messages -s silent: don't give error messages - -src source: ignore precompiled gfc and gfr files + -src from source: ignore precompiled gfc and gfr files + -gfc from gfc: use compiled modules whenever they exist -retain retain operations: read resource modules (needed in comm cc) -nocf don't build context-free grammar (thus no parser) -nocheckcirc don't eliminate circular rules from CF