diff options
| author | krasimir <krasimir@chalmers.se> | 2008-04-22 11:39:46 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2008-04-22 11:39:46 +0000 |
| commit | fc111c1a7910ab4a2a1bf40c0473bbaacadedd61 (patch) | |
| tree | 6f9c2bed83320272ebe41f314fd930f2a13ce3d9 /src/GF/Devel/Compile.hs | |
| parent | 7a6adbf35932efeed283f762b300b6f5a3b21d8a (diff) | |
use the standard System.FilePath module instead of our own broken file path manipulation functions
Diffstat (limited to 'src/GF/Devel/Compile.hs')
| -rw-r--r-- | src/GF/Devel/Compile.hs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/GF/Devel/Compile.hs b/src/GF/Devel/Compile.hs index 149e49c5d..538aa1309 100644 --- a/src/GF/Devel/Compile.hs +++ b/src/GF/Devel/Compile.hs @@ -29,6 +29,7 @@ import GF.Devel.Arch import Control.Monad import System.Directory +import System.FilePath batchCompile :: Options -> [FilePath] -> IOE SourceGrammar batchCompile opts files = do @@ -64,24 +65,24 @@ compileModule opts1 env file = do let useFileOpt = maybe False (const True) $ getOptVal opts0 pathList let useLineOpt = maybe False (const True) $ getOptVal opts1 pathList let opts = addOptions opts1 opts0 - let fpath = justInitPath file + let fpath = dropFileName file ps0 <- ioeIO $ pathListOpts opts fpath let ps1 = if (useFileOpt && not useLineOpt) - then (ps0 ++ map (prefixPathName fpath) ps0) + then (ps0 ++ map (combine fpath) ps0) else ps0 ps <- ioeIO $ extendPathEnv gfLibraryPath gfGrammarPathVar ps1 let ioeIOIf = if oElem beVerbose opts then ioeIO else (const (return ())) ioeIOIf $ putStrLn $ "module search path:" +++ show ps ---- let sgr = snd env let rfs = [] ---- files already in memory and their read times - let file' = if useFileOpt then justFileName file else file -- to find file itself + let file' = if useFileOpt then takeFileName file else file -- to find file itself files <- getAllFiles opts ps rfs file' ioeIOIf $ putStrLn $ "files to read:" +++ show files ---- let names = map justModuleName files ioeIOIf $ putStrLn $ "modules to include:" +++ show names ---- let sgr2 = MGrammar [m | m@(i,_) <- modules sgr, - notElem (prt i) $ map fileBody names] + notElem (prt i) $ map dropExtension names] foldM (compileOne opts) (0,sgr2) files @@ -95,16 +96,16 @@ compileOne opts env@(_,srcgr) file = do | oElem beSilent opts = putpp v act | otherwise = ioeIO (putStrFlush ("\n" ++ m)) >> act - let gf = fileSuffix file - let path = justInitPath file - let name = fileBody file + let gf = takeExtensions file + let path = dropFileName file + let name = dropExtension file let mos = modules srcgr case gf of -- for compiled gf, read the file and update environment -- also undo common subexp optimization, to enable normal computations - "gfo" -> do + ".gfo" -> do sm0 <- putp ("+ reading" +++ file) $ getSourceModule opts file let sm1 = unsubexpModule sm0 sm <- {- putp "creating indirections" $ -} ioeErr $ extendModule mos sm1 @@ -113,7 +114,7 @@ compileOne opts env@(_,srcgr) file = do -- for gf source, do full compilation and generate code _ -> do - let modu = unsuffixFile file + let modu = dropExtension file b1 <- ioeIO $ doesFileExist file if not b1 then compileOne opts env $ gfoFile $ modu @@ -174,7 +175,7 @@ compileSourceModule opts env@(k,gr) mo@(i,mi) = do generateModuleCode :: Options -> InitPath -> SourceModule -> IOE SourceModule generateModuleCode opts path minfo@(name,info) = do - let pname = prefixPathName path (prt name) + let pname = path </> prt name let minfo0 = minfo let minfo1 = subexpModule minfo0 let minfo2 = minfo1 @@ -191,7 +192,7 @@ generateModuleCode opts path minfo@(name,info) = do -- auxiliaries pathListOpts :: Options -> FileName -> IO [InitPath] -pathListOpts opts file = return $ maybe [file] pFilePaths $ getOptVal opts pathList +pathListOpts opts file = return $ maybe [file] splitInModuleSearchPath $ getOptVal opts pathList reverseModules (MGrammar ms) = MGrammar $ reverse ms |
