RemoveComments.hs 629 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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