print node

This commit is contained in:
z7zmey
2017-12-18 19:03:39 +02:00
parent b5dc115ff1
commit a73b9a9478
3 changed files with 31 additions and 2 deletions

29
node/expr/print.go Normal file
View File

@@ -0,0 +1,29 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type Print struct {
node.SimpleNode
expr node.Node
}
func NewPrint(expression node.Node) node.Node {
return Print{
node.SimpleNode{Name: "Print", Attributes: make(map[string]string)},
expression,
}
}
func (n Print) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
}
}