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

View File

@ -1,10 +1,5 @@
package node
import (
"fmt"
"io"
)
type Argument struct {
name string
expr Node
@ -23,12 +18,13 @@ func NewArgument(expression Node, variadic bool) Node {
}
}
func (n Argument) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
fmt.Fprintf(out, "\n%vvariadic: %t", indent+" ", n.variadic)
func (n Argument) Walk(v 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"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) {
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.name, n.opentToken.StartLine, n.closeToken.EndLine)
func (n Array) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.items != nil {
fmt.Fprintf(out, "\n%vitems:", indent+" ")
vv := v.Children("items")
for _, nn := range n.items {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
func (n ArrayDimFetch) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.dim != nil {
fmt.Fprintf(out, "\n%vdim:", indent+" ")
n.dim.Print(out, indent+" ")
vv := v.Children("dim")
n.dim.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
fmt.Fprintf(out, "\n%vbyRef: %t", indent+" ", n.byRef)
func (n ArrayItem) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
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.val != nil {
fmt.Fprintf(out, "\n%vval:", indent+" ")
n.val.Print(out, indent+" ")
vv := v.Children("val")
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
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
@ -12,17 +9,3 @@ type AssignOp struct {
variable 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 {
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
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
@ -12,17 +9,3 @@ type BinaryOp struct {
left 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 {
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 {
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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

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

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Clone) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Closure) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
fmt.Fprintf(out, "\n%vis static: %t", indent+" ", n.isStatic)
fmt.Fprintf(out, "\n%vis return ref: %t", indent+" ", n.isReturnRef)
v.Scalar("isStatic", n.isStatic)
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.uses != nil {
fmt.Fprintf(out, "\n%vuses:", indent+" ")
vv := v.Children("uses")
for _, nn := range n.uses {
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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
fmt.Fprintf(out, "\n%vby ref: %t", indent+" ", n.byRef)
func (n ClusureUse) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("byRef", n.byRef)
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n ConstFetch) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.constant != nil {
fmt.Fprintf(out, "\n%vconstant:", indent+" ")
n.constant.Print(out, indent+" ")
vv := v.Children("constant")
n.constant.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Empty) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n ErrorSuppress) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Eval) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
fmt.Fprintf(out, "\n%vis die: %t", indent+" ", n.isDie)
func (n Exit) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n FunctionCall) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.function != nil {
fmt.Fprintf(out, "\n%vfunction:", indent+" ")
n.function.Print(out, indent+" ")
vv := v.Children("function")
n.function.Walk(vv)
}
if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ")
vv := v.Children("arguments")
for _, nn := range n.arguments {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Include) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n IncludeOnce) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n InstanceOf) 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.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ")
n.class.Print(out, indent+" ")
vv := v.Children("class")
n.class.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Isset) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variables != nil {
fmt.Fprintf(out, "\n%vvariables:", indent+" ")
vv := v.Children("variables")
for _, nn := range n.variables {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n List) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.items != nil {
fmt.Fprintf(out, "\n%vitems:", indent+" ")
vv := v.Children("items")
for _, nn := range n.items {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n MethodCall) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.method != nil {
fmt.Fprintf(out, "\n%vmethod:", indent+" ")
n.method.Print(out, indent+" ")
vv := v.Children("method")
n.method.Walk(vv)
}
if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ")
vv := v.Children("arguments")
for _, nn := range n.arguments {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n New) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ")
n.class.Print(out, indent+" ")
vv := v.Children("class")
n.class.Walk(vv)
}
if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ")
vv := v.Children("arguments")
for _, nn := range n.arguments {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n PostDec) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n PostInc) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n PreDec) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n PreInc) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Print) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n PropertyFetch) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
vv := v.Children("variable")
n.variable.Walk(vv)
}
if n.property != nil {
fmt.Fprintf(out, "\n%vproperty:", indent+" ")
n.property.Print(out, indent+" ")
vv := v.Children("property")
n.property.Walk(vv)
}
}

View File

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

View File

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

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n ShortList) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.items != nil {
fmt.Fprintf(out, "\n%vitems:", indent+" ")
vv := v.Children("items")
for _, nn := range n.items {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n StaticCall) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ")
n.class.Print(out, indent+" ")
vv := v.Children("class")
n.class.Walk(vv)
}
if n.call != nil {
fmt.Fprintf(out, "\n%vcall:", indent+" ")
n.call.Print(out, indent+" ")
vv := v.Children("call")
n.call.Walk(vv)
}
if n.arguments != nil {
fmt.Fprintf(out, "\n%varguments:", indent+" ")
vv := v.Children("arguments")
for _, nn := range n.arguments {
nn.Print(out, indent+" ")
nn.Walk(vv)
}
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n StaticPropertyFetch) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.class != nil {
fmt.Fprintf(out, "\n%vclass:", indent+" ")
n.class.Print(out, indent+" ")
vv := v.Children("class")
n.class.Walk(vv)
}
if n.property != nil {
fmt.Fprintf(out, "\n%vproperty:", indent+" ")
n.property.Print(out, indent+" ")
vv := v.Children("property")
n.property.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Ternary) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.condition != nil {
fmt.Fprintf(out, "\n%vcondition:", indent+" ")
n.condition.Print(out, indent+" ")
vv := v.Children("condition")
n.condition.Walk(vv)
}
if n.ifTrue != nil {
fmt.Fprintf(out, "\n%vifTrue:", indent+" ")
n.ifTrue.Print(out, indent+" ")
vv := v.Children("ifTrue")
n.ifTrue.Walk(vv)
}
if n.ifFalse != nil {
fmt.Fprintf(out, "\n%vifFalse:", indent+" ")
n.ifFalse.Print(out, indent+" ")
vv := v.Children("ifFalse")
n.ifFalse.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n UnaryMinus) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n UnaryPlus) 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,9 +1,6 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
@ -13,21 +10,23 @@ func (n Variable) Name() string {
type Variable struct {
name string
variable node.Node
varName node.Node
}
func NewVariable(variable node.Node) node.Node {
func NewVariable(varName node.Node) node.Node {
return Variable{
"Variable",
variable,
varName,
}
}
func (n Variable) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Variable) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
if n.varName != nil {
vv := v.Children("varName")
n.varName.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Yield) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
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.value != nil {
fmt.Fprintf(out, "\n%vvalue:", indent+" ")
n.value.Print(out, indent+" ")
vv := v.Children("value")
n.value.Walk(vv)
}
}

View File

@ -1,9 +1,6 @@
package expr
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n YieldFrom) 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,9 +1,6 @@
package node
import (
"fmt"
"io"
"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) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
fmt.Fprintf(out, "\n%vname: %q", indent+" ", n.token.Value)
func (n Identifier) Walk(v Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("token", n.token.Value)
}

View File

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

View File

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

View File

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

View File

@ -1,10 +1,5 @@
package node
import (
"fmt"
"io"
)
type Nullable struct {
name string
expr Node
@ -21,11 +16,13 @@ func NewNullable(expression Node) Node {
}
}
func (n Nullable) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
func (n Nullable) Walk(v 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)
}
}

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