fix the generation of warnings in CheckGrammar. They are printed even in quiet mode and the prefix "Warning" is added automatically

This commit is contained in:
krasimir
2009-05-20 17:05:58 +00:00
parent 4e2e2b2535
commit baf56d651c
5 changed files with 20 additions and 15 deletions

View File

@@ -194,7 +194,7 @@ compileOne opts env@(_,srcgr,_) file = do
compileSourceModule :: Options -> CompileEnv -> SourceModule -> IOE (Int,SourceModule) compileSourceModule :: Options -> CompileEnv -> SourceModule -> IOE (Int,SourceModule)
compileSourceModule opts env@(k,gr,_) mo@(i,mi) = do compileSourceModule opts env@(k,gr,_) mo@(i,mi) = do
let putp = putPointE Normal opts let puts = putPointE Quiet opts
putpp = putPointE Verbose opts putpp = putPointE Verbose opts
mo1 <- ioeErr $ rebuildModule gr mo mo1 <- ioeErr $ rebuildModule gr mo
@@ -213,7 +213,7 @@ compileSourceModule opts env@(k,gr,_) mo@(i,mi) = do
intermOut opts DumpRename (ppModule Qualified mo2) intermOut opts DumpRename (ppModule Qualified mo2)
(mo3:_,warnings) <- putpp " type checking" $ ioeErr $ showCheckModule mos mo2 (mo3:_,warnings) <- putpp " type checking" $ ioeErr $ showCheckModule mos mo2
if null warnings then return () else putp warnings $ return () if null warnings then return () else puts warnings $ return ()
intermOut opts DumpTypeCheck (ppModule Qualified mo3) intermOut opts DumpTypeCheck (ppModule Qualified mo3)
(k',mo3r:_) <- putpp " refreshing " $ ioeErr $ refreshModule (k,mos) mo3 (k',mo3r:_) <- putpp " refreshing " $ ioeErr $ refreshModule (k,mos) mo3

View File

