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

26
dumper.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"fmt"
"github.com/z7zmey/php-parser/node"
)
type dumper struct {
indent string
}
func (d dumper) Visit(n node.Node) bool {
fmt.Printf("%v[%v]:\n", d.indent, n.Name())
return true
}
func (d dumper) Children(key string) node.Visitor {
fmt.Printf("%v%v:\n", d.indent+". ", key)
return dumper{d.indent + ". . "}
}
func (d dumper) Scalar(key string, value interface{}) {
fmt.Printf("%v%v: %v\n", d.indent+". ", key, value)
}

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"bytes"
"flag" "flag"
"fmt" "fmt"
"log" "log"
@ -17,14 +16,12 @@ func main() {
for _, path := range flag.Args() { for _, path := range flag.Args() {
real, err := realpath.Realpath(path) real, err := realpath.Realpath(path)
checkErr(err) checkErr(err)
fmt.Printf("\n==> %s", real) fmt.Printf("==> %s\n", real)
src, _ := os.Open(string(real)) src, _ := os.Open(string(real))
rootnode := parser.Parse(src, real) rootnode := parser.Parse(src, real)
buf := new(bytes.Buffer) rootnode.Walk(dumper{" | "})
rootnode.Print(buf, "")
fmt.Println(buf.String())
} }
} }

View File

@ -1,10 +1,5 @@
package node package node
import (
"fmt"
"io"
)
type Argument struct { type Argument struct {
name string name string
expr Node expr Node
@ -23,12 +18,13 @@ func NewArgument(expression Node, variadic bool) Node {
} }
} }
func (n Argument) Print(out io.Writer, indent string) { func (n Argument) Walk(v Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
fmt.Fprintf(out, "\n%vvariadic: %t", indent+" ", n.variadic) return
}
if n.expr != nil { if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ") vv := v.Children("expr")
n.expr.Print(out, indent+" ") n.expr.Walk(vv)
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token" "github.com/z7zmey/php-parser/token"
) )
@ -28,13 +25,15 @@ func NewArray(opentToken token.Token, closeToken token.Token, items []node.Node)
} }
} }
func (n Array) Print(out io.Writer, indent string) { func (n Array) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.name, n.opentToken.StartLine, n.closeToken.EndLine) if v.Visit(n) == false {
return
}
if n.items != nil { if n.items != nil {
fmt.Fprintf(out, "\n%vitems:", indent+" ") vv := v.Children("items")
for _, nn := range n.items { for _, nn := range n.items {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,16 +22,18 @@ func NewArrayDimFetch(variable node.Node, dim node.Node) node.Node {
} }
} }
func (n ArrayDimFetch) Print(out io.Writer, indent string) { func (n ArrayDimFetch) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name) if v.Visit(n) == false {
return
}
if n.variable != nil { if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ") vv := v.Children("variable")
n.variable.Print(out, indent+" ") n.variable.Walk(vv)
} }
if n.dim != nil { if n.dim != nil {
fmt.Fprintf(out, "\n%vdim:", indent+" ") vv := v.Children("dim")
n.dim.Print(out, indent+" ") n.dim.Walk(vv)
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -27,17 +24,18 @@ func NewArrayItem(key node.Node, val node.Node, byRef bool) node.Node {
} }
} }
func (n ArrayItem) Print(out io.Writer, indent string) { func (n ArrayItem) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
fmt.Fprintf(out, "\n%vbyRef: %t", indent+" ", n.byRef) return
}
if n.key != nil { if n.key != nil {
fmt.Fprintf(out, "\n%vkey:", indent+" ") vv := v.Children("key")
n.key.Print(out, indent+" ") n.key.Walk(vv)
} }
if n.val != nil { if n.val != nil {
fmt.Fprintf(out, "\n%vval:", indent+" ") vv := v.Children("val")
n.val.Print(out, indent+" ") n.val.Walk(vv)
} }
} }

View File

@ -21,3 +21,19 @@ func NewAssign(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Assign) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package assign_op package assign_op
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -12,17 +9,3 @@ type AssignOp struct {
variable node.Node variable node.Node
expression node.Node expression node.Node
} }
func (n AssignOp) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
}
if n.expression != nil {
fmt.Fprintf(out, "\n%vexpression:", indent+" ")
n.expression.Print(out, indent+" ")
}
}

View File

