This commit is contained in:
z7zmey
2017-12-28 01:23:32 +02:00
parent 32a285b437
commit 79d3bb1674
159 changed files with 1659 additions and 1015 deletions

View File

@@ -1,9 +1,6 @@
package name
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
@@ -23,13 +20,15 @@ func NewName(parts []node.Node) node.Node {
}
}
func (n NameNode) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v", indent, n.name)
func (n NameNode) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.parts != nil {
fmt.Fprintf(out, "\n%vparts:", indent+" ")
vv := v.Children("parts")
for _, nn := range n.parts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package name
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n NamePart) Name() string {
func (n NamePart) Name() string {
return "NamePart"
}
@@ -24,6 +21,10 @@ func NewNamePart(token token.Token) node.Node {
}
}
func (n NamePart) 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)
func (n NamePart) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
}