From 6197aa5afb5280d58bf8fafbca8202c5bfc3aa3e Mon Sep 17 00:00:00 2001 From: z7zmey Date: Sat, 31 Mar 2018 13:50:35 +0300 Subject: [PATCH] pretty printer: remove func printStmt --- printer/printer.go | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/printer/printer.go b/printer/printer.go index bd1d738..50d36d9 100644 --- a/printer/printer.go +++ b/printer/printer.go @@ -19,21 +19,6 @@ func Print(o io.Writer, n node.Node) { 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) { for k, n := range nn { if k > 0 { @@ -1459,7 +1444,19 @@ func printStmtDeclare(o io.Writer, n node.Node) { io.WriteString(o, "declare(") joinPrint(", ", o, nn.Consts) 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) {