@ -21,3 +21,19 @@ func NewAssignRef(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n AssignRef) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n BitwiseAnd) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBitwiseOr(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n BitwiseOr) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBitwiseXor(variable node.Node, expression node.Node) node.Node {
func (n BitwiseXor) Name() string { func (n BitwiseXor) Name() string {
return "BitwiseXor" return "BitwiseXor"
} }
func (n BitwiseXor) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewConcat(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Concat) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewDiv(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Div) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewMinus(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Minus) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewMod(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Mod) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewMul(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Mul) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewPlus(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Plus) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewPow(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Pow) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewShiftLeft(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n ShiftLeft) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewShiftRight(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n ShiftRight) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.expression != nil {
vv := v.Children("expression")
n.expression.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package binary_op package binary_op
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -12,17 +9,3 @@ type BinaryOp struct {
left node.Node left node.Node
right node.Node right node.Node
} }
func (n BinaryOp) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.left != nil {
fmt.Fprintf(out, "\n%vleft:", indent+" ")
n.left.Print(out, indent+" ")
}
if n.right != nil {
fmt.Fprintf(out, "\n%vright:", indent+" ")
n.right.Print(out, indent+" ")
}
}

View File

@ -21,3 +21,19 @@ func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n BitwiseAnd) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBitwiseOr(variable node.Node, expression node.Node) node.Node {
func (n BitwiseOr) Name() string { func (n BitwiseOr) Name() string {
return "BitwiseOr" return "BitwiseOr"
} }
func (n BitwiseOr) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBitwiseXor(variable node.Node, expression node.Node) node.Node {
func (n BitwiseXor) Name() string { func (n BitwiseXor) Name() string {
return "BitwiseXor" return "BitwiseXor"
} }
func (n BitwiseXor) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBooleanAnd(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n BooleanAnd) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewBooleanOr(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n BooleanOr) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewCoalesce(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Coalesce) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewConcat(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Concat) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewDiv(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Div) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewEqual(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Equal) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewGreater(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Greater) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewGreaterOrEqual(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n GreaterOrEqual) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewIdentical(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Identical) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewLogicalAnd(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n LogicalAnd) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewLogicalOr(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n LogicalOr) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewLogicalXor(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n LogicalXor) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -21,3 +21,19 @@ func NewMinus(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Minus) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n Mod) Name() string { func (n Mod) Name() string {
return "Mod" return "Mod"
} }
@ -21,3 +21,19 @@ func NewMod(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Mod) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n Mul) Name() string { func (n Mul) Name() string {
return "Mul" return "Mul"
} }
@ -21,3 +21,19 @@ func NewMul(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Mul) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n NotEqual) Name() string { func (n NotEqual) Name() string {
return "NotEqual" return "NotEqual"
} }
@ -21,3 +21,19 @@ func NewNotEqual(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n NotEqual) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n NotIdentical) Name() string { func (n NotIdentical) Name() string {
return "NotIdentical" return "NotIdentical"
} }
@ -21,3 +21,19 @@ func NewNotIdentical(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n NotIdentical) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n Plus) Name() string { func (n Plus) Name() string {
return "Plus" return "Plus"
} }
@ -21,3 +21,19 @@ func NewPlus(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Plus) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n Pow) Name() string { func (n Pow) Name() string {
return "Pow" return "Pow"
} }
@ -21,3 +21,19 @@ func NewPow(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Pow) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n ShiftLeft) Name() string { func (n ShiftLeft) Name() string {
return "ShiftLeft" return "ShiftLeft"
} }
@ -21,3 +21,19 @@ func NewShiftLeft(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n ShiftLeft) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n ShiftRight) Name() string { func (n ShiftRight) Name() string {
return "ShiftRight" return "ShiftRight"
} }
@ -21,3 +21,19 @@ func NewShiftRight(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n ShiftRight) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n Smaller) Name() string { func (n Smaller) Name() string {
return "Smaller" return "Smaller"
} }
@ -21,3 +21,19 @@ func NewSmaller(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Smaller) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n SmallerOrEqual) Name() string { func (n SmallerOrEqual) Name() string {
return "SmallerOrEqual" return "SmallerOrEqual"
} }
@ -21,3 +21,19 @@ func NewSmallerOrEqual(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n SmallerOrEqual) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
func(n Spaceship) Name() string { func (n Spaceship) Name() string {
return "Spaceship" return "Spaceship"
} }
@ -21,3 +21,19 @@ func NewSpaceship(variable node.Node, expression node.Node) node.Node {
}, },
} }
} }
func (n Spaceship) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.left != nil {
vv := v.Children("left")
n.left.Walk(vv)
}
if n.right != nil {
vv := v.Children("right")
n.right.Walk(vv)
}
}

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package cast package cast
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -11,12 +8,3 @@ type Cast struct {
name string name string
expr node.Node expr node.Node
} }
func (n Cast) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
}
}

