php-parser/node/argument.go

35 lines
563 B
Go
Raw Normal View History

2017-12-27 14:26:36 +00:00
package node
import (
"fmt"
"io"
)
type Argument struct {
2017-12-27 17:55:58 +00:00
name string
2017-12-27 14:26:36 +00:00
expr Node
variadic bool
}
2017-12-27 17:55:58 +00:00
func (n Argument) Name() string {
return "Argument"
}
2017-12-27 14:26:36 +00:00
func NewArgument(expression Node, variadic bool) Node {
return Argument{
2017-12-27 17:55:58 +00:00
"Argument",
2017-12-27 14:26:36 +00:00
expression,
variadic,
}
}
func (n Argument) 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
fmt.Fprintf(out, "\n%vvariadic: %t", indent+" ", n.variadic)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
}
}