1
0
forked from GitHub/gf-core

gf3 should not exit if there is a syntax error in the file

This commit is contained in:
krasimir
2008-04-17 12:50:51 +00:00
parent 08f92cd180
commit 0ea2798b3c
4 changed files with 24 additions and 21 deletions

View File

@@ -30,13 +30,12 @@ import GF.Devel.Arch
import Control.Monad
import System.Directory
batchCompile :: Options -> [FilePath] -> IO SourceGrammar
batchCompile :: Options -> [FilePath] -> IOE SourceGrammar
batchCompile opts files = do
let defOpts = addOptions opts (options [emitCode])
egr <- appIOE $ foldM (compileModule defOpts) emptyCompileEnv files
case egr of
Ok (_,gr) -> return gr
Bad s -> error s
(_,gr) <- foldM (compileModule defOpts) emptyCompileEnv files
return gr
where
defOpts = addOptions opts (options [emitCode])
-- to output an intermediate stage
intermOut :: Options -> Option -> String -> IOE ()
@@ -83,10 +82,7 @@ compileModule opts1 env file = do
ioeIOIf $ putStrLn $ "modules to include:" +++ show names ----
let sgr2 = MGrammar [m | m@(i,_) <- modules sgr,
notElem (prt i) $ map fileBody names]
let env0 = (0,sgr2)
(e,mm) <- foldIOE (compileOne opts) env0 files
maybe (return ()) putStrLnE mm
return e
foldM (compileOne opts) (0,sgr2) files
compileOne :: Options -> CompileEnv -> FullPath -> IOE CompileEnv

View File

@@ -18,7 +18,7 @@ mainGFC xx = do
case opts of
_ | oElem (iOpt "help") opts -> putStrLn usageMsg
_ | oElem (iOpt "-make") opts -> do
gfcc <- compileToGFCC opts fs
gfcc <- appIOE (compileToGFCC opts fs) >>= err fail return
let gfccFile = targetNameGFCC opts (absname gfcc)
outputFile gfccFile (printGFCC gfcc)
mapM_ (alsoPrint opts gfcc) printOptions
@@ -32,7 +32,7 @@ mainGFC xx = do
mapM_ (alsoPrint opts gfcc) printOptions
_ -> do
mapM_ (batchCompile opts) (map return fs)
appIOE (mapM_ (batchCompile opts) (map return fs)) >>= err fail return
putStrLn "Done."
targetName :: Options -> CId -> String