mirror of https://github.com/zachjs/sv2v.git
remove comments by default; added --verbose flag
This commit is contained in:
parent
b48ca0bb8f
commit
02ba9e95df
|
|
@ -23,6 +23,7 @@ import qualified Convert.NamedBlock
|
|||
import qualified Convert.NestPI
|
||||
import qualified Convert.Package
|
||||
import qualified Convert.PackedArray
|
||||
import qualified Convert.RemoveComments
|
||||
import qualified Convert.Return
|
||||
import qualified Convert.StarPort
|
||||
import qualified Convert.StmtBlock
|
||||
|
|
@ -56,6 +57,7 @@ phases excludes =
|
|||
, Convert.Return.convert
|
||||
, selectExclude (Job.Interface, Convert.Interface.convert)
|
||||
, selectExclude (Job.Always , Convert.AlwaysKW.convert)
|
||||
, selectExclude (Job.Succinct , Convert.RemoveComments.convert)
|
||||
]
|
||||
where
|
||||
selectExclude :: (Job.Exclude, Phase) -> Phase
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
{- 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
|
|||
= Always
|
||||
| Interface
|
||||
| Logic
|
||||
| Succinct
|
||||
deriving (Show, Typeable, Data, Eq)
|
||||
|
||||
data Job = Job
|
||||
|
|
@ -21,6 +22,7 @@ data Job = Job
|
|||
, incdir :: [FilePath]
|
||||
, define :: [String]
|
||||
, oneunit :: Bool
|
||||
, verbose :: Bool
|
||||
} deriving (Show, Typeable, Data)
|
||||
|
||||
defaultJob :: Job
|
||||
|
|
@ -33,6 +35,7 @@ defaultJob = Job
|
|||
++ " preprocessing")
|
||||
, oneunit = False &= help ("put all files in one compilation unit, so"
|
||||
++ " macros from earlier files remain defined in later files")
|
||||
, verbose = False &= help "retain certain conversion artifacts"
|
||||
}
|
||||
&= program "sv2v"
|
||||
&= summary "sv2v v0.0.1, (C) 2019 Zachary Snow, 2011-2015 Tom Hawkins"
|
||||
|
|
@ -40,4 +43,8 @@ defaultJob = Job
|
|||
, "More info: https://github.com/zachjs/sv2v" ]
|
||||
|
||||
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
|
|||
Convert.NestPI
|
||||
Convert.Package
|
||||
Convert.PackedArray
|
||||
Convert.RemoveComments
|
||||
Convert.Return
|
||||
Convert.StarPort
|
||||
Convert.StmtBlock
|
||||
|
|
|
|||
Loading…
Reference in New Issue