View File

@ -20,3 +20,14 @@ func NewCastArray(expr node.Node) node.Node {
}, },
} }
} }
func (n CastArray) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -20,3 +20,14 @@ func NewCastBool(expr node.Node) node.Node {
}, },
} }
} }
func (n CastBool) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -20,3 +20,14 @@ func NewCastDouble(expr node.Node) node.Node {
}, },
} }
} }
func (n CastDouble) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -20,3 +20,14 @@ func NewCastInt(expr node.Node) node.Node {
}, },
} }
} }
func (n CastInt) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -20,3 +20,14 @@ func NewCastObject(expr node.Node) node.Node {
}, },
} }
} }
func (n CastObject) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -20,3 +20,14 @@ func NewCastString(expr node.Node) node.Node {
}, },
} }
} }
func (n CastString) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -20,3 +20,14 @@ func NewCastUnset(expr node.Node) node.Node {
}, },
} }
} }
func (n CastUnset) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.expr != nil {
vv := v.Children("expr")
n.expr.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token" "github.com/z7zmey/php-parser/token"
) )
@ -18,6 +15,7 @@ type ClassConstFetch struct {
constant token.Token constant token.Token
} }
// TODO: constant must be identifier
func NewClassConstFetch(class node.Node, constant token.Token) node.Node { func NewClassConstFetch(class node.Node, constant token.Token) node.Node {
return ClassConstFetch{ return ClassConstFetch{
"ClassConstFetch", "ClassConstFetch",
@ -26,12 +24,15 @@ func NewClassConstFetch(class node.Node, constant token.Token) node.Node {
} }
} }
func (n ClassConstFetch) Print(out io.Writer, indent string) { func (n ClassConstFetch) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
fmt.Fprintf(out, "\n%vname: %q", indent+" ", n.constant.Value) return
}
v.Scalar("constant", n.constant.Value)
if n.class != nil { if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ") vv := v.Children("class")
n.class.Print(out, indent+" ") n.class.Walk(vv)
} }
} }

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -33,35 +30,37 @@ func NewClosure(params []node.Node, uses []node.Node, returnType node.Node, stmt
} }
} }
func (n Closure) Print(out io.Writer, indent string) { func (n Closure) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
fmt.Fprintf(out, "\n%vis static: %t", indent+" ", n.isStatic) v.Scalar("isStatic", n.isStatic)
fmt.Fprintf(out, "\n%vis return ref: %t", indent+" ", n.isReturnRef) v.Scalar("isReturnRef", n.isReturnRef)
if n.params != nil { if n.params != nil {
fmt.Fprintf(out, "\n%vparams:", indent+" ") vv := v.Children("params")
for _, nn := range n.params { for _, nn := range n.params {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
if n.uses != nil { if n.uses != nil {
fmt.Fprintf(out, "\n%vuses:", indent+" ") vv := v.Children("uses")
for _, nn := range n.uses { for _, nn := range n.uses {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
if n.returnType != nil { if n.returnType != nil {
fmt.Fprintf(out, "\n%vreturn type:", indent+" ") vv := v.Children("returnType")
n.returnType.Print(out, indent+" ") n.returnType.Walk(vv)
} }
if n.stmts != nil { if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ") vv := v.Children("stmts")
for _, nn := range n.stmts { for _, nn := range n.stmts {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,12 +22,15 @@ func NewClusureUse(variable node.Node, byRef bool) node.Node {
} }
} }
func (n ClusureUse) Print(out io.Writer, indent string) { func (n ClusureUse) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
fmt.Fprintf(out, "\n%vby ref: %t", indent+" ", n.byRef) return
}
v.Scalar("byRef", n.byRef)
if n.variable != nil { if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ") vv := v.Children("variable")
n.variable.Print(out, indent+" ") n.variable.Walk(vv)
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,12 +22,13 @@ func NewExit(expr node.Node, isDie bool) node.Node {
} }
} }
func (n Exit) Print(out io.Writer, indent string) { func (n Exit) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
fmt.Fprintf(out, "\n%vis die: %t", indent+" ", n.isDie) return
}
if n.expr != nil { if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ") vv := v.Children("expr")
n.expr.Print(out, indent+" ") n.expr.Walk(vv)
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,18 +22,20 @@ func NewFunctionCall(function node.Node, arguments []node.Node) node.Node {
} }
} }
func (n FunctionCall) Print(out io.Writer, indent string) { func (n FunctionCall) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.function != nil { if n.function != nil {
fmt.Fprintf(out, "\n%vfunction:", indent+" ") vv := v.Children("function")
n.function.Print(out, indent+" ") n.function.Walk(vv)
} }
if n.arguments != nil { if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ") vv := v.Children("arguments")
for _, nn := range n.arguments { for _, nn := range n.arguments {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,16 +22,18 @@ func NewInstanceOf(expr node.Node, class node.Node) node.Node {
} }
} }
func (n InstanceOf) Print(out io.Writer, indent string) { func (n InstanceOf) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.expr != nil { if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ") vv := v.Children("expr")
n.expr.Print(out, indent+" ") n.expr.Walk(vv)
} }
if n.class != nil { if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ") vv := v.Children("class")
n.class.Print(out, indent+" ") n.class.Walk(vv)
} }
} }

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -27,23 +24,25 @@ func NewMethodCall(variable node.Node, method node.Node, arguments []node.Node)
} }
} }
func (n MethodCall) Print(out io.Writer, indent string) { func (n MethodCall) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.variable != nil { if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ") vv := v.Children("variable")
n.variable.Print(out, indent+" ") n.variable.Walk(vv)
} }
if n.method != nil { if n.method != nil {
fmt.Fprintf(out, "\n%vmethod:", indent+" ") vv := v.Children("method")
n.method.Print(out, indent+" ") n.method.Walk(vv)
} }
if n.arguments != nil { if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ") vv := v.Children("arguments")
for _, nn := range n.arguments { for _, nn := range n.arguments {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,18 +22,20 @@ func NewNew(class node.Node, arguments []node.Node) node.Node {
} }
} }
func (n New) Print(out io.Writer, indent string) { func (n New) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.class != nil { if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ") vv := v.Children("class")
n.class.Print(out, indent+" ") n.class.Walk(vv)
} }
if n.arguments != nil { if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ") vv := v.Children("arguments")
for _, nn := range n.arguments { for _, nn := range n.arguments {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,16 +22,18 @@ func NewPropertyFetch(variable node.Node, property node.Node) node.Node {
} }
} }
func (n PropertyFetch) Print(out io.Writer, indent string) { func (n PropertyFetch) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.variable != nil { if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ") vv := v.Children("variable")
n.variable.Print(out, indent+" ") n.variable.Walk(vv)
} }
if n.property != nil { if n.property != nil {
fmt.Fprintf(out, "\n%vproperty:", indent+" ") vv := v.Children("property")
n.property.Print(out, indent+" ") n.property.Walk(vv)
} }
} }

