walker
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
package scalar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n Dnumber) Name() string {
|
||||
func (n Dnumber) Name() string {
|
||||
return "Dnumber"
|
||||
}
|
||||
|
||||
@@ -24,6 +21,10 @@ func NewDnumber(token token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n Dnumber) 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 Dnumber) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package scalar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n Encapsed) Name() string {
|
||||
func (n Encapsed) Name() string {
|
||||
return "Encapsed"
|
||||
}
|
||||
|
||||
@@ -28,13 +25,15 @@ func NewEncapsed(startToken token.Token, parts []node.Node, endToken token.Token
|
||||
}
|
||||
}
|
||||
|
||||
func (n Encapsed) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.name, n.startToken.StartLine, n.endToken.EndLine)
|
||||
func (n Encapsed) 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package scalar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n EncapsedStringPart) Name() string {
|
||||
func (n EncapsedStringPart) Name() string {
|
||||
return "EncapsedStringPart"
|
||||
}
|
||||
|
||||
@@ -24,6 +21,10 @@ func NewEncapsedStringPart(t token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n EncapsedStringPart) 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 EncapsedStringPart) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package scalar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n Lnumber) Name() string {
|
||||
func (n Lnumber) Name() string {
|
||||
return "Lnumber"
|
||||
}
|
||||
|
||||
@@ -24,6 +21,10 @@ func NewLnumber(token token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n Lnumber) 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 Lnumber) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package scalar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n MagicConstant) Name() string {
|
||||
func (n MagicConstant) Name() string {
|
||||
return "MagicConstant"
|
||||
}
|
||||
|
||||
@@ -24,6 +21,10 @@ func NewMagicConstant(token token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n MagicConstant) 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 MagicConstant) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package scalar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func(n String) Name() string {
|
||||
func (n String) Name() string {
|
||||
return "String"
|
||||
}
|
||||
|
||||
@@ -24,6 +21,10 @@ func NewString(token token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n String) 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 String) Walk(v node.Visitor) {
|
||||
if v.Visit(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user