namespace node

This commit is contained in:
vadim
2017-12-08 12:16:04 +02:00
parent 92688ac8d2
commit 32b05a653b
3 changed files with 47 additions and 6 deletions

41
node/stmt/namespace.go Normal file
View File

@@ -0,0 +1,41 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type Namespace struct {
node.SimpleNode
token token.Token
name node.Node
stmts []node.Node
}
func NewNamespace(token token.Token, name node.Node, stmts []node.Node) node.Node {
return Namespace{
node.SimpleNode{Name: "Namespace", Attributes: make(map[string]string)},
token,
name,
stmts,
}
}
func (n Namespace) 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.name != nil {
fmt.Fprintf(out, "\n%vname:", indent+" ")
n.name.Print(out, indent+" ")
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
}
}
}