Commit 945923b3 by Zachary Snow

cleaned up command line args module a bit

parent 7bc81ef6
......@@ -7,7 +7,7 @@
module Convert (convert) where
import Language.SystemVerilog.AST
import qualified Args as Args
import Job (Target(..))
import qualified Convert.AlwaysKW
import qualified Convert.CaseKW
......@@ -19,24 +19,24 @@ import qualified Convert.StarPort
type Phase = AST -> AST
phases :: Args.Target -> [Phase]
phases Args.YOSYS =
phases :: Target -> [Phase]
phases YOSYS =
[ Convert.Typedef.convert
, Convert.PackedArray.convert
, Convert.StarPort.convert
]
phases Args.VTR =
(phases Args.YOSYS) ++
phases VTR =
(phases YOSYS) ++
[ Convert.AlwaysKW.convert
, Convert.CaseKW.convert
, Convert.Logic.convert
, Convert.SplitPortDecl.convert
]
run :: Args.Target -> Phase
run :: Target -> Phase
run target = foldr (.) id $ phases target
convert :: Args.Target -> Phase
convert :: Target -> Phase
convert target = convert'
where
convert' :: Phase
......
......@@ -5,7 +5,7 @@
- Command line arguments.
-}
module Args where
module Job where
import System.Console.CmdArgs
......@@ -28,5 +28,5 @@ defaultJob = Job
&= details [ "sv2v converts SystemVerilog to Verilog."
, "More info: https://github.com/zachjs/sv2v" ]
readArgs :: IO Job
readArgs = cmdArgs defaultJob
readJob :: IO Job
readJob = cmdArgs defaultJob
{-# LANGUAGE DeriveDataTypeable #-}
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
......@@ -8,21 +7,19 @@
import System.IO
import System.Exit
import Args (readArgs, target, file)
import Job (readJob, file, target)
import Convert (convert)
import Language.SystemVerilog.Parser
main :: IO ()
main = do
args <- readArgs
let filePath = file args
job <- readJob
-- parse the input file
let filePath = file job
content <- readFile filePath
let ast = parseFile [] filePath content
let res = Right (convert (target args) ast)
case res of
Left _ -> do
--hPrint stderr err
exitFailure
Right str -> do
hPrint stdout str
exitSuccess
-- convert the file
let ast' = convert (target job) ast
-- print the converted file out
hPrint stdout ast'
exitSuccess
......@@ -48,7 +48,7 @@ executable sv2v
Convert.Typedef
Convert.Traverse
-- sv2v CLI modules
Args
Job
ghc-options:
-O3
-threaded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment