summaryrefslogtreecommitdiff
path: root/src/GF/Infra/ReadFiles.hs
diff options
context:
space:
mode:
authoraarne <unknown>2004-03-31 12:30:34 +0000
committeraarne <unknown>2004-03-31 12:30:34 +0000
commit3f9b4e7855cf4594708a9fbad194c89540d2cf1e (patch)
tree33dcbbd6d2e6e5f6290a25f65b4b9f90253fd34b /src/GF/Infra/ReadFiles.hs
parent6719aedde34c3a4f0ccb78931968c6fe490b3282 (diff)
Added support for cf and ebnf formats
Diffstat (limited to 'src/GF/Infra/ReadFiles.hs')
-rw-r--r--src/GF/Infra/ReadFiles.hs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/GF/Infra/ReadFiles.hs b/src/GF/Infra/ReadFiles.hs
index 06205e350..4172ee32e 100644
--- a/src/GF/Infra/ReadFiles.hs
+++ b/src/GF/Infra/ReadFiles.hs
@@ -27,15 +27,15 @@ import List
type ModName = String
type ModEnv = [(ModName,ModTime)]
-getAllFiles :: [InitPath] -> ModEnv -> FileName -> IOE [FullPath]
-getAllFiles ps env file = do
+getAllFiles :: Options -> [InitPath] -> ModEnv -> FileName -> IOE [FullPath]
+getAllFiles opts ps env file = do
-- read module headers from all files recursively
ds0 <- getImports ps file
let ds = [((snd m,map fst ms),p) | ((m,ms),p) <- ds0]
ioeIO $ putStrLn $ "all modules:" +++ show (map (fst . fst) ds)
- -- get a topological sorting of files: returns file names --- deletes paths
+ -- get a topological sorting of files: returns file names --- deletes paths
ds1 <- ioeErr $ either
return
(\ms -> Bad $ "circular modules" +++
@@ -44,12 +44,15 @@ getAllFiles ps env file = do
-- associate each file name with its path --- more optimal: save paths in ds1
let paths = [(f,p) | ((f,_),p) <- ds]
let pds1 = [(p,f) | f <- ds1, Just p <- [lookup f paths]]
+ if oElem fromSource opts
+ then return [gfFile (prefixPathName p f) | (p,f) <- pds1]
+ else do
- ds2 <- ioeIO $ mapM (selectFormat env) pds1
+ ds2 <- ioeIO $ mapM (selectFormat env) pds1
- let ds4 = needCompile (map fst ds0) ds2
- return ds4
+ let ds4 = needCompile opts (map fst ds0) ds2
+ return ds4
-- to decide whether to read gf or gfc, or if in env; returns full file path
@@ -77,8 +80,9 @@ selectFormat env (p,f) = do
return $ (f, (p,stat))
-needCompile :: [ModuleHeader] -> [(ModName,(InitPath,CompStatus))] -> [FullPath]
-needCompile headers sfiles0 = paths $ res $ mark $ iter changed where
+needCompile :: Options ->
+ [ModuleHeader] -> [(ModName,(InitPath,CompStatus))] -> [FullPath]
+needCompile opts headers sfiles0 = paths $ res $ mark $ iter changed where
deps = [(snd m,map fst ms) | (m,ms) <- headers]
typ m = maybe MTyOther id $ lookup m [(m,t) | ((t,m),_) <- headers]
@@ -117,10 +121,12 @@ needCompile headers sfiles0 = paths $ res $ mark $ iter changed where
-- if a compilable file depends on a resource, read gfr instead of gfc/env
-- but don't read gfr if already in env (by CSEnvR)
+ -- Also read res if the option "retain" is present
res cs = map mkRes cs where
mkRes x@(f,(path,st)) | elem st [CSRead,CSEnv] = case typ f of
MTyResource | not (null [m | (m,(_,CSComp)) <- cs,
Just ms <- [lookup m allDeps], elem f ms])
+ || oElem retainOpers opts
-> (f,(path,CSRes))
_ -> x
mkRes x = x