remove SimpleNode

This commit is contained in:
vadim
2017-12-27 19:55:58 +02:00
parent e83ab79344
commit 32a285b437
159 changed files with 1195 additions and 622 deletions

View File

@@ -1,20 +1,36 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n AltElse) Name() string {
return "AltElse"
}
type AltElse struct {
Else
name string
token token.Token
stmt node.Node
}
func NewAltElse(token token.Token, stmt node.Node) node.Node {
return AltElse{
Else{
node.SimpleNode{Name: "AltElse", Attributes: make(map[string]string)},
token,
stmt,
},
"AltElse",
token,
stmt,
}
}
func (n AltElse) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
}
}

View File

@@ -1,21 +1,43 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n AltElseIf) Name() string {
return "AltElseIf"
}
type AltElseIf struct {
ElseIf
name string
token token.Token
cond node.Node
stmt node.Node
}
func NewAltElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
return AltElseIf{
ElseIf{
node.SimpleNode{Name: "AltElseIf", Attributes: make(map[string]string)},
token,
cond,
stmt,
},
"AltElseIf",
token,
cond,
stmt,
}
}
func (n AltElseIf) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
}
}

View File

@@ -1,33 +1,43 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n AltIf) Name() string {
return "AltIf"
}
type AltIf struct {
If
name string
token token.Token
cond node.Node
stmt node.Node
elseAltIf []node.Node
_else node.Node
}
func NewAltIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
return AltIf{
If{
node.SimpleNode{Name: "AltIf", Attributes: make(map[string]string)},
token,
cond,
stmt,
nil,
nil,
},
"AltIf",
token,
cond,
stmt,
nil,
nil,
}
}
func (n AltIf) AddElseIf(elseIf node.Node) node.Node {
if n.elseIf == nil {
n.elseIf = make([]node.Node, 0)
func (n AltIf) AddElseIf(elseAltIf node.Node) node.Node {
if n.elseAltIf == nil {
n.elseAltIf = make([]node.Node, 0)
}
n.elseIf = append(n.elseIf, elseIf)
n.elseAltIf = append(n.elseAltIf, elseAltIf)
return n
}
@@ -37,3 +47,28 @@ func (n AltIf) SetElse(_else node.Node) node.Node {
return n
}
func (n AltIf) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")
}
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")
n.stmt.Print(out, indent+" ")
}
if n.elseAltIf != nil {
fmt.Fprintf(out, "\n%velseAltIfs:", indent+" ")
for _, nn := range n.elseAltIf {
nn.Print(out, indent+" ")
}
}
if n._else != nil {
fmt.Fprintf(out, "\n%velse:", indent+" ")
n._else.Print(out, indent+" ")
}
}

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Break) Name() string {
return "Break"
}
type Break struct {
node.SimpleNode
name string
token token.Token
expr node.Node
}
func NewBreak(token token.Token, expr node.Node) node.Node {
return Break{
node.SimpleNode{Name: "Break", Attributes: make(map[string]string)},
"Break",
token,
expr,
}
}
func (n Break) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Case) Name() string {
return "Case"
}
type Case struct {
node.SimpleNode
name string
token token.Token
cond node.Node
stmts []node.Node
@@ -17,7 +21,7 @@ type Case struct {
func NewCase(token token.Token, cond node.Node, stmts []node.Node) node.Node {
return Case{
node.SimpleNode{Name: "Case", Attributes: make(map[string]string)},
"Case",
token,
cond,
stmts,
@@ -25,7 +29,7 @@ func NewCase(token token.Token, cond node.Node, stmts []node.Node) node.Node {
}
func (n Case) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%vcond:", indent+" ")
n.cond.Print(out, indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Catch) Name() string {
return "Catch"
}
type Catch struct {
node.SimpleNode
name string
token token.Token
types []node.Node
variable node.Node
@@ -18,7 +22,7 @@ type Catch struct {
func NewCatch(token token.Token, types []node.Node, variable node.Node, stmts []node.Node) node.Node {
return Catch{
node.SimpleNode{Name: "Catch", Attributes: make(map[string]string)},
"Catch",
token,
types,
variable,
@@ -27,7 +31,7 @@ func NewCatch(token token.Token, types []node.Node, variable node.Node, stmts []
}
func (n Catch) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%vtypes:", indent+" ")
for _, nn := range n.types {

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Class) Name() string {
return "Class"
}
type Class struct {
node.SimpleNode
name string
token token.Token
modifiers []node.Node
args []node.Node
@@ -20,7 +24,7 @@ type Class struct {
func NewClass(token token.Token, modifiers []node.Node, args []node.Node, extends node.Node, implements []node.Node, stmts []node.Node) node.Node {
return Class{
node.SimpleNode{Name: "Class", Attributes: make(map[string]string)},
"Class",
token,
modifiers,
args,
@@ -31,7 +35,7 @@ func NewClass(token token.Token, modifiers []node.Node, args []node.Node, extend
}
func (n Class) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmotifiers:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n ClassConstList) Name() string {
return "ClassConstList"
}
type ClassConstList struct {
node.SimpleNode
name string
token token.Token
modifiers []node.Node
consts []node.Node
@@ -17,7 +21,7 @@ type ClassConstList struct {
func NewClassConstList(token token.Token, modifiers []node.Node, consts []node.Node) node.Node {
return ClassConstList{
node.SimpleNode{Name: "ClassConstList", Attributes: make(map[string]string)},
"ClassConstList",
token,
modifiers,
consts,
@@ -25,7 +29,7 @@ func NewClassConstList(token token.Token, modifiers []node.Node, consts []node.N
}
func (n ClassConstList) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmotifiers:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n ClassMethod) Name() string {
return "ClassMethod"
}
type ClassMethod struct {
node.SimpleNode
name string
token token.Token
modifiers []node.Node
isReturnRef bool
@@ -20,7 +24,7 @@ type ClassMethod struct {
func NewClassMethod(token token.Token, modifiers []node.Node, isReturnRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
return ClassMethod{
node.SimpleNode{Name: "ClassMethod", Attributes: make(map[string]string)},
"ClassMethod",
token,
modifiers,
isReturnRef,
@@ -31,7 +35,7 @@ func NewClassMethod(token token.Token, modifiers []node.Node, isReturnRef bool,
}
func (n ClassMethod) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmodifiers:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n ConstList) Name() string {
return "ConstList"
}
type ConstList struct {
node.SimpleNode
name string
token token.Token
consts []node.Node
}
func NewConstList(token token.Token, consts []node.Node) node.Node {
return ConstList{
node.SimpleNode{Name: "ConstList", Attributes: make(map[string]string)},
"ConstList",
token,
consts,
}
}
func (n ConstList) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.consts != nil {
fmt.Fprintf(out, "\n%vconsts:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Constant) Name() string {
return "Constant"
}
type Constant struct {
node.SimpleNode
name string
token token.Token
expr node.Node
}
func NewConstant(token token.Token, expr node.Node) node.Node {
return Constant{
node.SimpleNode{Name: "Constant", Attributes: make(map[string]string)},
"Constant",
token,
expr,
}
}
func (n Constant) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Continue) Name() string {
return "Continue"
}
type Continue struct {
node.SimpleNode
name string
token token.Token
expr node.Node
expr node.Node
}
func NewContinue(token token.Token, expr node.Node) node.Node {
return Continue{
node.SimpleNode{Name: "Continue", Attributes: make(map[string]string)},
"Continue",
token,
expr,
}
}
func (n Continue) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Declare) Name() string {
return "Declare"
}
type Declare struct {
node.SimpleNode
name string
token token.Token
consts []node.Node
stmt node.Node
@@ -17,7 +21,7 @@ type Declare struct {
func NewDeclare(token token.Token, consts []node.Node, stmt node.Node) node.Node {
return Declare{
node.SimpleNode{Name: "Declare", Attributes: make(map[string]string)},
"Declare",
token,
consts,
stmt,
@@ -25,7 +29,7 @@ func NewDeclare(token token.Token, consts []node.Node, stmt node.Node) node.Node
}
func (n Declare) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.consts != nil {
fmt.Fprintf(out, "\n%vconsts:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Default) Name() string {
return "Default"
}
type Default struct {
node.SimpleNode
name string
token token.Token
stmts []node.Node
}
func NewDefault(token token.Token, stmts []node.Node) node.Node {
return Default{
node.SimpleNode{Name: "Default", Attributes: make(map[string]string)},
"Default",
token,
stmts,
}
}
func (n Default) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Do) Name() string {
return "Do"
}
type Do struct {
node.SimpleNode
name string
token token.Token
stmt node.Node
cond node.Node
@@ -17,7 +21,7 @@ type Do struct {
func NewDo(token token.Token, stmt node.Node, cond node.Node) node.Node {
return Do{
node.SimpleNode{Name: "Do", Attributes: make(map[string]string)},
"Do",
token,
stmt,
cond,
@@ -25,7 +29,7 @@ func NewDo(token token.Token, stmt node.Node, cond node.Node) node.Node {
}
func (n Do) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Echo) Name() string {
return "Echo"
}
type Echo struct {
node.SimpleNode
name string
token token.Token
exprs []node.Node
}
func NewEcho(token token.Token, exprs []node.Node) node.Node {
return Echo{
node.SimpleNode{Name: "Echo", Attributes: make(map[string]string)},
"Echo",
token,
exprs,
}
}
func (n Echo) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.exprs != nil {
fmt.Fprintf(out, "\n%vexprs:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Else) Name() string {
return "Else"
}
type Else struct {
node.SimpleNode
name string
token token.Token
stmt node.Node
}
func NewElse(token token.Token, stmt node.Node) node.Node {
return Else{
node.SimpleNode{Name: "Else", Attributes: make(map[string]string)},
"Else",
token,
stmt,
}
}
func (n Else) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.stmt != nil {
fmt.Fprintf(out, "\n%vstmt:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n ElseIf) Name() string {
return "ElseIf"
}
type ElseIf struct {
node.SimpleNode
name string
token token.Token
cond node.Node
stmt node.Node
@@ -17,7 +21,7 @@ type ElseIf struct {
func NewElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
return ElseIf{
node.SimpleNode{Name: "ElseIf", Attributes: make(map[string]string)},
"ElseIf",
token,
cond,
stmt,
@@ -25,7 +29,7 @@ func NewElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
}
func (n ElseIf) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")

View File

@@ -7,20 +7,24 @@ import (
"github.com/z7zmey/php-parser/node"
)
func(n Expression) Name() string {
return "Expression"
}
type Expression struct {
node.SimpleNode
name string
expr node.Node
}
func NewExpression(expr node.Node) node.Node {
return Expression{
node.SimpleNode{Name: "Expression", Attributes: make(map[string]string)},
"Expression",
expr,
}
}
func (n Expression) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Finally) Name() string {
return "Finally"
}
type Finally struct {
node.SimpleNode
name string
token token.Token
stmts []node.Node
}
func NewFinally(token token.Token, stmts []node.Node) node.Node {
return Finally{
node.SimpleNode{Name: "Finally", Attributes: make(map[string]string)},
"Finally",
token,
stmts,
}
}
func (n Finally) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n For) Name() string {
return "For"
}
type For struct {
node.SimpleNode
name string
token token.Token
init []node.Node
cond []node.Node
@@ -19,7 +23,7 @@ type For struct {
func NewFor(token token.Token, init []node.Node, cond []node.Node, loop []node.Node, stmt node.Node) node.Node {
return For{
node.SimpleNode{Name: "For", Attributes: make(map[string]string)},
"For",
token,
init,
cond,
@@ -29,7 +33,7 @@ func NewFor(token token.Token, init []node.Node, cond []node.Node, loop []node.N
}
func (n For) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.init != nil {
fmt.Fprintf(out, "\n%vinit:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Foreach) Name() string {
return "Foreach"
}
type Foreach struct {
node.SimpleNode
name string
token token.Token
expr node.Node
key node.Node
@@ -20,7 +24,7 @@ type Foreach struct {
func NewForeach(token token.Token, expr node.Node, key node.Node, variable node.Node, stmt node.Node, byRef bool) node.Node {
return Foreach{
node.SimpleNode{Name: "Foreach", Attributes: make(map[string]string)},
"Foreach",
token,
expr,
key,
@@ -31,7 +35,7 @@ func NewForeach(token token.Token, expr node.Node, key node.Node, variable node.
}
func (n Foreach) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Function) Name() string {
return "Function"
}
type Function struct {
node.SimpleNode
name string
token token.Token
isReturnRef bool
params []node.Node
@@ -19,7 +23,7 @@ type Function struct {
func NewFunction(token token.Token, isReturnRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
return Function{
node.SimpleNode{Name: "Function", Attributes: make(map[string]string)},
"Function",
token,
isReturnRef,
params,
@@ -29,7 +33,7 @@ func NewFunction(token token.Token, isReturnRef bool, params []node.Node, return
}
func (n Function) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%vreturn ref: %t", indent+" ", n.isReturnRef)

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Global) Name() string {
return "Global"
}
type Global struct {
node.SimpleNode
name string
token token.Token
vars []node.Node
}
func NewGlobal(token token.Token, vars []node.Node) node.Node {
return Global{
node.SimpleNode{Name: "Global", Attributes: make(map[string]string)},
"Global",
token,
vars,
}
}
func (n Global) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.vars != nil {
fmt.Fprintf(out, "\n%vvars:", indent+" ")

View File

@@ -8,20 +8,24 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Goto) Name() string {
return "Goto"
}
type Goto struct {
node.SimpleNode
name string
token token.Token
name token.Token
label token.Token
}
func NewGoto(token token.Token, name token.Token) node.Node {
return Goto{
node.SimpleNode{Name: "Goto", Attributes: make(map[string]string)},
"Goto",
token,
name,
}
}
func (n Goto) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.name.EndLine, n.name.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.label.EndLine, n.label.Value)
}

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n GroupUse) Name() string {
return "GroupUse"
}
type GroupUse struct {
node.SimpleNode
name string
token token.TokenInterface
useType node.Node
prefix node.Node
@@ -19,7 +23,7 @@ type GroupUse struct {
//TODO: stmts myst be []node.Node
func NewGroupUse(token token.TokenInterface, useType node.Node, prefix node.Node, useList []node.Node) node.Node {
return GroupUse{
node.SimpleNode{Name: "GroupUse", Attributes: make(map[string]string)},
"GroupUse",
token,
useType,
prefix,
@@ -38,7 +42,7 @@ func (n GroupUse) SetUseType(useType node.Node) node.Node {
}
func (n GroupUse) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.GetStartLine(), n.token.GetEndLine(), n.token.GetValue())
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.GetStartLine(), n.token.GetEndLine(), n.token.GetValue())
if n.useType != nil {
fmt.Fprintf(out, "\n%vuse type:", indent+" ")

View File

@@ -8,18 +8,22 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n HaltCompiler) Name() string {
return "HaltCompiler"
}
type HaltCompiler struct {
node.SimpleNode
name string
token token.Token
}
func NewHaltCompiler(token token.Token) node.Node {
return HaltCompiler{
node.SimpleNode{Name: "HaltCompiler", Attributes: make(map[string]string)},
"HaltCompiler",
token,
}
}
func (n HaltCompiler) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n If) Name() string {
return "If"
}
type If struct {
node.SimpleNode
name string
token token.Token
cond node.Node
stmt node.Node
@@ -19,7 +23,7 @@ type If struct {
func NewIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
return If{
node.SimpleNode{Name: "If", Attributes: make(map[string]string)},
"If",
token,
cond,
stmt,
@@ -45,7 +49,7 @@ func (n If) SetElse(_else node.Node) node.Node {
}
func (n If) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")

View File

@@ -8,18 +8,22 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n InlineHtml) Name() string {
return "InlineHtml"
}
type InlineHtml struct {
node.SimpleNode
name string
token token.Token
}
func NewInlineHtml(token token.Token) node.Node {
return InlineHtml{
node.SimpleNode{Name: "InlineHtml", Attributes: make(map[string]string)},
"InlineHtml",
token,
}
}
func (n InlineHtml) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -8,17 +8,21 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Interface) Name() string {
return "Interface"
}
type Interface struct {
node.SimpleNode
name string
token token.Token
name token.Token
iName token.Token
extends []node.Node
stmts []node.Node
}
func NewInterface(token token.Token, name token.Token, extends []node.Node, stmts []node.Node) node.Node {
return Interface{
node.SimpleNode{Name: "Interface", Attributes: make(map[string]string)},
"Interface",
token,
name,
extends,
@@ -27,7 +31,7 @@ func NewInterface(token token.Token, name token.Token, extends []node.Node, stmt
}
func (n Interface) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.name.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.iName.Value)
if n.extends != nil {
fmt.Fprintf(out, "\n%vextends:", indent+" ")

View File

@@ -8,18 +8,22 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Label) Name() string {
return "Label"
}
type Label struct {
node.SimpleNode
name string
token token.Token
}
func NewLabel(token token.Token) node.Node {
return Label{
node.SimpleNode{Name: "Label", Attributes: make(map[string]string)},
"Label",
token,
}
}
func (n Label) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -8,16 +8,20 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Namespace) Name() string {
return "Namespace"
}
type Namespace struct {
node.SimpleNode
name string
token token.Token
name node.Node
nName node.Node
stmts []node.Node
}
func NewNamespace(token token.Token, name node.Node, stmts []node.Node) node.Node {
return Namespace{
node.SimpleNode{Name: "Namespace", Attributes: make(map[string]string)},
"Namespace",
token,
name,
stmts,
@@ -25,11 +29,11 @@ func NewNamespace(token token.Token, name node.Node, stmts []node.Node) node.Nod
}
func (n Namespace) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.name != nil {
if n.nName != nil {
fmt.Fprintf(out, "\n%vname:", indent+" ")
n.name.Print(out, indent+" ")
n.nName.Print(out, indent+" ")
}
if n.stmts != nil {

View File

@@ -8,18 +8,22 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Nop) Name() string {
return "Nop"
}
type Nop struct {
node.SimpleNode
name string
token token.Token
}
func NewNop(token token.Token) node.Node {
return Nop{
node.SimpleNode{Name: "Nop", Attributes: make(map[string]string)},
"Nop",
token,
}
}
func (n Nop) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Property) Name() string {
return "Property"
}
type Property struct {
node.SimpleNode
name string
token token.Token
expr node.Node
}
func NewProperty(token token.Token, expr node.Node) node.Node {
return Property{
node.SimpleNode{Name: "Property", Attributes: make(map[string]string)},
"Property",
token,
expr,
}
}
func (n Property) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -7,22 +7,26 @@ import (
"github.com/z7zmey/php-parser/node"
)
func(n PropertyList) Name() string {
return "PropertyList"
}
type PropertyList struct {
node.SimpleNode
name string
modifiers []node.Node
properties []node.Node
}
func NewPropertyList(modifiers []node.Node, properties []node.Node) node.Node {
return PropertyList{
node.SimpleNode{Name: "PropertyList", Attributes: make(map[string]string)},
"PropertyList",
modifiers,
properties,
}
}
func (n PropertyList) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.modifiers != nil {
fmt.Fprintf(out, "\n%vmodifiers:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Return) Name() string {
return "Return"
}
type Return struct {
node.SimpleNode
name string
token token.Token
expr node.Node
}
func NewReturn(token token.Token, expr node.Node) node.Node {
return Return{
node.SimpleNode{Name: "Return", Attributes: make(map[string]string)},
"Return",
token,
expr,
}
}
func (n Return) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Static) Name() string {
return "Static"
}
type Static struct {
node.SimpleNode
name string
token token.Token
vars []node.Node
}
func NewStatic(token token.Token, vars []node.Node) node.Node {
return Static{
node.SimpleNode{Name: "Static", Attributes: make(map[string]string)},
"Static",
token,
vars,
}
}
func (n Static) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.vars != nil {
fmt.Fprintf(out, "\n%vvars:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n StaticVar) Name() string {
return "StaticVar"
}
type StaticVar struct {
node.SimpleNode
name string
token token.Token
expr node.Node
}
func NewStaticVar(token token.Token, expr node.Node) node.Node {
return StaticVar{
node.SimpleNode{Name: "StaticVar", Attributes: make(map[string]string)},
"StaticVar",
token,
expr,
}
}
func (n StaticVar) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -7,20 +7,24 @@ import (
"github.com/z7zmey/php-parser/node"
)
func(n StmtList) Name() string {
return "StmtList"
}
type StmtList struct {
node.SimpleNode
name string
stmts []node.Node
}
func NewStmtList(stmts []node.Node) node.Node {
return StmtList{
node.SimpleNode{Name: "StmtList", Attributes: make(map[string]string)},
"StmtList",
stmts,
}
}
func (n StmtList) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Switch) Name() string {
return "Switch"
}
type Switch struct {
node.SimpleNode
name string
token token.Token
cond node.Node
cases []node.Node
@@ -17,7 +21,7 @@ type Switch struct {
func NewSwitch(token token.Token, cond node.Node, cases []node.Node) node.Node {
return Switch{
node.SimpleNode{Name: "Switch", Attributes: make(map[string]string)},
"Switch",
token,
cond,
cases,
@@ -25,7 +29,7 @@ func NewSwitch(token token.Token, cond node.Node, cases []node.Node) node.Node {
}
func (n Switch) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Throw) Name() string {
return "Throw"
}
type Throw struct {
node.SimpleNode
name string
token token.Token
expr node.Node
}
func NewThrow(token token.Token, expr node.Node) node.Node {
return Throw{
node.SimpleNode{Name: "Throw", Attributes: make(map[string]string)},
"Throw",
token,
expr,
}
}
func (n Throw) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Trait) Name() string {
return "Trait"
}
type Trait struct {
node.SimpleNode
name string
token token.Token
stmts []node.Node
}
@@ -17,14 +21,14 @@ type Trait struct {
//TODO: stmts myst be []node.Node
func NewTrait(token token.Token, stmts []node.Node) node.Node {
return Trait{
node.SimpleNode{Name: "Trait", Attributes: make(map[string]string)},
"Trait",
token,
stmts,
}
}
func (n Trait) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n TraitMethodRef) Name() string {
return "TraitMethodRef"
}
type TraitMethodRef struct {
node.SimpleNode
name string
trait node.Node
method token.Token
}
func NewTraitMethodRef(trait node.Node, method token.Token) node.Node {
return TraitMethodRef{
node.SimpleNode{Name: "TraitMethodRef", Attributes: make(map[string]string)},
"TraitMethodRef",
trait,
method,
}
}
func (n TraitMethodRef) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -] %q", indent, n.Name, n.method.Value)
fmt.Fprintf(out, "\n%v%v [- -] %q", indent, n.name, n.method.Value)
if n.trait != nil {
fmt.Fprintf(out, "\n%vtrait", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n TraitUse) Name() string {
return "TraitUse"
}
type TraitUse struct {
node.SimpleNode
name string
token token.Token
traits []node.Node
adaptations []node.Node
@@ -18,7 +22,7 @@ type TraitUse struct {
//TODO: traits myst be []node.Node
func NewTraitUse(token token.Token, traits []node.Node, adaptations []node.Node) node.Node {
return TraitUse{
node.SimpleNode{Name: "TraitUse", Attributes: make(map[string]string)},
"TraitUse",
token,
traits,
adaptations,
@@ -26,7 +30,7 @@ func NewTraitUse(token token.Token, traits []node.Node, adaptations []node.Node)
}
func (n TraitUse) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.traits != nil {
fmt.Fprintf(out, "\n%vtraits:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n TraitUseAlias) Name() string {
return "TraitUseAlias"
}
type TraitUseAlias struct {
node.SimpleNode
name string
ref node.Node
modifier node.Node
alias token.TokenInterface
@@ -17,7 +21,7 @@ type TraitUseAlias struct {
func NewTraitUseAlias(ref node.Node, modifier node.Node, alias token.TokenInterface) node.Node {
return TraitUseAlias{
node.SimpleNode{Name: "TraitUseAlias", Attributes: make(map[string]string)},
"TraitUseAlias",
ref,
modifier,
alias,
@@ -25,7 +29,7 @@ func NewTraitUseAlias(ref node.Node, modifier node.Node, alias token.TokenInterf
}
func (n TraitUseAlias) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.alias != nil {
fmt.Fprintf(out, "\n%valias: %q", indent+" ", n.alias.GetValue())

View File

@@ -7,22 +7,26 @@ import (
"github.com/z7zmey/php-parser/node"
)
func(n TraitUsePrecedence) Name() string {
return "TraitUsePrecedence"
}
type TraitUsePrecedence struct {
node.SimpleNode
name string
ref node.Node
insteadof node.Node
}
func NewTraitUsePrecedence(ref node.Node, insteadof node.Node) node.Node {
return TraitUsePrecedence{
node.SimpleNode{Name: "TraitUsePrecedence", Attributes: make(map[string]string)},
"TraitUsePrecedence",
ref,
insteadof,
}
}
func (n TraitUsePrecedence) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.ref != nil {
fmt.Fprintf(out, "\n%vmethod", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Try) Name() string {
return "Try"
}
type Try struct {
node.SimpleNode
name string
token token.Token
stmts []node.Node
catches []node.Node
@@ -18,7 +22,7 @@ type Try struct {
func NewTry(token token.Token, stmts []node.Node, catches []node.Node, finally node.Node) node.Node {
return Try{
node.SimpleNode{Name: "Try", Attributes: make(map[string]string)},
"Try",
token,
stmts,
catches,
@@ -27,7 +31,7 @@ func NewTry(token token.Token, stmts []node.Node, catches []node.Node, finally n
}
func (n Try) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")

View File

@@ -8,22 +8,26 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Unset) Name() string {
return "Unset"
}
type Unset struct {
node.SimpleNode
name string
token token.Token
vars []node.Node
}
func NewUnset(token token.Token, vars []node.Node) node.Node {
return Unset{
node.SimpleNode{Name: "Unset", Attributes: make(map[string]string)},
"Unset",
token,
vars,
}
}
func (n Unset) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.vars != nil {
fmt.Fprintf(out, "\n%vvars:", indent+" ")

View File

@@ -8,18 +8,22 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n Use) Name() string {
return "Use"
}
type Use struct {
node.SimpleNode
name string
useType node.Node
name node.Node
use node.Node
alias token.TokenInterface
}
func NewUse(useType node.Node, name node.Node, alias token.TokenInterface) node.Node {
func NewUse(useType node.Node, use node.Node, alias token.TokenInterface) node.Node {
return Use{
node.SimpleNode{Name: "Use", Attributes: make(map[string]string)},
"Use",
useType,
name,
use,
alias,
}
}
@@ -30,16 +34,16 @@ func (n Use) SetType(useType node.Node) node.Node {
}
func (n Use) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.name)
if n.useType != nil {
fmt.Fprintf(out, "\n%vtype:", indent+" ")
n.useType.Print(out, indent+" ")
}
if n.name != nil {
fmt.Fprintf(out, "\n%vname:", indent+" ")
n.name.Print(out, indent+" ")
if n.use != nil {
fmt.Fprintf(out, "\n%vuse:", indent+" ")
n.use.Print(out, indent+" ")
}
if n.alias != nil {

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n UseList) Name() string {
return "UseList"
}
type UseList struct {
node.SimpleNode
name string
token token.Token
useType node.Node
uses []node.Node
@@ -17,7 +21,7 @@ type UseList struct {
func NewUseList(token token.Token, useType node.Node, uses []node.Node) node.Node {
return UseList{
node.SimpleNode{Name: "UseList", Attributes: make(map[string]string)},
"UseList",
token,
useType,
uses,
@@ -25,7 +29,7 @@ func NewUseList(token token.Token, useType node.Node, uses []node.Node) node.Nod
}
func (n UseList) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.useType != nil {
fmt.Fprintf(out, "\n%vtype:", indent+" ")

View File

@@ -8,8 +8,12 @@ import (
"github.com/z7zmey/php-parser/token"
)
func(n While) Name() string {
return "While"
}
type While struct {
node.SimpleNode
name string
token token.Token
cond node.Node
stmt node.Node
@@ -17,7 +21,7 @@ type While struct {
func NewWhile(token token.Token, cond node.Node, stmt node.Node) node.Node {
return While{
node.SimpleNode{Name: "While", Attributes: make(map[string]string)},
"While",
token,
cond,
stmt,
@@ -25,7 +29,7 @@ func NewWhile(token token.Token, cond node.Node, stmt node.Node) node.Node {
}
func (n While) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.cond != nil {
fmt.Fprintf(out, "\n%vcond:", indent+" ")