summaryrefslogtreecommitdiff
path: root/utils/check-ppr/Main.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2016-12-26 10:02:43 -0500
committerBen Gamari <ben@smart-cactus.org>2016-12-26 10:02:43 -0500
commit9331e338a7a8f78c05ef89684ab1a5bb7c79d37d (patch)
treeabdd5e941a64f64f009228ef3edff05b3e12fac7 /utils/check-ppr/Main.hs
parent48a5da9ac6abd42e713402bd38612ce6624cac1b (diff)
downloadhaskell-9331e338a7a8f78c05ef89684ab1a5bb7c79d37d.tar.gz
check-ppr: Make --dump the default behavior
Diffstat (limited to 'utils/check-ppr/Main.hs')
-rw-r--r--utils/check-ppr/Main.hs17
1 files changed, 6 insertions, 11 deletions
diff --git a/utils/check-ppr/Main.hs b/utils/check-ppr/Main.hs
index c9fac7dc33..ef39831bb1 100644
--- a/utils/check-ppr/Main.hs
+++ b/utils/check-ppr/Main.hs
@@ -23,25 +23,21 @@ import qualified Data.Map as Map
usage :: String
usage = unlines
- [ "usage: check-ppr [--dump] (libdir) (file)"
+ [ "usage: check-ppr (libdir) (file)"
, ""
, "where libdir is the GHC library directory (e.g. the output of"
, "ghc --print-libdir) and file is the file to parse."
- , "The --dump flag causes check-ppr to produce .new and .old files"
- , "containing dumps of the new and old ASTs in the event of a match"
- , "failure."
]
main :: IO()
main = do
args <- getArgs
case args of
- [libdir,fileName] -> testOneFile libdir fileName False
- ["--dump", libdir,fileName] -> testOneFile libdir fileName True
+ [libdir,fileName] -> testOneFile libdir fileName
_ -> putStrLn usage
-testOneFile :: FilePath -> String -> Bool -> IO ()
-testOneFile libdir fileName dumpOldNew = do
+testOneFile :: FilePath -> String -> IO ()
+testOneFile libdir fileName = do
p <- parseOneFile libdir fileName
let
origAst = showAstData 0 (pm_parsed_source p)
@@ -51,6 +47,7 @@ testOneFile libdir fileName dumpOldNew = do
newFile = dropExtension fileName <.> "ppr" <.> takeExtension fileName
astFile = fileName <.> "ast"
+ newAstFile = fileName <.> "ast.new"
writeFile astFile origAst
writeFile newFile pped
@@ -58,6 +55,7 @@ testOneFile libdir fileName dumpOldNew = do
p' <- parseOneFile libdir newFile
let newAstStr = showAstData 0 (pm_parsed_source p')
+ writeFile newAstFile newAstStr
if origAst == newAstStr
then do
@@ -69,9 +67,6 @@ testOneFile libdir fileName dumpOldNew = do
putStrLn origAst
putStrLn "\n===================================\nNew\n\n"
putStrLn newAstStr
- when dumpOldNew $ do
- writeFile (fileName <.> "old") origAst
- writeFile (fileName <.> "new") newAstStr
exitFailure