@@ -182,7 +182,7 @@ checkCompleteGrammar gr abs cnc = do
-- remove those lincat and lin in concrete that are not in abstract -- remove those lincat and lin in concrete that are not in abstract
let unkn = filter (not . flip isInBinTree jsa) fsc let unkn = filter (not . flip isInBinTree jsa) fsc
jsc1 <- if (null unkn) then return jsc else do jsc1 <- if (null unkn) then return jsc else do
checkWarn $ "WARNING: ignoring constants not in abstract:" +++ checkWarn $ "ignoring constants not in abstract:" +++
unwords (map prt unkn) unwords (map prt unkn)
return $ filterBinTree (\f _ -> notElem f unkn) jsc return $ filterBinTree (\f _ -> notElem f unkn) jsc
@@ -209,24 +209,24 @@ checkCompleteGrammar gr abs cnc = do
Ok (CncFun cty Nothing pn) -> Ok (CncFun cty Nothing pn) ->
case mb_def of case mb_def of
Ok def -> return $ updateTree (c,CncFun cty (Just def) pn) js Ok def -> return $ updateTree (c,CncFun cty (Just def) pn) js
Bad _ -> do checkWarn $ "WARNING: no linearization of" +++ prt c Bad _ -> do checkWarn $ "no linearization of" +++ prt c
return js return js
_ -> do _ -> do
case mb_def of case mb_def of
Ok def -> return $ updateTree (c,CncFun Nothing (Just def) Nothing) js Ok def -> return $ updateTree (c,CncFun Nothing (Just def) Nothing) js
Bad _ -> do checkWarn $ "WARNING: no linearization of" +++ prt c Bad _ -> do checkWarn $ "no linearization of" +++ prt c
return js return js
AbsCat (Just _) _ -> case lookupIdent c js of AbsCat (Just _) _ -> case lookupIdent c js of
Ok (AnyInd _ _) -> return js Ok (AnyInd _ _) -> return js
Ok (CncCat (Just _) _ _) -> return js Ok (CncCat (Just _) _ _) -> return js
Ok (CncCat _ mt mp) -> do Ok (CncCat _ mt mp) -> do
checkWarn $ checkWarn $
"Warning: no linearization type for" +++ prt c ++ "no linearization type for" +++ prt c ++
", inserting default {s : Str}" ", inserting default {s : Str}"
return $ updateTree (c,CncCat (Just defLinType) mt mp) js return $ updateTree (c,CncCat (Just defLinType) mt mp) js
_ -> do _ -> do
checkWarn $ checkWarn $
"Warning: no linearization type for" +++ prt c ++ "no linearization type for" +++ prt c ++
", inserting default {s : Str}" ", inserting default {s : Str}"
return $ updateTree (c,CncCat (Just defLinType) Nothing Nothing) js return $ updateTree (c,CncCat (Just defLinType) Nothing Nothing) js
_ -> return js _ -> return js
@@ -421,7 +421,7 @@ checkPrintname _ _ = return ()
-- | for grammars obtained otherwise than by parsing ---- update!! -- | for grammars obtained otherwise than by parsing ---- update!!
checkReservedId :: Ident -> Check () checkReservedId :: Ident -> Check ()
checkReservedId x checkReservedId x
| isReservedWord (ident2bs x) = checkWarn ("Warning: reserved word used as identifier:" +++ prt x) | isReservedWord (ident2bs x) = checkWarn ("reserved word used as identifier:" +++ prt x)
| otherwise = return () | otherwise = return ()
-- to normalize records and record types -- to normalize records and record types
@@ -532,7 +532,7 @@ inferLType gr trm = case trm of
then do then do
let ss = foldr C Empty (map K (words s)) let ss = foldr C Empty (map K (words s))
----- removed irritating warning AR 24/5/2008 ----- removed irritating warning AR 24/5/2008
----- checkWarn ("WARNING: token \"" ++ s ++ ----- checkWarn ("token \"" ++ s ++
----- "\" converted to token list" ++ prt ss) ----- "\" converted to token list" ++ prt ss)
return (ss, typeStr) return (ss, typeStr)
else return (trm, typeStr) else return (trm, typeStr)
@@ -552,7 +552,7 @@ inferLType gr trm = case trm of
---- hack from Rename.identRenameTerm, to live with files with naming conflicts 18/6/2007 ---- hack from Rename.identRenameTerm, to live with files with naming conflicts 18/6/2007
Strs (Cn c : ts) | c == cConflict -> do Strs (Cn c : ts) | c == cConflict -> do
trace ("WARNING: unresolved constant, could be any of" +++ unwords (map prt ts)) (infer $ head ts) trace ("WARNING: unresolved constant, could be any of" +++ unwords (map prt ts)) (infer $ head ts)
-- checkWarn ("WARNING: unresolved constant, could be any of" +++ unwords (map prt ts)) -- checkWarn ("unresolved constant, could be any of" +++ unwords (map prt ts))
-- infer $ head ts -- infer $ head ts
Strs ts -> do Strs ts -> do
@@ -714,7 +714,7 @@ getOverload env@gr mt ot = case appForm ot of
return (mkApp fun tts, val) return (mkApp fun tts, val)
----- unsafely exclude irritating warning AR 24/5/2008 ----- unsafely exclude irritating warning AR 24/5/2008
----- checkWarn $ "WARNING: overloading of" +++ prt f +++ ----- checkWarn $ "overloading of" +++ prt f +++
----- "resolved by excluding partial applications:" ++++ ----- "resolved by excluding partial applications:" ++++
----- unlines [prtType env ty | (ty,_) <- vfs', not (noProd ty)] ----- unlines [prtType env ty | (ty,_) <- vfs', not (noProd ty)]
@@ -791,7 +791,7 @@ checkLType env trm typ0 = do
ps <- checkErr $ testOvershadow ps0 vs ps <- checkErr $ testOvershadow ps0 vs
if null ps if null ps
then return () then return ()
---- else checkWarn $ "WARNING: patterns never reached:" +++ ---- else checkWarn $ "patterns never reached:" +++
---- concat (intersperse ", " (map prt ps)) ---- concat (intersperse ", " (map prt ps))
else trace ("WARNING: patterns never reached:" +++ else trace ("WARNING: patterns never reached:" +++
concat (intersperse ", " (map prt ps))) (return ()) concat (intersperse ", " (map prt ps))) (return ())
@@ -1002,7 +1002,7 @@ checkIfEqLType env t u trm = do
--- better: use a flag to forgive? (AR 31/1/2006) --- better: use a flag to forgive? (AR 31/1/2006)
_ -> case missingLock [] t' u' of _ -> case missingLock [] t' u' of
Ok lo -> do Ok lo -> do
checkWarn $ "WARNING: missing lock field" +++ unwords (map prt lo) checkWarn $ "missing lock field" +++ unwords (map prt lo)
return (True,t',u',[]) return (True,t',u',[])
Bad s -> return (False,t',u',s) Bad s -> return (False,t',u',s)

View File

@@ -35,7 +35,7 @@ checkCond s b = if b then return () else checkError s
-- | warnings should be reversed in the end -- | warnings should be reversed in the end
checkWarn :: String -> Check () checkWarn :: String -> Check ()
checkWarn s = updateSTM (\ (cont,msg) -> (cont, s:msg)) checkWarn s = updateSTM (\ (cont,msg) -> (cont, ("Warning: "++s):msg))
checkUpdate :: Decl -> Check () checkUpdate :: Decl -> Check ()
checkUpdate d = updateSTM (\ (cont,msg) -> (d:cont, msg)) checkUpdate d = updateSTM (\ (cont,msg) -> (d:cont, msg))

View File

@@ -1,2 +1,2 @@
i -erasing=on testsuite\check\lins\linsCnc.gf i -src -erasing=on testsuite\check\lins\linsCnc.gf
pg -printer=pmcfg_pretty pg -printer=pmcfg_pretty

View File

@@ -1,3 +1,8 @@
checking module linsCnc
Warning: no linearization type for C, inserting default {s : Str}
checking module linsCnc
Warning: no linearization of test Warning: no linearization of test