LHS.hs 1.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{- sv2v
 - Author: Zachary Snow <zach@zachjs.com>
 - Initial Verilog AST Author: Tom Hawkins <tomahawkins@gmail.com>
 -
 - SystemVerilog left-hand sides (aka lvals)
 -}

module Language.SystemVerilog.AST.LHS
    ( LHS (..)
    ) where

import Text.Printf (printf)

import Language.SystemVerilog.AST.ShowHelp (commas)
import Language.SystemVerilog.AST.Type (Identifier)
16
import Language.SystemVerilog.AST.Expr (Expr, PartSelectMode, Range)
17
import Language.SystemVerilog.AST.Op (StreamOp)
18 19 20 21

data LHS
    = LHSIdent  Identifier
    | LHSBit    LHS Expr
22
    | LHSRange  LHS PartSelectMode Range
23 24
    | LHSDot    LHS Identifier
    | LHSConcat [LHS]
25
    | LHSStream StreamOp Expr [LHS]
26 27 28
    deriving Eq

instance Show LHS where
29 30 31 32
    show (LHSIdent x         ) = x
    show (LHSBit   l e       ) = printf "%s[%s]"     (show l) (show e)
    show (LHSRange l m (a, b)) = printf "%s[%s%s%s]" (show l) (show a) (show m) (show b)
    show (LHSDot   l x       ) = printf "%s.%s"      (show l) x
33 34
    show (LHSConcat      lhss) = printf "{%s}"       (commas $ map show lhss)
    show (LHSStream  o e lhss) = printf "{%s %s%s}"  (show o) (show e) (show $ LHSConcat lhss)