View File

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

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token" "github.com/z7zmey/php-parser/token"
) )
@ -28,13 +25,15 @@ func NewShortArray(opentToken token.Token, closeToken token.Token, items []node.
} }
} }
func (n ShortArray) Print(out io.Writer, indent string) { func (n ShortArray) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.name, n.opentToken.StartLine, n.closeToken.EndLine) if v.Visit(n) == false {
return
}
if n.items != nil { if n.items != nil {
fmt.Fprintf(out, "\n%vitems:", indent+" ") vv := v.Children("items")
for _, nn := range n.items { for _, nn := range n.items {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -27,23 +24,25 @@ func NewStaticCall(class node.Node, call node.Node, arguments []node.Node) node.
} }
} }
func (n StaticCall) Print(out io.Writer, indent string) { func (n StaticCall) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.class != nil { if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ") vv := v.Children("class")
n.class.Print(out, indent+" ") n.class.Walk(vv)
} }
if n.call != nil { if n.call != nil {
fmt.Fprintf(out, "\n%vcall:", indent+" ") vv := v.Children("call")
n.call.Print(out, indent+" ") n.call.Walk(vv)
} }
if n.arguments != nil { if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ") vv := v.Children("arguments")
for _, nn := range n.arguments { for _, nn := range n.arguments {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,16 +22,18 @@ func NewStaticPropertyFetch(class node.Node, property node.Node) node.Node {
} }
} }
func (n StaticPropertyFetch) Print(out io.Writer, indent string) { func (n StaticPropertyFetch) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.class != nil { if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ") vv := v.Children("class")
n.class.Print(out, indent+" ") n.class.Walk(vv)
} }
if n.property != nil { if n.property != nil {
fmt.Fprintf(out, "\n%vproperty:", indent+" ") vv := v.Children("property")
n.property.Print(out, indent+" ") n.property.Walk(vv)
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -27,21 +24,23 @@ func NewTernary(condition node.Node, ifTrue node.Node, ifFalse node.Node) node.N
} }
} }
func (n Ternary) Print(out io.Writer, indent string) { func (n Ternary) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.condition != nil { if n.condition != nil {
fmt.Fprintf(out, "\n%vcondition:", indent+" ") vv := v.Children("condition")
n.condition.Print(out, indent+" ") n.condition.Walk(vv)
} }
if n.ifTrue != nil { if n.ifTrue != nil {
fmt.Fprintf(out, "\n%vifTrue:", indent+" ") vv := v.Children("ifTrue")
n.ifTrue.Print(out, indent+" ") n.ifTrue.Walk(vv)
} }
if n.ifFalse != nil { if n.ifFalse != nil {
fmt.Fprintf(out, "\n%vifFalse:", indent+" ") vv := v.Children("ifFalse")
n.ifFalse.Print(out, indent+" ") n.ifFalse.Walk(vv)
} }
} }

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -12,22 +9,24 @@ func (n Variable) Name() string {
} }
type Variable struct { type Variable struct {
name string name string
variable node.Node varName node.Node
} }
func NewVariable(variable node.Node) node.Node { func NewVariable(varName node.Node) node.Node {
return Variable{ return Variable{
"Variable", "Variable",
variable, varName,
} }
} }
func (n Variable) Print(out io.Writer, indent string) { func (n Variable) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.variable != nil { if n.varName != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ") vv := v.Children("varName")
n.variable.Print(out, indent+" ") n.varName.Walk(vv)
} }
} }

