forked from GitHub/gf-core
gf3 should not exit if there is a syntax error in the file
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user