@@ -25,7 +25,7 @@ module Language.SystemVerilog.AST.Stmt
2525
2626import Text.Printf (printf )
2727
28- import Language.SystemVerilog.AST.ShowHelp (commas , indent , unlines' , showPad )
28+ import Language.SystemVerilog.AST.ShowHelp (commas , indent , unlines' , showPad , showBlock )
2929import Language.SystemVerilog.AST.Attr (Attr )
3030import Language.SystemVerilog.AST.Decl (Decl )
3131import Language.SystemVerilog.AST.Expr (Expr (Inside , Nil ), Args (.. ), showExprOrRange )
@@ -57,13 +57,13 @@ data Stmt
5757 deriving Eq
5858
5959instance Show Stmt where
60+ showList l _ = unlines' $ map show l
6061 show (StmtAttr attr stmt) = printf " %s\n %s" (show attr) (show stmt)
6162 show (Block kw name decls stmts) =
6263 printf " %s%s\n %s\n %s" (show kw) header body (blockEndToken kw)
6364 where
6465 header = if null name then " " else " : " ++ name
65- bodyLines = (map show decls) ++ (map show stmts)
66- body = indent $ unlines' bodyLines
66+ body = showBlock decls stmts
6767 show (Case u kw e cs) =
6868 printf " %s%s (%s)\n %s\n endcase" (showPad u) (show kw) (show e) bodyStr
6969 where bodyStr = indent $ unlines' $ map showCase cs
@@ -104,9 +104,8 @@ instance Show Stmt where
104104 else " // " ++ c
105105
106106showBranch :: Stmt -> String
107- showBranch (Block Seq " " [] [CommentStmt c, stmt]) =
108- ' \n ' : (indent $ unlines' $ map show stmts)
109- where stmts = [CommentStmt c, stmt]
107+ showBranch (Block Seq " " [] (stmts @ [CommentStmt {}, _])) =
108+ ' \n ' : (indent $ show stmts)
110109showBranch (block @ Block {}) = ' ' : show block
111110showBranch stmt = ' \n ' : (indent $ show stmt)
112111
0 commit comments