php-parser/node/nullable.go

32 lines
450 B
Go
Raw Normal View History

2017-12-27 14:26:36 +00:00
package node
import (
"fmt"
"io"
)
type Nullable struct {
2017-12-27 17:55:58 +00:00
name string
2017-12-27 14:26:36 +00:00
expr Node
}
2017-12-27 17:55:58 +00:00
func (n Nullable) Name() string {
return "Nullable"
}
2017-12-27 14:26:36 +00:00
func NewNullable(expression Node) Node {
return Nullable{
2017-12-27 17:55:58 +00:00
"Nullable",
2017-12-27 14:26:36 +00:00
expression,
}
}
func (n Nullable) Print(out io.Writer, indent string) {
2017-12-27 17:55:58 +00:00
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
2017-12-27 14:26:36 +00:00
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
}
}