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,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n AltElse) Name() string {
func (n AltElse) Name() string {
return "AltElse"
}
@@ -26,11 +23,13 @@ func NewAltElse(token token.Token, stmt node.Node) node.Node {
}
}
func (n AltElse) 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 AltElse) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n AltElseIf) Name() string {
func (n AltElseIf) Name() string {
return "AltElseIf"
}
@@ -28,16 +25,18 @@ func NewAltElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
}
}
func (n AltElseIf) 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 AltElseIf) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,24 +1,21 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n AltIf) Name() string {
func (n AltIf) Name() string {
return "AltIf"
}
type AltIf struct {
name string
token token.Token
cond node.Node
stmt node.Node
elseAltIf []node.Node
_else node.Node
name string
token token.Token
cond node.Node
stmt node.Node
elseIf []node.Node
_else node.Node
}
func NewAltIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
@@ -32,12 +29,12 @@ func NewAltIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
}
}
func (n AltIf) AddElseIf(elseAltIf node.Node) node.Node {
if n.elseAltIf == nil {
n.elseAltIf = make([]node.Node, 0)
func (n AltIf) AddElseIf(elseIf node.Node) node.Node {
if n.elseIf == nil {
n.elseIf = make([]node.Node, 0)
}
n.elseAltIf = append(n.elseAltIf, elseAltIf)
n.elseIf = append(n.elseIf, elseIf)
return n
}
@@ -48,27 +45,30 @@ func (n AltIf) SetElse(_else node.Node) node.Node {
return n
}
func (n AltIf) 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 AltIf) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
if n.elseAltIf != nil {
fmt.Fprintf(out, "\n%velseAltIfs:", indent+" ")
for _, nn := range n.elseAltIf {
nn.Print(out, indent+" ")
if n.elseIf != nil {
vv := v.Children("elseIf")
for _, nn := range n.elseIf {
nn.Walk(vv)
}
}
if n._else != nil {
fmt.Fprintf(out, "\n%velse:", indent+" ")
n._else.Print(out, indent+" ")
vv := v.Children("else")
n._else.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Break) Name() string {
func (n Break) Name() string {
return "Break"
}
@@ -26,11 +23,13 @@ func NewBreak(token token.Token, expr node.Node) node.Node {
}
}
func (n Break) 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 Break) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Case) Name() string {
func (n Case) Name() string {
return "Case"
}
@@ -28,16 +25,20 @@ func NewCase(token token.Token, cond node.Node, stmts []node.Node) node.Node {
}
}
func (n Case) 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 Case) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
if n.cond != nil {
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Catch) Name() string {
func (n Catch) Name() string {
return "Catch"
}
@@ -30,21 +27,22 @@ func NewCatch(token token.Token, types []node.Node, variable node.Node, stmts []
}
}
func (n Catch) 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)
fmt.Fprintf(out, "\n%vtypes:", indent+" ")
for _, nn := range n.types {
nn.Print(out, indent+" ")
func (n Catch) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
if n.types != nil {
vv := v.Children("types")
for _, nn := range n.types {
nn.Walk(vv)
}
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Class) Name() string {
func (n Class) Name() string {
return "Class"
}
@@ -34,39 +31,43 @@ func NewClass(token token.Token, modifiers []node.Node, args []node.Node, extend
}
}
func (n Class) 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 Class) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmotifiers:", indent+" ")
vv := v.Children("modifiers")
for _, nn := range n.modifiers {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.args != nil {
fmt.Fprintf(out, "\n%vargs:", indent+" ")
vv := v.Children("args")
for _, nn := range n.args {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.extends != nil {
fmt.Fprintf(out, "\n%vextends:", indent+" ")
n.extends.Print(out, indent+" ")
vv := v.Children("extends")
n.extends.Walk(vv)
}
if n.implements != nil {
fmt.Fprintf(out, "\n%vimplements:", indent+" ")
vv := v.Children("implements")
for _, nn := range n.implements {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n ClassConstList) Name() string {
func (n ClassConstList) Name() string {
return "ClassConstList"
}
@@ -28,20 +25,22 @@ func NewClassConstList(token token.Token, modifiers []node.Node, consts []node.N
}
}
func (n ClassConstList) 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 ClassConstList) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmotifiers:", indent+" ")
vv := v.Children("modifiers")
for _, nn := range n.modifiers {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.consts != nil {
fmt.Fprintf(out, "\n%vconsts:", indent+" ")
vv := v.Children("consts")
for _, nn := range n.consts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n ClassMethod) Name() string {
func (n ClassMethod) Name() string {
return "ClassMethod"
}
@@ -34,34 +31,37 @@ func NewClassMethod(token token.Token, modifiers []node.Node, isReturnRef bool,
}
}
func (n ClassMethod) 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 ClassMethod) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
v.Scalar("isReturnRef", n.isReturnRef)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmodifiers:", indent+" ")
vv := v.Children("modifiers")
for _, nn := range n.modifiers {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
fmt.Fprintf(out, "\n%vreturn ref: %t", indent+" ", n.isReturnRef)
if n.params != nil {
fmt.Fprintf(out, "\n%vparams:", indent+" ")
vv := v.Children("params")
for _, nn := range n.params {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.returnType != nil {
fmt.Fprintf(out, "\n%vreturn type:", indent+" ")
n.returnType.Print(out, indent+" ")
vv := v.Children("returnType")
n.returnType.Walk(vv)
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n ConstList) Name() string {
func (n ConstList) Name() string {
return "ConstList"
}
@@ -26,13 +23,15 @@ func NewConstList(token token.Token, consts []node.Node) node.Node {
}
}
func (n ConstList) 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 ConstList) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.consts != nil {
fmt.Fprintf(out, "\n%vconsts:", indent+" ")
vv := v.Children("consts")
for _, nn := range n.consts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Constant) Name() string {
func (n Constant) Name() string {
return "Constant"
}
@@ -26,9 +23,15 @@ func NewConstant(token token.Token, expr node.Node) node.Node {
}
}
func (n Constant) 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 Constant) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
v.Scalar("token", n.token.Value)
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Continue) Name() string {
func (n Continue) Name() string {
return "Continue"
}
@@ -26,11 +23,13 @@ func NewContinue(token token.Token, expr node.Node) node.Node {
}
}
func (n Continue) 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 Continue) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Declare) Name() string {
func (n Declare) Name() string {
return "Declare"
}
@@ -28,18 +25,20 @@ func NewDeclare(token token.Token, consts []node.Node, stmt node.Node) node.Node
}
}
func (n Declare) 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 Declare) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.consts != nil {
fmt.Fprintf(out, "\n%vconsts:", indent+" ")
vv := v.Children("consts")
for _, nn := range n.consts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Default) Name() string {
func (n Default) Name() string {
return "Default"
}
@@ -26,13 +23,15 @@ func NewDefault(token token.Token, stmts []node.Node) node.Node {
}
}
func (n Default) 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 Default) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Do) Name() string {
func (n Do) Name() string {
return "Do"
}
@@ -28,16 +25,18 @@ func NewDo(token token.Token, stmt node.Node, cond node.Node) node.Node {
}
}
func (n Do) 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 Do) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Echo) Name() string {
func (n Echo) Name() string {
return "Echo"
}
@@ -26,13 +23,15 @@ func NewEcho(token token.Token, exprs []node.Node) node.Node {
}
}
func (n Echo) 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 Echo) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.exprs != nil {
fmt.Fprintf(out, "\n%vexprs:", indent+" ")
vv := v.Children("exprs")
for _, nn := range n.exprs {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Else) Name() string {
func (n Else) Name() string {
return "Else"
}
@@ -26,11 +23,13 @@ func NewElse(token token.Token, stmt node.Node) node.Node {
}
}
func (n Else) 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 Else) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n ElseIf) Name() string {
func (n ElseIf) Name() string {
return "ElseIf"
}
@@ -28,16 +25,18 @@ func NewElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
}
}
func (n ElseIf) 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 ElseIf) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,13 +1,10 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
func(n Expression) Name() string {
func (n Expression) Name() string {
return "Expression"
}
@@ -23,11 +20,13 @@ func NewExpression(expr node.Node) node.Node {
}
}
func (n Expression) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Expression) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Finally) Name() string {
func (n Finally) Name() string {
return "Finally"
}
@@ -26,13 +23,15 @@ func NewFinally(token token.Token, stmts []node.Node) node.Node {
}
}
func (n Finally) 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 Finally) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n For) Name() string {
func (n For) Name() string {
return "For"
}
@@ -32,32 +29,34 @@ func NewFor(token token.Token, init []node.Node, cond []node.Node, loop []node.N
}
}
func (n For) 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 For) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.init != nil {
fmt.Fprintf(out, "\n%vinit:", indent+" ")
vv := v.Children("init")
for _, nn := range n.init {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
vv := v.Children("cond")
for _, nn := range n.cond {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.loop != nil {
fmt.Fprintf(out, "\n%vloop:", indent+" ")
vv := v.Children("loop")
for _, nn := range n.loop {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Foreach) Name() string {
func (n Foreach) Name() string {
return "Foreach"
}
@@ -34,26 +31,28 @@ func NewForeach(token token.Token, expr node.Node, key node.Node, variable node.
}
}
func (n Foreach) 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 Foreach) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
if n.key != nil {
fmt.Fprintf(out, "\n%vkey:", indent+" ")
n.key.Print(out, indent+" ")
vv := v.Children("key")
n.key.Walk(vv)
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable[byRef: %t]:", indent+" ", n.byRef)
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Function) Name() string {
func (n Function) Name() string {
return "Function"
}
@@ -32,27 +29,30 @@ func NewFunction(token token.Token, isReturnRef bool, params []node.Node, return
}
}
func (n Function) 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 Function) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
fmt.Fprintf(out, "\n%vreturn ref: %t", indent+" ", n.isReturnRef)
v.Scalar("token", n.token.Value)
v.Scalar("isReturnRef", n.isReturnRef)
if n.params != nil {
fmt.Fprintf(out, "\n%vparams:", indent+" ")
vv := v.Children("params")
for _, nn := range n.params {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.returnType != nil {
fmt.Fprintf(out, "\n%vreturn type:", indent+" ")
n.returnType.Print(out, indent+" ")
vv := v.Children("returnType")
n.returnType.Walk(vv)
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Global) Name() string {
func (n Global) Name() string {
return "Global"
}
@@ -26,13 +23,15 @@ func NewGlobal(token token.Token, vars []node.Node) node.Node {
}
}
func (n Global) 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 Global) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.vars != nil {
fmt.Fprintf(out, "\n%vvars:", indent+" ")
vv := v.Children("vars")
for _, nn := range n.vars {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Goto) Name() string {
func (n Goto) Name() string {
return "Goto"
}
@@ -18,14 +15,19 @@ type Goto struct {
label token.Token
}
func NewGoto(token token.Token, name token.Token) node.Node {
// todl label must be identifier
func NewGoto(token token.Token, label token.Token) node.Node {
return Goto{
"Goto",
token,
name,
label,
}
}
func (n Goto) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.label.EndLine, n.label.Value)
func (n Goto) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("label", n.label.Value)
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n GroupUse) Name() string {
func (n GroupUse) Name() string {
return "GroupUse"
}
@@ -41,23 +38,25 @@ func (n GroupUse) SetUseType(useType node.Node) node.Node {
return n
}
func (n GroupUse) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.GetStartLine(), n.token.GetEndLine(), n.token.GetValue())
func (n GroupUse) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.useType != nil {
fmt.Fprintf(out, "\n%vuse type:", indent+" ")
n.useType.Print(out, indent+" ")
vv := v.Children("useType")
n.useType.Walk(vv)
}
if n.prefix != nil {
fmt.Fprintf(out, "\n%vprefix:", indent+" ")
n.prefix.Print(out, indent+" ")
vv := v.Children("prefix")
n.prefix.Walk(vv)
}
if n.useList != nil {
fmt.Fprintf(out, "\n%vuse list:", indent+" ")
vv := v.Children("useList")
for _, nn := range n.useList {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

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

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n If) Name() string {
func (n If) Name() string {
return "If"
}
@@ -48,27 +45,30 @@ func (n If) SetElse(_else node.Node) node.Node {
return n
}
func (n If) 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 If) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
if n.elseIf != nil {
fmt.Fprintf(out, "\n%velseIfs:", indent+" ")
vv := v.Children("elseIf")
for _, nn := range n.elseIf {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n._else != nil {
fmt.Fprintf(out, "\n%velse:", indent+" ")
n._else.Print(out, indent+" ")
vv := v.Children("else")
n._else.Walk(vv)
}
}

View File

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

View File

@@ -1,23 +1,20 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Interface) Name() string {
func (n Interface) Name() string {
return "Interface"
}
type Interface struct {
name string
token token.Token
iName token.Token
extends []node.Node
stmts []node.Node
name string
token token.Token
interfaceName token.Token
extends []node.Node
stmts []node.Node
}
func NewInterface(token token.Token, name token.Token, extends []node.Node, stmts []node.Node) node.Node {
@@ -30,20 +27,24 @@ func NewInterface(token token.Token, name token.Token, extends []node.Node, stmt
}
}
func (n Interface) 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.iName.Value)
func (n Interface) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.interfaceName.Value)
if n.extends != nil {
fmt.Fprintf(out, "\n%vextends:", indent+" ")
vv := v.Children("extends")
for _, nn := range n.extends {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

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

View File

@@ -1,45 +1,44 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Namespace) Name() string {
func (n Namespace) Name() string {
return "Namespace"
}
type Namespace struct {
name string
token token.Token
nName node.Node
stmts []node.Node
name string
token token.Token
namespaceName node.Node
stmts []node.Node
}
func NewNamespace(token token.Token, name node.Node, stmts []node.Node) node.Node {
func NewNamespace(token token.Token, namespaceName node.Node, stmts []node.Node) node.Node {
return Namespace{
"Namespace",
token,
name,
namespaceName,
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)
func (n Namespace) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.nName != nil {
fmt.Fprintf(out, "\n%vname:", indent+" ")
n.nName.Print(out, indent+" ")
if n.namespaceName != nil {
vv := v.Children("namespaceName")
n.namespaceName.Walk(vv)
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Nop) Name() string {
func (n Nop) Name() string {
return "Nop"
}
@@ -27,3 +27,11 @@ func NewNop(token token.Token) node.Node {
func (n Nop) 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 Nop) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Property) Name() string {
func (n Property) Name() string {
return "Property"
}
@@ -26,11 +23,15 @@ func NewProperty(token token.Token, expr node.Node) node.Node {
}
}
func (n Property) 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 Property) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,13 +1,10 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
func(n PropertyList) Name() string {
func (n PropertyList) Name() string {
return "PropertyList"
}
@@ -25,20 +22,22 @@ func NewPropertyList(modifiers []node.Node, properties []node.Node) node.Node {
}
}
func (n PropertyList) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n PropertyList) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmodifiers:", indent+" ")
vv := v.Children("modifiers")
for _, nn := range n.modifiers {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.properties != nil {
fmt.Fprintf(out, "\n%vproperties:", indent+" ")
vv := v.Children("properties")
for _, nn := range n.properties {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Return) Name() string {
func (n Return) Name() string {
return "Return"
}
@@ -26,11 +23,13 @@ func NewReturn(token token.Token, expr node.Node) node.Node {
}
}
func (n Return) 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 Return) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Static) Name() string {
func (n Static) Name() string {
return "Static"
}
@@ -26,13 +23,15 @@ func NewStatic(token token.Token, vars []node.Node) node.Node {
}
}
func (n Static) 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 Static) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.vars != nil {
fmt.Fprintf(out, "\n%vvars:", indent+" ")
vv := v.Children("vars")
for _, nn := range n.vars {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n StaticVar) Name() string {
func (n StaticVar) Name() string {
return "StaticVar"
}
@@ -26,11 +23,13 @@ func NewStaticVar(token token.Token, expr node.Node) node.Node {
}
}
func (n StaticVar) 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 StaticVar) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

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

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Switch) Name() string {
func (n Switch) Name() string {
return "Switch"
}
@@ -28,18 +25,20 @@ func NewSwitch(token token.Token, cond node.Node, cases []node.Node) node.Node {
}
}
func (n Switch) 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 Switch) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.cases != nil {
fmt.Fprintf(out, "\n%vcases:", indent+" ")
vv := v.Children("cases")
for _, nn := range n.cases {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Throw) Name() string {
func (n Throw) Name() string {
return "Throw"
}
@@ -26,11 +23,13 @@ func NewThrow(token token.Token, expr node.Node) node.Node {
}
}
func (n Throw) 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 Throw) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Trait) Name() string {
func (n Trait) Name() string {
return "Trait"
}
@@ -27,13 +24,17 @@ func NewTrait(token token.Token, stmts []node.Node) node.Node {
}
}
func (n Trait) 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 Trait) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n TraitMethodRef) Name() string {
func (n TraitMethodRef) Name() string {
return "TraitMethodRef"
}
@@ -18,6 +15,7 @@ type TraitMethodRef struct {
method token.Token
}
// TODO: method must be identifier
func NewTraitMethodRef(trait node.Node, method token.Token) node.Node {
return TraitMethodRef{
"TraitMethodRef",
@@ -26,11 +24,15 @@ func NewTraitMethodRef(trait node.Node, method token.Token) node.Node {
}
}
func (n TraitMethodRef) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -] %q", indent, n.name, n.method.Value)
func (n TraitMethodRef) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("method", n.method.Value)
if n.trait != nil {
fmt.Fprintf(out, "\n%vtrait", indent+" ")
n.trait.Print(out, indent+" ")
vv := v.Children("trait")
n.trait.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n TraitUse) Name() string {
func (n TraitUse) Name() string {
return "TraitUse"
}
@@ -29,20 +26,22 @@ func NewTraitUse(token token.Token, traits []node.Node, adaptations []node.Node)
}
}
func (n TraitUse) 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 TraitUse) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.traits != nil {
fmt.Fprintf(out, "\n%vtraits:", indent+" ")
vv := v.Children("traits")
for _, nn := range n.traits {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.adaptations != nil {
fmt.Fprintf(out, "\n%vadaptations:", indent+" ")
vv := v.Children("adaptations")
for _, nn := range n.adaptations {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n TraitUseAlias) Name() string {
func (n TraitUseAlias) Name() string {
return "TraitUseAlias"
}
@@ -28,20 +25,18 @@ func NewTraitUseAlias(ref node.Node, modifier node.Node, alias token.TokenInterf
}
}
func (n TraitUseAlias) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.alias != nil {
fmt.Fprintf(out, "\n%valias: %q", indent+" ", n.alias.GetValue())
func (n TraitUseAlias) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.ref != nil {
fmt.Fprintf(out, "\n%vmethod", indent+" ")
n.ref.Print(out, indent+" ")
vv := v.Children("ref")
n.ref.Walk(vv)
}
if n.modifier != nil {
fmt.Fprintf(out, "\n%vmodifier:", indent+" ")
n.modifier.Print(out, indent+" ")
vv := v.Children("modifier")
n.modifier.Walk(vv)
}
}

View File

@@ -1,13 +1,10 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
func(n TraitUsePrecedence) Name() string {
func (n TraitUsePrecedence) Name() string {
return "TraitUsePrecedence"
}
@@ -25,16 +22,18 @@ func NewTraitUsePrecedence(ref node.Node, insteadof node.Node) node.Node {
}
}
func (n TraitUsePrecedence) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n TraitUsePrecedence) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.ref != nil {
fmt.Fprintf(out, "\n%vmethod", indent+" ")
n.ref.Print(out, indent+" ")
vv := v.Children("ref")
n.ref.Walk(vv)
}
if n.insteadof != nil {
fmt.Fprintf(out, "\n%vinsteadof:", indent+" ")
n.insteadof.Print(out, indent+" ")
vv := v.Children("insteadof")
n.insteadof.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Try) Name() string {
func (n Try) Name() string {
return "Try"
}
@@ -30,25 +27,27 @@ func NewTry(token token.Token, stmts []node.Node, catches []node.Node, finally n
}
}
func (n Try) 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 Try) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
vv := v.Children("stmts")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.catches != nil {
fmt.Fprintf(out, "\n%vcatches:", indent+" ")
vv := v.Children("catches")
for _, nn := range n.catches {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
if n.finally != nil {
fmt.Fprintf(out, "\n%vfinally:", indent+" ")
n.finally.Print(out, indent+" ")
vv := v.Children("finally")
n.finally.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Unset) Name() string {
func (n Unset) Name() string {
return "Unset"
}
@@ -26,13 +23,15 @@ func NewUnset(token token.Token, vars []node.Node) node.Node {
}
}
func (n Unset) 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 Unset) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.vars != nil {
fmt.Fprintf(out, "\n%vvars:", indent+" ")
vv := v.Children("vars")
for _, nn := range n.vars {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,17 +1,10 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Use) Name() string {
return "Use"
}
type Use struct {
name string
useType node.Node
@@ -28,25 +21,27 @@ func NewUse(useType node.Node, use node.Node, alias token.TokenInterface) node.N
}
}
func (n Use) Name() string {
return "Use"
}
func (n Use) SetType(useType node.Node) node.Node {
n.useType = useType
return n
}
func (n Use) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Use) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.useType != nil {
fmt.Fprintf(out, "\n%vtype:", indent+" ")
n.useType.Print(out, indent+" ")
vv := v.Children("useType")
n.useType.Walk(vv)
}
if n.use != nil {
fmt.Fprintf(out, "\n%vuse:", indent+" ")
n.use.Print(out, indent+" ")
}
if n.alias != nil {
fmt.Fprintf(out, "\n%valias: %q", indent+" ", n.alias.GetValue())
vv := v.Children("use")
n.use.Walk(vv)
}
}

View File

@@ -1,14 +1,11 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n UseList) Name() string {
func (n UseList) Name() string {
return "UseList"
}
@@ -28,18 +25,20 @@ func NewUseList(token token.Token, useType node.Node, uses []node.Node) node.Nod
}
}
func (n UseList) 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 UseList) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.useType != nil {
fmt.Fprintf(out, "\n%vtype:", indent+" ")
n.useType.Print(out, indent+" ")
vv := v.Children("useType")
n.useType.Walk(vv)
}
if n.uses != nil {
fmt.Fprintf(out, "\n%vuses:", indent+" ")
vv := v.Children("uses")
for _, nn := range n.uses {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@@ -1,17 +1,10 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n While) Name() string {
return "While"
}
type While struct {
name string
token token.Token
@@ -28,16 +21,22 @@ func NewWhile(token token.Token, cond node.Node, stmt node.Node) node.Node {
}
}
func (n While) 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 While) Name() string {
return "While"
}
func (n While) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
vv := v.Children("cond")
n.cond.Walk(vv)
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
vv := v.Children("stmt")
n.stmt.Walk(vv)
}
}