instance_of node

This commit is contained in:
z7zmey
2017-12-17 23:08:17 +02:00
parent 9095d3fef7
commit aa520300c0
3 changed files with 38 additions and 2 deletions

36
node/expr/instance_of.go Normal file
View File

@@ -0,0 +1,36 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type InstanceOf struct {
node.SimpleNode
expr node.Node
class node.Node
}
func NewInstanceOf(expr node.Node, class node.Node) node.Node {
return InstanceOf{
node.SimpleNode{Name: "InstanceOf", Attributes: make(map[string]string)},
expr,
class,
}
}
func (n InstanceOf) 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+" ")
}
if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ")
n.class.Print(out, indent+" ")
}
}