pretty printer: remove func printStmt

This commit is contained in:
z7zmey 2018-03-31 13:50:35 +03:00
parent 0c1ac1c4a6
commit 6197aa5afb

View File

@ -19,21 +19,6 @@ func Print(o io.Writer, n node.Node) {
fn(o, n) fn(o, n)
} }
func printStmt(o io.Writer, n node.Node) {
switch nn := n.(type) {
case *stmt.Nop:
Print(o, nn)
break
case *stmt.StmtList:
io.WriteString(o, " {\n")
printNodes(o, nn.Stmts)
io.WriteString(o, "}\n")
default:
io.WriteString(o, "\n")
Print(o, nn)
}
}
func joinPrint(glue string, o io.Writer, nn []node.Node) { func joinPrint(glue string, o io.Writer, nn []node.Node) {
for k, n := range nn { for k, n := range nn {
if k > 0 { if k > 0 {
@ -1459,7 +1444,19 @@ func printStmtDeclare(o io.Writer, n node.Node) {
io.WriteString(o, "declare(") io.WriteString(o, "declare(")
joinPrint(", ", o, nn.Consts) joinPrint(", ", o, nn.Consts)
io.WriteString(o, ")") io.WriteString(o, ")")
printStmt(o, nn.Stmt)
switch s := nn.Stmt.(type) {
case *stmt.Nop:
Print(o, s)
break
case *stmt.StmtList:
io.WriteString(o, " {\n")
printNodes(o, s.Stmts)
io.WriteString(o, "}\n")
default:
io.WriteString(o, "\n")
Print(o, s)
}
} }
func printStmtDefault(o io.Writer, n node.Node) { func printStmtDefault(o io.Writer, n node.Node) {