View File

@ -1,9 +1,6 @@
package expr package expr
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
) )
@ -25,16 +22,18 @@ func NewYield(key node.Node, value node.Node) node.Node {
} }
} }
func (n Yield) Print(out io.Writer, indent string) { func (n Yield) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.key != nil { if n.key != nil {
fmt.Fprintf(out, "\n%vkey:", indent+" ") vv := v.Children("key")
n.key.Print(out, indent+" ") n.key.Walk(vv)
} }
if n.value != nil { if n.value != nil {
fmt.Fprintf(out, "\n%vvalue:", indent+" ") vv := v.Children("value")
n.value.Print(out, indent+" ") n.value.Walk(vv)
} }
} }

View File

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

View File

@ -1,9 +1,6 @@
package node package node
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/token" "github.com/z7zmey/php-parser/token"
) )
@ -23,7 +20,10 @@ func NewIdentifier(token token.Token) Node {
} }
} }
func (n Identifier) Print(out io.Writer, indent string) { func (n Identifier) Walk(v Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
fmt.Fprintf(out, "\n%vname: %q", indent+" ", n.token.Value) return
}
v.Scalar("token", n.token.Value)
} }

View File

@ -1,9 +1,6 @@
package name package name
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "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) { func (n NameNode) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v", indent, n.name) if v.Visit(n) == false {
return
}
if n.parts != nil { if n.parts != nil {
fmt.Fprintf(out, "\n%vparts:", indent+" ") vv := v.Children("parts")
for _, nn := range n.parts { for _, nn := range n.parts {
nn.Print(out, indent+" ") nn.Walk(vv)
} }
} }
} }

View File

@ -1,14 +1,11 @@
package name package name
import ( import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token" "github.com/z7zmey/php-parser/token"
) )
func(n NamePart) Name() string { func (n NamePart) Name() string {
return "NamePart" return "NamePart"
} }
@ -24,6 +21,10 @@ func NewNamePart(token token.Token) node.Node {
} }
} }
func (n NamePart) Print(out io.Writer, indent string) { func (n NamePart) Walk(v node.Visitor) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value) if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
} }

View File

@ -1,10 +1,6 @@
package node package node
import (
"io"
)
type Node interface { type Node interface {
Name() string Name() string
Print(out io.Writer, indent string) Walk(v Visitor)
} }

View File

@ -1,10 +1,5 @@
package node package node
import (
"fmt"
"io"
)
type Nullable struct { type Nullable struct {
name string name string
expr Node expr Node
@ -21,11 +16,13 @@ func NewNullable(expression Node) Node {
} }
} }
func (n Nullable) Print(out io.Writer, indent string) { func (n Nullable) Walk(v Visitor) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name) if v.Visit(n) == false {
return
}
if n.expr != nil { if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ") vv := v.Children("expr")
n.expr.Print(out, indent+" ") n.expr.Walk(vv)
} }
} }

Some files were not shown because too many files have changed in this diff Show More