From 61c16f2eb2a042152a2b04f709d0cefe6e5a14df Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 15 Nov 2011 13:33:44 +0000 Subject: more structured format for errors and warnings from the compiler --- src/compiler/GF/Compile.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/compiler/GF/Compile.hs') diff --git a/src/compiler/GF/Compile.hs b/src/compiler/GF/Compile.hs index aac2a0fb7..e4fe85aef 100644 --- a/src/compiler/GF/Compile.hs +++ b/src/compiler/GF/Compile.hs @@ -82,6 +82,13 @@ intermOut opts d doc | dump opts d = ioeIO (hPutStrLn stderr (render (text "\n\n--#" <+> text (show d) $$ doc))) | otherwise = return () +warnOut opts warnings + | null warnings = return () + | otherwise = ioeIO (hPutStrLn stderr $ + if flag optVerbosity opts == Normal + then ('\n':warnings) + else warnings) + -- | the environment type CompileEnv = (Int,SourceGrammar,ModEnv) @@ -173,8 +180,7 @@ compileOne opts env@(_,srcgr,_) file = do compileSourceModule :: Options -> CompileEnv -> Maybe FilePath -> SourceModule -> IOE CompileEnv compileSourceModule opts env@(k,gr,_) mb_gfFile mo@(i,mi) = do - let puts = putPointE Quiet opts - putpp = putPointE Verbose opts + let putpp = putPointE Verbose opts mo1 <- ioeErr $ rebuildModule gr mo intermOut opts DumpRebuild (ppModule Qualified mo1) @@ -198,11 +204,11 @@ compileSourceModule opts env@(k,gr,_) mb_gfFile mo@(i,mi) = do let mos = modules gr (mo2,warnings) <- putpp " renaming " $ ioeErr $ runCheck (renameModule mos mo1b) - if null warnings then return () else puts warnings $ return () + warnOut opts warnings intermOut opts DumpRename (ppModule Qualified mo2) (mo3,warnings) <- putpp " type checking" $ ioeErr $ runCheck (checkModule mos mo2) - if null warnings then return () else puts warnings $ return () + warnOut opts warnings intermOut opts DumpTypeCheck (ppModule Qualified mo3) if not (flag optTagsOnly opts) -- cgit v1.2.3