class const node

This commit is contained in:
vadim
2017-12-06 19:58:12 +02:00
parent 01f7e3fe63
commit 3a5590d7bc
3 changed files with 51 additions and 8 deletions

43
node/stmt/class_const.go Normal file
View File

@@ -0,0 +1,43 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type ClassConst struct {
node.SimpleNode
token token.Token
modifiers []node.Node
consts []node.Node
}
func NewClassConst(token token.Token, modifiers []node.Node, consts []node.Node) node.Node {
return ClassConst{
node.SimpleNode{Name: "ClassConst", Attributes: make(map[string]string)},
token,
modifiers,
consts,
}
}
func (n ClassConst) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmotifiers:", indent+" ")
for _, nn := range n.modifiers {
nn.Print(out, indent+" ")
}
}
if n.consts != nil {
fmt.Fprintf(out, "\n%vconsts:", indent+" ")
for _, nn := range n.consts {
nn.Print(out, indent+" ")
}
}
}