Commit 02ba9e95 by Zachary Snow

remove comments by default; added --verbose flag

parent b48ca0bb
...@@ -23,6 +23,7 @@ import qualified Convert.NamedBlock ...@@ -23,6 +23,7 @@ import qualified Convert.NamedBlock
import qualified Convert.NestPI import qualified Convert.NestPI
import qualified Convert.Package import qualified Convert.Package
import qualified Convert.PackedArray import qualified Convert.PackedArray
import qualified Convert.RemoveComments
import qualified Convert.Return import qualified Convert.Return
import qualified Convert.StarPort import qualified Convert.StarPort
import qualified Convert.StmtBlock import qualified Convert.StmtBlock
...@@ -56,6 +57,7 @@ phases excludes = ...@@ -56,6 +57,7 @@ phases excludes =
, Convert.Return.convert , Convert.Return.convert
, selectExclude (Job.Interface, Convert.Interface.convert) , selectExclude (Job.Interface, Convert.Interface.convert)
, selectExclude (Job.Always , Convert.AlwaysKW.convert) , selectExclude (Job.Always , Convert.AlwaysKW.convert)
, selectExclude (Job.Succinct , Convert.RemoveComments.convert)
] ]
where where
selectExclude :: (Job.Exclude, Phase) -> Phase selectExclude :: (Job.Exclude, Phase) -> Phase
......
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
- Conversion for removing any comments
-}
module Convert.RemoveComments (convert) where
import Convert.Traverse
import Language.SystemVerilog.AST
convert :: [AST] -> [AST]
convert = map convertFile
convertFile :: AST -> AST
convertFile =
traverseDescriptions (traverseModuleItems convertModuleItem) .
filter (not . isComment)
isComment :: Description -> Bool
isComment (PackageItem (Comment _)) = True
isComment _ = False
convertModuleItem :: ModuleItem -> ModuleItem
convertModuleItem (MIPackageItem (Comment _)) = Generate []
convertModuleItem other = other
...@@ -13,6 +13,7 @@ data Exclude ...@@ -13,6 +13,7 @@ data Exclude
= Always = Always
| Interface | Interface
| Logic | Logic
| Succinct
deriving (Show, Typeable, Data, Eq) deriving (Show, Typeable, Data, Eq)
data Job = Job data Job = Job
...@@ -21,6 +22,7 @@ data Job = Job ...@@ -21,6 +22,7 @@ data Job = Job
, incdir :: [FilePath] , incdir :: [FilePath]
, define :: [String] , define :: [String]
, oneunit :: Bool , oneunit :: Bool
, verbose :: Bool
} deriving (Show, Typeable, Data) } deriving (Show, Typeable, Data)
defaultJob :: Job defaultJob :: Job
...@@ -33,6 +35,7 @@ defaultJob = Job ...@@ -33,6 +35,7 @@ defaultJob = Job
++ " preprocessing") ++ " preprocessing")
, oneunit = False &= help ("put all files in one compilation unit, so" , oneunit = False &= help ("put all files in one compilation unit, so"
++ " macros from earlier files remain defined in later files") ++ " macros from earlier files remain defined in later files")
, verbose = False &= help "retain certain conversion artifacts"
} }
&= program "sv2v" &= program "sv2v"
&= summary "sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins" &= summary "sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins"
...@@ -40,4 +43,8 @@ defaultJob = Job ...@@ -40,4 +43,8 @@ defaultJob = Job
, "More info: https://github.com/zachjs/sv2v" ] , "More info: https://github.com/zachjs/sv2v" ]
readJob :: IO Job readJob :: IO Job
readJob = cmdArgs defaultJob readJob = do
job <- cmdArgs defaultJob
return $ if verbose job
then job { exclude = Succinct : exclude job }
else job
...@@ -67,6 +67,7 @@ executable sv2v ...@@ -67,6 +67,7 @@ executable sv2v
Convert.NestPI Convert.NestPI
Convert.Package Convert.Package
Convert.PackedArray Convert.PackedArray
Convert.RemoveComments
Convert.Return Convert.Return
Convert.StarPort Convert.StarPort
Convert.StmtBlock Convert.StmtBlock
......
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