diff options
-rw-r--r-- | utils/check-ppr/Main.hs | 17 |
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 |