From 3fd1f5652a3af22e90a040a821d244a91a3553a0 Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 28 May 2008 15:10:36 +0000 Subject: Switch to new options handling. This changes lots of stuff, let me know if it broke anything. Comments: - We use a local hacked version of GetOpt that allows long forms of commands to start with a single dash. This breaks other parts of GetOpt. For example, arguments to short options now require a =, and does not allo pace after the option character. - The new command parsing is currently only used for the program command line, pragmas and the arguments for the 'i' shell command. - I made a quick hack for the options for showTerm, which currently makes it impossible to use the print style flags for cc. This will be replaced by a facility for parsing command-specific options. - The verbosity handling is broken in some places. I will fix that in a later patch. --- src-3.0/GF/Compile/ReadFiles.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src-3.0/GF/Compile/ReadFiles.hs') diff --git a/src-3.0/GF/Compile/ReadFiles.hs b/src-3.0/GF/Compile/ReadFiles.hs index f1f94c105..cd2faec15 100644 --- a/src-3.0/GF/Compile/ReadFiles.hs +++ b/src-3.0/GF/Compile/ReadFiles.hs @@ -19,8 +19,9 @@ ----------------------------------------------------------------------------- module GF.Compile.ReadFiles - ( getAllFiles,ModName,ModEnv,getOptionsFromFile,importsOfModule, - gfoFile,gfFile,isGFO ) where + ( getAllFiles,ModName,ModEnv,importsOfModule, + gfoFile,gfFile,isGFO, + getOptionsFromFile) where import GF.Infra.UseIO import GF.Infra.Option @@ -48,9 +49,7 @@ getAllFiles :: Options -> [InitPath] -> ModEnv -> FileName -> IOE [FullPath] getAllFiles opts ps env file = do -- read module headers from all files recursively ds <- liftM reverse $ get [] [] (justModuleName file) - if oElem beVerbose opts - then ioeIO $ putStrLn $ "all modules:" +++ show [name | (name,_,_,_,_) <- ds] - else return () + ioeIO $ putIfVerb opts $ "all modules:" +++ show [name | (name,_,_,_,_) <- ds] return $ paths ds where -- construct list of paths to read @@ -135,8 +134,8 @@ selectFormat opts mtenv mtgf mtgfo = (_,_, Nothing) -> (CSRead,Nothing) -- source does not exist _ -> (CSComp,Nothing) where - fromComp = oElem isCompiled opts -- i -gfo - fromSrc = oElem fromSource opts + fromComp = flag optRecomp opts == NeverRecomp + fromSrc = flag optRecomp opts == AlwaysRecomp -- internal module dep information @@ -188,8 +187,9 @@ importsOfModule (MModule _ typ body) = modType typ (modBody body []) -- | options can be passed to the compiler by comments in @--#@, in the main file -getOptionsFromFile :: FilePath -> IO Options +getOptionsFromFile :: FilePath -> IOE Options getOptionsFromFile file = do - s <- readFileIfStrict file + s <- ioeIO $ readFileIfStrict file let ls = filter (BS.isPrefixOf (BS.pack "--#")) $ BS.lines s - return $ fst $ getOptions "-" $ map (BS.unpack . BS.unwords . BS.words . BS.drop 3) ls + fs = map (BS.unpack . BS.unwords . BS.words . BS.drop 3) ls + ioeErr $ liftM moduleOptions $ parseModuleOptions fs -- cgit v1.2.3