php-parser/node/expr/variable.go

34 lines
519 B
Go
Raw Normal View History

2017-12-06 13:04:44 +00:00
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
2017-12-27 17:55:58 +00:00
func (n Variable) Name() string {
return "Variable"
}
2017-12-06 13:04:44 +00:00
type Variable struct {
2017-12-27 17:55:58 +00:00
name string
variable node.Node
2017-12-06 13:04:44 +00:00
}
2017-12-27 17:55:58 +00:00
func NewVariable(variable node.Node) node.Node {
2017-12-06 13:04:44 +00:00
return Variable{
2017-12-27 17:55:58 +00:00
"Variable",
variable,
2017-12-06 13:04:44 +00:00
}
}
func (n Variable) 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-18 18:35:29 +00:00
2017-12-27 17:55:58 +00:00
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
2017-12-18 18:35:29 +00:00
}
2017-12-06 13:04:44 +00:00
}