Attr.hs 703 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 27 28 29
{- sv2v
 - Author: Zachary Snow <zach@zachjs.com>
 - Initial Verilog AST Author: Tom Hawkins <tomahawkins@gmail.com>
 -
 - SystemVerilog attribute instances
 -}

module Language.SystemVerilog.AST.Attr
    ( Attr (..)
    , AttrSpec
    ) where

import Text.Printf (printf)

import Language.SystemVerilog.AST.ShowHelp (commas)
import Language.SystemVerilog.AST.Expr (Expr, showAssignment)
import Language.SystemVerilog.AST.Type (Identifier)

data Attr
    = Attr [AttrSpec]
    deriving Eq

type AttrSpec = (Identifier, Maybe Expr)

instance Show Attr where
    show (Attr specs) = printf "(* %s *)" $ commas $ map showSpec specs

showSpec :: AttrSpec -> String
showSpec (x, me) = x ++ showAssignment me