From 5eef44c8f426017cec7ac2076f34108b216236e3 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Mon, 14 Jun 2021 15:45:24 -0400 Subject: [PATCH] Add file output write mode --- src/Job.hs | 4 +++- src/sv2v.hs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Job.hs b/src/Job.hs index bdb7b3a..6d577e1 100644 --- a/src/Job.hs +++ b/src/Job.hs @@ -26,6 +26,7 @@ data Exclude data Write = Stdout | Adjacent + | File deriving (Show, Typeable, Data, Eq) instance Default Write where @@ -66,7 +67,8 @@ defaultJob = Job , verbose = nam "verbose" &= help "Retain certain conversion artifacts" , write = nam_ "write" &= name "w" &= typ "MODE" &= help ("How to write output; default is 'stdout'; use 'adjacent' to" - ++ " create a .v file next to each input") + ++ " create a .v file next to each input; use 'file' to create a" + ++ " sv2v_output.v file") } &= program "sv2v" &= summary ("sv2v " ++ version) diff --git a/src/sv2v.hs b/src/sv2v.hs index 379ea4a..43ff3e1 100644 --- a/src/sv2v.hs +++ b/src/sv2v.hs @@ -64,6 +64,9 @@ writeOutput _ [] [] = hPutStrLn stderr "Warning: No input files specified (try `sv2v --help`)" writeOutput Stdout _ asts = hPrint stdout $ concat asts +writeOutput File _ asts = + writeFile f $ show $ concat asts + where f = "sv2v_output.v" writeOutput Adjacent inPaths asts = do outPaths <- mapM rewritePath inPaths badPaths <- filterM doesFileExist outPaths