node attributes
This commit is contained in:
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type AltElse struct {
|
||||
name string
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewAltElse(stmt node.Node) node.Node {
|
||||
return AltElse{
|
||||
"AltElse",
|
||||
stmt,
|
||||
}
|
||||
}
|
||||
|
||||
func (n AltElse) Name() string {
|
||||
return "AltElse"
|
||||
}
|
||||
|
||||
type AltElse struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewAltElse(token token.Token, stmt node.Node) node.Node {
|
||||
return AltElse{
|
||||
"AltElse",
|
||||
token,
|
||||
stmt,
|
||||
}
|
||||
func (n AltElse) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n AltElse) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type AltElseIf struct {
|
||||
name string
|
||||
cond node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewAltElseIf(cond node.Node, stmt node.Node) node.Node {
|
||||
return AltElseIf{
|
||||
"AltElseIf",
|
||||
cond,
|
||||
stmt,
|
||||
}
|
||||
}
|
||||
|
||||
func (n AltElseIf) Name() string {
|
||||
return "AltElseIf"
|
||||
}
|
||||
|
||||
type AltElseIf struct {
|
||||
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{
|
||||
"AltElseIf",
|
||||
token,
|
||||
cond,
|
||||
stmt,
|
||||
}
|
||||
func (n AltElseIf) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n AltElseIf) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,26 +2,19 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n AltIf) Name() string {
|
||||
return "AltIf"
|
||||
}
|
||||
|
||||
type AltIf struct {
|
||||
name string
|
||||
token token.Token
|
||||
cond node.Node
|
||||
stmt node.Node
|
||||
elseIf []node.Node
|
||||
_else node.Node
|
||||
}
|
||||
|
||||
func NewAltIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
|
||||
func NewAltIf(cond node.Node, stmt node.Node) node.Node {
|
||||
return AltIf{
|
||||
"AltIf",
|
||||
token,
|
||||
cond,
|
||||
stmt,
|
||||
nil,
|
||||
@@ -29,6 +22,14 @@ func NewAltIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n AltIf) Name() string {
|
||||
return "AltIf"
|
||||
}
|
||||
|
||||
func (n AltIf) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n AltIf) AddElseIf(elseIf node.Node) node.Node {
|
||||
if n.elseIf == nil {
|
||||
n.elseIf = make([]node.Node, 0)
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Break struct {
|
||||
name string
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewBreak(expr node.Node) node.Node {
|
||||
return Break{
|
||||
"Break",
|
||||
expr,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Break) Name() string {
|
||||
return "Break"
|
||||
}
|
||||
|
||||
type Break struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewBreak(token token.Token, expr node.Node) node.Node {
|
||||
return Break{
|
||||
"Break",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n Break) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Break) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Case struct {
|
||||
name string
|
||||
cond node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewCase(cond node.Node, stmts []node.Node) node.Node {
|
||||
return Case{
|
||||
"Case",
|
||||
cond,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Case) Name() string {
|
||||
return "Case"
|
||||
}
|
||||
|
||||
type Case struct {
|
||||
name string
|
||||
token token.Token
|
||||
cond node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewCase(token token.Token, cond node.Node, stmts []node.Node) node.Node {
|
||||
return Case{
|
||||
"Case",
|
||||
token,
|
||||
cond,
|
||||
stmts,
|
||||
}
|
||||
func (n Case) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Case) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,31 +2,32 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n Catch) Name() string {
|
||||
return "Catch"
|
||||
}
|
||||
|
||||
type Catch struct {
|
||||
name string
|
||||
token token.Token
|
||||
types []node.Node
|
||||
variable node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewCatch(token token.Token, types []node.Node, variable node.Node, stmts []node.Node) node.Node {
|
||||
func NewCatch(types []node.Node, variable node.Node, stmts []node.Node) node.Node {
|
||||
return Catch{
|
||||
"Catch",
|
||||
token,
|
||||
types,
|
||||
variable,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Catch) Name() string {
|
||||
return "Catch"
|
||||
}
|
||||
|
||||
func (n Catch) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Catch) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -2,16 +2,11 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n Class) Name() string {
|
||||
return "Class"
|
||||
}
|
||||
|
||||
type Class struct {
|
||||
name string
|
||||
token token.Token
|
||||
className node.Node
|
||||
modifiers []node.Node
|
||||
args []node.Node
|
||||
extends node.Node
|
||||
@@ -19,10 +14,10 @@ type Class struct {
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewClass(token token.Token, modifiers []node.Node, args []node.Node, extends node.Node, implements []node.Node, stmts []node.Node) node.Node {
|
||||
func NewClass(className node.Node, modifiers []node.Node, args []node.Node, extends node.Node, implements []node.Node, stmts []node.Node) node.Node {
|
||||
return Class{
|
||||
"Class",
|
||||
token,
|
||||
className,
|
||||
modifiers,
|
||||
args,
|
||||
extends,
|
||||
@@ -31,12 +26,23 @@ func NewClass(token token.Token, modifiers []node.Node, args []node.Node, extend
|
||||
}
|
||||
}
|
||||
|
||||
func (n Class) Name() string {
|
||||
return "Class"
|
||||
}
|
||||
|
||||
func (n Class) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Class) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
if n.className != nil {
|
||||
vv := v.GetChildrenVisitor("className")
|
||||
n.className.Walk(vv)
|
||||
}
|
||||
|
||||
if n.modifiers != nil {
|
||||
vv := v.GetChildrenVisitor("modifiers")
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type ClassConstList struct {
|
||||
name string
|
||||
modifiers []node.Node
|
||||
consts []node.Node
|
||||
}
|
||||
|
||||
func NewClassConstList(modifiers []node.Node, consts []node.Node) node.Node {
|
||||
return ClassConstList{
|
||||
"ClassConstList",
|
||||
modifiers,
|
||||
consts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n ClassConstList) Name() string {
|
||||
return "ClassConstList"
|
||||
}
|
||||
|
||||
type ClassConstList struct {
|
||||
name string
|
||||
token token.Token
|
||||
modifiers []node.Node
|
||||
consts []node.Node
|
||||
}
|
||||
|
||||
func NewClassConstList(token token.Token, modifiers []node.Node, consts []node.Node) node.Node {
|
||||
return ClassConstList{
|
||||
"ClassConstList",
|
||||
token,
|
||||
modifiers,
|
||||
consts,
|
||||
}
|
||||
func (n ClassConstList) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n ClassConstList) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,33 +2,38 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type ClassMethod struct {
|
||||
name string
|
||||
attributes map[string]interface{}
|
||||
methodName node.Node
|
||||
modifiers []node.Node
|
||||
params []node.Node
|
||||
returnType node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewClassMethod(methodName node.Node, modifiers []node.Node, returnsRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
|
||||
return ClassMethod{
|
||||
"ClassMethod",
|
||||
map[string]interface{}{
|
||||
"returnsRef": returnsRef,
|
||||
},
|
||||
methodName,
|
||||
modifiers,
|
||||
params,
|
||||
returnType,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n ClassMethod) Name() string {
|
||||
return "ClassMethod"
|
||||
}
|
||||
|
||||
type ClassMethod struct {
|
||||
name string
|
||||
token token.Token
|
||||
modifiers []node.Node
|
||||
isReturnRef bool
|
||||
params []node.Node
|
||||
returnType node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewClassMethod(token token.Token, modifiers []node.Node, isReturnRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
|
||||
return ClassMethod{
|
||||
"ClassMethod",
|
||||
token,
|
||||
modifiers,
|
||||
isReturnRef,
|
||||
params,
|
||||
returnType,
|
||||
stmts,
|
||||
}
|
||||
func (n ClassMethod) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n ClassMethod) Walk(v node.Visitor) {
|
||||
@@ -36,8 +41,10 @@ func (n ClassMethod) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
v.Scalar("isReturnRef", n.isReturnRef)
|
||||
if n.methodName != nil {
|
||||
vv := v.GetChildrenVisitor("methodName")
|
||||
n.methodName.Walk(vv)
|
||||
}
|
||||
|
||||
if n.modifiers != nil {
|
||||
vv := v.GetChildrenVisitor("modifiers")
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type ConstList struct {
|
||||
name string
|
||||
consts []node.Node
|
||||
}
|
||||
|
||||
func NewConstList(consts []node.Node) node.Node {
|
||||
return ConstList{
|
||||
"ConstList",
|
||||
consts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n ConstList) Name() string {
|
||||
return "ConstList"
|
||||
}
|
||||
|
||||
type ConstList struct {
|
||||
name string
|
||||
token token.Token
|
||||
consts []node.Node
|
||||
}
|
||||
|
||||
func NewConstList(token token.Token, consts []node.Node) node.Node {
|
||||
return ConstList{
|
||||
"ConstList",
|
||||
token,
|
||||
consts,
|
||||
}
|
||||
func (n ConstList) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n ConstList) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,25 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Constant struct {
|
||||
name string
|
||||
constantName node.Node
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewConstant(constantName node.Node, expr node.Node) node.Node {
|
||||
return Constant{
|
||||
"Constant",
|
||||
constantName,
|
||||
expr,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Constant) Name() string {
|
||||
return "Constant"
|
||||
}
|
||||
|
||||
type Constant struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewConstant(token token.Token, expr node.Node) node.Node {
|
||||
return Constant{
|
||||
"Constant",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n Constant) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Constant) Walk(v node.Visitor) {
|
||||
@@ -28,7 +31,10 @@ func (n Constant) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
if n.constantName != nil {
|
||||
vv := v.GetChildrenVisitor("constantName")
|
||||
n.constantName.Walk(vv)
|
||||
}
|
||||
|
||||
if n.expr != nil {
|
||||
vv := v.GetChildrenVisitor("expr")
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Continue struct {
|
||||
name string
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewContinue(expr node.Node) node.Node {
|
||||
return Continue{
|
||||
"Continue",
|
||||
expr,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Continue) Name() string {
|
||||
return "Continue"
|
||||
}
|
||||
|
||||
type Continue struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewContinue(token token.Token, expr node.Node) node.Node {
|
||||
return Continue{
|
||||
"Continue",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n Continue) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Continue) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Declare struct {
|
||||
name string
|
||||
consts []node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewDeclare(consts []node.Node, stmt node.Node) node.Node {
|
||||
return Declare{
|
||||
"Declare",
|
||||
consts,
|
||||
stmt,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Declare) Name() string {
|
||||
return "Declare"
|
||||
}
|
||||
|
||||
type Declare struct {
|
||||
name string
|
||||
token token.Token
|
||||
consts []node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewDeclare(token token.Token, consts []node.Node, stmt node.Node) node.Node {
|
||||
return Declare{
|
||||
"Declare",
|
||||
token,
|
||||
consts,
|
||||
stmt,
|
||||
}
|
||||
func (n Declare) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Declare) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Default struct {
|
||||
name string
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewDefault(stmts []node.Node) node.Node {
|
||||
return Default{
|
||||
"Default",
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Default) Name() string {
|
||||
return "Default"
|
||||
}
|
||||
|
||||
type Default struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewDefault(token token.Token, stmts []node.Node) node.Node {
|
||||
return Default{
|
||||
"Default",
|
||||
token,
|
||||
stmts,
|
||||
}
|
||||
func (n Default) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Default) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Do struct {
|
||||
name string
|
||||
stmt node.Node
|
||||
cond node.Node
|
||||
}
|
||||
|
||||
func NewDo(stmt node.Node, cond node.Node) node.Node {
|
||||
return Do{
|
||||
"Do",
|
||||
stmt,
|
||||
cond,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Do) Name() string {
|
||||
return "Do"
|
||||
}
|
||||
|
||||
type Do struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmt node.Node
|
||||
cond node.Node
|
||||
}
|
||||
|
||||
func NewDo(token token.Token, stmt node.Node, cond node.Node) node.Node {
|
||||
return Do{
|
||||
"Do",
|
||||
token,
|
||||
stmt,
|
||||
cond,
|
||||
}
|
||||
func (n Do) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Do) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Echo struct {
|
||||
name string
|
||||
exprs []node.Node
|
||||
}
|
||||
|
||||
func NewEcho(exprs []node.Node) node.Node {
|
||||
return Echo{
|
||||
"Echo",
|
||||
exprs,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Echo) Name() string {
|
||||
return "Echo"
|
||||
}
|
||||
|
||||
type Echo struct {
|
||||
name string
|
||||
token token.Token
|
||||
exprs []node.Node
|
||||
}
|
||||
|
||||
func NewEcho(token token.Token, exprs []node.Node) node.Node {
|
||||
return Echo{
|
||||
"Echo",
|
||||
token,
|
||||
exprs,
|
||||
}
|
||||
func (n Echo) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Echo) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Else struct {
|
||||
name string
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewElse(stmt node.Node) node.Node {
|
||||
return Else{
|
||||
"Else",
|
||||
stmt,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Else) Name() string {
|
||||
return "Else"
|
||||
}
|
||||
|
||||
type Else struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewElse(token token.Token, stmt node.Node) node.Node {
|
||||
return Else{
|
||||
"Else",
|
||||
token,
|
||||
stmt,
|
||||
}
|
||||
func (n Else) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Else) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type ElseIf struct {
|
||||
name string
|
||||
cond node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewElseIf(cond node.Node, stmt node.Node) node.Node {
|
||||
return ElseIf{
|
||||
"ElseIf",
|
||||
cond,
|
||||
stmt,
|
||||
}
|
||||
}
|
||||
|
||||
func (n ElseIf) Name() string {
|
||||
return "ElseIf"
|
||||
}
|
||||
|
||||
type ElseIf struct {
|
||||
name string
|
||||
token token.Token
|
||||
cond node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewElseIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
|
||||
return ElseIf{
|
||||
"ElseIf",
|
||||
token,
|
||||
cond,
|
||||
stmt,
|
||||
}
|
||||
func (n ElseIf) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n ElseIf) Walk(v node.Visitor) {
|
||||
|
||||
@@ -4,10 +4,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
func (n Expression) Name() string {
|
||||
return "Expression"
|
||||
}
|
||||
|
||||
type Expression struct {
|
||||
name string
|
||||
expr node.Node
|
||||
@@ -20,6 +16,14 @@ func NewExpression(expr node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n Expression) Name() string {
|
||||
return "Expression"
|
||||
}
|
||||
|
||||
func (n Expression) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Expression) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Finally struct {
|
||||
name string
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewFinally(stmts []node.Node) node.Node {
|
||||
return Finally{
|
||||
"Finally",
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Finally) Name() string {
|
||||
return "Finally"
|
||||
}
|
||||
|
||||
type Finally struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewFinally(token token.Token, stmts []node.Node) node.Node {
|
||||
return Finally{
|
||||
"Finally",
|
||||
token,
|
||||
stmts,
|
||||
}
|
||||
func (n Finally) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Finally) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,26 +2,19 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n For) Name() string {
|
||||
return "For"
|
||||
}
|
||||
|
||||
type For struct {
|
||||
name string
|
||||
token token.Token
|
||||
init []node.Node
|
||||
cond []node.Node
|
||||
loop []node.Node
|
||||
stmt node.Node
|
||||
name string
|
||||
init []node.Node
|
||||
cond []node.Node
|
||||
loop []node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewFor(token token.Token, init []node.Node, cond []node.Node, loop []node.Node, stmt node.Node) node.Node {
|
||||
func NewFor(init []node.Node, cond []node.Node, loop []node.Node, stmt node.Node) node.Node {
|
||||
return For{
|
||||
"For",
|
||||
token,
|
||||
init,
|
||||
cond,
|
||||
loop,
|
||||
@@ -29,6 +22,14 @@ func NewFor(token token.Token, init []node.Node, cond []node.Node, loop []node.N
|
||||
}
|
||||
}
|
||||
|
||||
func (n For) Name() string {
|
||||
return "For"
|
||||
}
|
||||
|
||||
func (n For) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n For) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -2,33 +2,36 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Foreach struct {
|
||||
name string
|
||||
attributes map[string]interface{}
|
||||
expr node.Node
|
||||
key node.Node
|
||||
variable node.Node
|
||||
stmt node.Node
|
||||
}
|
||||
|
||||
func NewForeach(expr node.Node, key node.Node, variable node.Node, stmt node.Node, byRef bool) node.Node {
|
||||
return Foreach{
|
||||
"Foreach",
|
||||
map[string]interface{}{
|
||||
"byRef": byRef,
|
||||
},
|
||||
expr,
|
||||
key,
|
||||
variable,
|
||||
stmt,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Foreach) Name() string {
|
||||
return "Foreach"
|
||||
}
|
||||
|
||||
type Foreach struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
key node.Node
|
||||
variable node.Node
|
||||
stmt node.Node
|
||||
byRef bool
|
||||
}
|
||||
|
||||
func NewForeach(token token.Token, expr node.Node, key node.Node, variable node.Node, stmt node.Node, byRef bool) node.Node {
|
||||
return Foreach{
|
||||
"Foreach",
|
||||
token,
|
||||
expr,
|
||||
key,
|
||||
variable,
|
||||
stmt,
|
||||
byRef,
|
||||
}
|
||||
func (n Foreach) Attributes() map[string]interface{} {
|
||||
return n.attributes
|
||||
}
|
||||
|
||||
func (n Foreach) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,31 +2,36 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Function struct {
|
||||
name string
|
||||
attributes map[string]interface{}
|
||||
functionName node.Node
|
||||
params []node.Node
|
||||
returnType node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewFunction(functionName node.Node, returnsRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
|
||||
return Function{
|
||||
"Function",
|
||||
map[string]interface{}{
|
||||
"returnsRef": returnsRef,
|
||||
},
|
||||
functionName,
|
||||
params,
|
||||
returnType,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Function) Name() string {
|
||||
return "Function"
|
||||
}
|
||||
|
||||
type Function struct {
|
||||
name string
|
||||
token token.Token
|
||||
isReturnRef bool
|
||||
params []node.Node
|
||||
returnType node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewFunction(token token.Token, isReturnRef bool, params []node.Node, returnType node.Node, stmts []node.Node) node.Node {
|
||||
return Function{
|
||||
"Function",
|
||||
token,
|
||||
isReturnRef,
|
||||
params,
|
||||
returnType,
|
||||
stmts,
|
||||
}
|
||||
func (n Function) Attributes() map[string]interface{} {
|
||||
return n.attributes
|
||||
}
|
||||
|
||||
func (n Function) Walk(v node.Visitor) {
|
||||
@@ -34,8 +39,10 @@ func (n Function) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
v.Scalar("isReturnRef", n.isReturnRef)
|
||||
if n.functionName != nil {
|
||||
vv := v.GetChildrenVisitor("functionName")
|
||||
n.functionName.Walk(vv)
|
||||
}
|
||||
|
||||
if n.params != nil {
|
||||
vv := v.GetChildrenVisitor("params")
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Global struct {
|
||||
name string
|
||||
vars []node.Node
|
||||
}
|
||||
|
||||
func NewGlobal(vars []node.Node) node.Node {
|
||||
return Global{
|
||||
"Global",
|
||||
vars,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Global) Name() string {
|
||||
return "Global"
|
||||
}
|
||||
|
||||
type Global struct {
|
||||
name string
|
||||
token token.Token
|
||||
vars []node.Node
|
||||
}
|
||||
|
||||
func NewGlobal(token token.Token, vars []node.Node) node.Node {
|
||||
return Global{
|
||||
"Global",
|
||||
token,
|
||||
vars,
|
||||
}
|
||||
func (n Global) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Global) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,26 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Goto struct {
|
||||
name string
|
||||
label node.Node
|
||||
}
|
||||
|
||||
func NewGoto(label node.Node) node.Node {
|
||||
return Goto{
|
||||
"Goto",
|
||||
label,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Goto) Name() string {
|
||||
return "Goto"
|
||||
}
|
||||
|
||||
type Goto struct {
|
||||
name string
|
||||
token token.Token
|
||||
label token.Token
|
||||
}
|
||||
|
||||
// todl label must be identifier
|
||||
func NewGoto(token token.Token, label token.Token) node.Node {
|
||||
return Goto{
|
||||
"Goto",
|
||||
token,
|
||||
label,
|
||||
}
|
||||
func (n Goto) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Goto) Walk(v node.Visitor) {
|
||||
@@ -29,7 +29,10 @@ func (n Goto) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("label", n.label.Value)
|
||||
if n.label != nil {
|
||||
vv := v.GetChildrenVisitor("label")
|
||||
n.label.Walk(vv)
|
||||
}
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -2,35 +2,30 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n GroupUse) Name() string {
|
||||
return "GroupUse"
|
||||
}
|
||||
|
||||
type GroupUse struct {
|
||||
name string
|
||||
token token.TokenInterface
|
||||
useType node.Node
|
||||
prefix node.Node
|
||||
useList []node.Node
|
||||
}
|
||||
|
||||
//TODO: stmts myst be []node.Node
|
||||
func NewGroupUse(token token.TokenInterface, useType node.Node, prefix node.Node, useList []node.Node) node.Node {
|
||||
func NewGroupUse(useType node.Node, prefix node.Node, useList []node.Node) node.Node {
|
||||
return GroupUse{
|
||||
"GroupUse",
|
||||
token,
|
||||
useType,
|
||||
prefix,
|
||||
useList,
|
||||
}
|
||||
}
|
||||
|
||||
func (n GroupUse) SetToken(token token.TokenInterface) node.Node {
|
||||
n.token = token
|
||||
return n
|
||||
func (n GroupUse) Name() string {
|
||||
return "GroupUse"
|
||||
}
|
||||
|
||||
func (n GroupUse) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n GroupUse) SetUseType(useType node.Node) node.Node {
|
||||
|
||||
@@ -2,23 +2,24 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type HaltCompiler struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func NewHaltCompiler() node.Node {
|
||||
return HaltCompiler{
|
||||
"HaltCompiler",
|
||||
}
|
||||
}
|
||||
|
||||
func (n HaltCompiler) Name() string {
|
||||
return "HaltCompiler"
|
||||
}
|
||||
|
||||
type HaltCompiler struct {
|
||||
name string
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func NewHaltCompiler(token token.Token) node.Node {
|
||||
return HaltCompiler{
|
||||
"HaltCompiler",
|
||||
token,
|
||||
}
|
||||
func (n HaltCompiler) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n HaltCompiler) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,26 +2,19 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n If) Name() string {
|
||||
return "If"
|
||||
}
|
||||
|
||||
type If struct {
|
||||
name string
|
||||
token token.Token
|
||||
cond node.Node
|
||||
stmt node.Node
|
||||
elseIf []node.Node
|
||||
_else node.Node
|
||||
}
|
||||
|
||||
func NewIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
|
||||
func NewIf(cond node.Node, stmt node.Node) node.Node {
|
||||
return If{
|
||||
"If",
|
||||
token,
|
||||
cond,
|
||||
stmt,
|
||||
nil,
|
||||
@@ -29,6 +22,14 @@ func NewIf(token token.Token, cond node.Node, stmt node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n If) Name() string {
|
||||
return "If"
|
||||
}
|
||||
|
||||
func (n If) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n If) AddElseIf(elseIf node.Node) node.Node {
|
||||
if n.elseIf == nil {
|
||||
n.elseIf = make([]node.Node, 0)
|
||||
|
||||
@@ -2,23 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type InlineHtml struct {
|
||||
name string
|
||||
attributes map[string]interface{}
|
||||
}
|
||||
|
||||
func NewInlineHtml(value string) node.Node {
|
||||
return InlineHtml{
|
||||
"InlineHtml",
|
||||
map[string]interface{}{
|
||||
"value": value,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (n InlineHtml) Name() string {
|
||||
return "InlineHtml"
|
||||
}
|
||||
|
||||
type InlineHtml struct {
|
||||
name string
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func NewInlineHtml(token token.Token) node.Node {
|
||||
return InlineHtml{
|
||||
"InlineHtml",
|
||||
token,
|
||||
}
|
||||
func (n InlineHtml) Attributes() map[string]interface{} {
|
||||
return n.attributes
|
||||
}
|
||||
|
||||
func (n InlineHtml) Walk(v node.Visitor) {
|
||||
@@ -26,7 +31,5 @@ func (n InlineHtml) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -2,29 +2,30 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Interface struct {
|
||||
name string
|
||||
interfaceName node.Node
|
||||
extends []node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewInterface(interfaceName node.Node, extends []node.Node, stmts []node.Node) node.Node {
|
||||
return Interface{
|
||||
"Interface",
|
||||
interfaceName,
|
||||
extends,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Interface) Name() string {
|
||||
return "Interface"
|
||||
}
|
||||
|
||||
type Interface struct {
|
||||
name string
|
||||
token token.Token
|
||||
interfaceName token.Token
|
||||
extends []node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewInterface(token token.Token, name token.Token, extends []node.Node, stmts []node.Node) node.Node {
|
||||
return Interface{
|
||||
"Interface",
|
||||
token,
|
||||
name,
|
||||
extends,
|
||||
stmts,
|
||||
}
|
||||
func (n Interface) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Interface) Walk(v node.Visitor) {
|
||||
@@ -32,7 +33,10 @@ func (n Interface) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.interfaceName.Value)
|
||||
if n.interfaceName != nil {
|
||||
vv := v.GetChildrenVisitor("interfaceName")
|
||||
n.interfaceName.Walk(vv)
|
||||
}
|
||||
|
||||
if n.extends != nil {
|
||||
vv := v.GetChildrenVisitor("extends")
|
||||
|
||||
@@ -2,23 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Label struct {
|
||||
name string
|
||||
labelName node.Node
|
||||
}
|
||||
|
||||
func NewLabel(labelName node.Node) node.Node {
|
||||
return Label{
|
||||
"Label",
|
||||
labelName,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Label) Name() string {
|
||||
return "Label"
|
||||
}
|
||||
|
||||
type Label struct {
|
||||
name string
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func NewLabel(token token.Token) node.Node {
|
||||
return Label{
|
||||
"Label",
|
||||
token,
|
||||
}
|
||||
func (n Label) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Label) Walk(v node.Visitor) {
|
||||
@@ -26,7 +29,10 @@ func (n Label) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
if n.labelName != nil {
|
||||
vv := v.GetChildrenVisitor("labelName")
|
||||
n.labelName.Walk(vv)
|
||||
}
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Namespace struct {
|
||||
name string
|
||||
namespaceName node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewNamespace(namespaceName node.Node, stmts []node.Node) node.Node {
|
||||
return Namespace{
|
||||
"Namespace",
|
||||
namespaceName,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Namespace) Name() string {
|
||||
return "Namespace"
|
||||
}
|
||||
|
||||
type Namespace struct {
|
||||
name string
|
||||
token token.Token
|
||||
namespaceName node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewNamespace(token token.Token, namespaceName node.Node, stmts []node.Node) node.Node {
|
||||
return Namespace{
|
||||
"Namespace",
|
||||
token,
|
||||
namespaceName,
|
||||
stmts,
|
||||
}
|
||||
func (n Namespace) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Namespace) Walk(v node.Visitor) {
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
package stmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Nop struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func NewNop() node.Node {
|
||||
return Nop{
|
||||
"Nop",
|
||||
}
|
||||
}
|
||||
|
||||
func (n Nop) Name() string {
|
||||
return "Nop"
|
||||
}
|
||||
|
||||
type Nop struct {
|
||||
name string
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func NewNop(token token.Token) node.Node {
|
||||
return Nop{
|
||||
"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)
|
||||
func (n Nop) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Nop) Walk(v node.Visitor) {
|
||||
@@ -33,7 +27,5 @@ func (n Nop) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -2,25 +2,27 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Property struct {
|
||||
name string
|
||||
variable node.Node
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewProperty(variable node.Node, expr node.Node) node.Node {
|
||||
return Property{
|
||||
"Property",
|
||||
variable,
|
||||
expr,
|
||||
}
|
||||
}
|
||||
func (n Property) Name() string {
|
||||
return "Property"
|
||||
}
|
||||
|
||||
type Property struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewProperty(token token.Token, expr node.Node) node.Node {
|
||||
return Property{
|
||||
"Property",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n Property) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Property) Walk(v node.Visitor) {
|
||||
@@ -28,7 +30,10 @@ func (n Property) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
if n.variable != nil {
|
||||
vv := v.GetChildrenVisitor("variable")
|
||||
n.variable.Walk(vv)
|
||||
}
|
||||
|
||||
if n.expr != nil {
|
||||
vv := v.GetChildrenVisitor("expr")
|
||||
|
||||
@@ -4,10 +4,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
func (n PropertyList) Name() string {
|
||||
return "PropertyList"
|
||||
}
|
||||
|
||||
type PropertyList struct {
|
||||
name string
|
||||
modifiers []node.Node
|
||||
@@ -22,6 +18,14 @@ func NewPropertyList(modifiers []node.Node, properties []node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n PropertyList) Name() string {
|
||||
return "PropertyList"
|
||||
}
|
||||
|
||||
func (n PropertyList) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n PropertyList) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Return struct {
|
||||
name string
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewReturn(expr node.Node) node.Node {
|
||||
return Return{
|
||||
"Return",
|
||||
expr,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Return) Name() string {
|
||||
return "Return"
|
||||
}
|
||||
|
||||
type Return struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewReturn(token token.Token, expr node.Node) node.Node {
|
||||
return Return{
|
||||
"Return",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n Return) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Return) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Static struct {
|
||||
name string
|
||||
vars []node.Node
|
||||
}
|
||||
|
||||
func NewStatic(vars []node.Node) node.Node {
|
||||
return Static{
|
||||
"Static",
|
||||
vars,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Static) Name() string {
|
||||
return "Static"
|
||||
}
|
||||
|
||||
type Static struct {
|
||||
name string
|
||||
token token.Token
|
||||
vars []node.Node
|
||||
}
|
||||
|
||||
func NewStatic(token token.Token, vars []node.Node) node.Node {
|
||||
return Static{
|
||||
"Static",
|
||||
token,
|
||||
vars,
|
||||
}
|
||||
func (n Static) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Static) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,25 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type StaticVar struct {
|
||||
name string
|
||||
variable node.Node
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewStaticVar(variable node.Node, expr node.Node) node.Node {
|
||||
return StaticVar{
|
||||
"StaticVar",
|
||||
variable,
|
||||
expr,
|
||||
}
|
||||
}
|
||||
|
||||
func (n StaticVar) Name() string {
|
||||
return "StaticVar"
|
||||
}
|
||||
|
||||
type StaticVar struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewStaticVar(token token.Token, expr node.Node) node.Node {
|
||||
return StaticVar{
|
||||
"StaticVar",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n StaticVar) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n StaticVar) Walk(v node.Visitor) {
|
||||
@@ -28,6 +31,11 @@ func (n StaticVar) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
if n.variable != nil {
|
||||
vv := v.GetChildrenVisitor("variable")
|
||||
n.variable.Walk(vv)
|
||||
}
|
||||
|
||||
if n.expr != nil {
|
||||
vv := v.GetChildrenVisitor("expr")
|
||||
n.expr.Walk(vv)
|
||||
|
||||
@@ -4,10 +4,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
func (n StmtList) Name() string {
|
||||
return "StmtList"
|
||||
}
|
||||
|
||||
type StmtList struct {
|
||||
name string
|
||||
stmts []node.Node
|
||||
@@ -20,6 +16,14 @@ func NewStmtList(stmts []node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n StmtList) Name() string {
|
||||
return "StmtList"
|
||||
}
|
||||
|
||||
func (n StmtList) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n StmtList) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -5,6 +5,10 @@ import (
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n Switch) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Switch) Name() string {
|
||||
return "Switch"
|
||||
}
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Throw struct {
|
||||
name string
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewThrow(expr node.Node) node.Node {
|
||||
return Throw{
|
||||
"Throw",
|
||||
expr,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Throw) Name() string {
|
||||
return "Throw"
|
||||
}
|
||||
|
||||
type Throw struct {
|
||||
name string
|
||||
token token.Token
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewThrow(token token.Token, expr node.Node) node.Node {
|
||||
return Throw{
|
||||
"Throw",
|
||||
token,
|
||||
expr,
|
||||
}
|
||||
func (n Throw) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Throw) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,26 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Trait struct {
|
||||
name string
|
||||
traitName node.Node
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
func NewTrait(traitName node.Node, stmts []node.Node) node.Node {
|
||||
return Trait{
|
||||
"Trait",
|
||||
traitName,
|
||||
stmts,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Trait) Name() string {
|
||||
return "Trait"
|
||||
}
|
||||
|
||||
type Trait struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmts []node.Node
|
||||
}
|
||||
|
||||
//TODO: stmts myst be []node.Node
|
||||
func NewTrait(token token.Token, stmts []node.Node) node.Node {
|
||||
return Trait{
|
||||
"Trait",
|
||||
token,
|
||||
stmts,
|
||||
}
|
||||
func (n Trait) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Trait) Walk(v node.Visitor) {
|
||||
@@ -29,7 +31,10 @@ func (n Trait) Walk(v node.Visitor) {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("token", n.token.Value)
|
||||
if n.traitName != nil {
|
||||
vv := v.GetChildrenVisitor("traitName")
|
||||
n.traitName.Walk(vv)
|
||||
}
|
||||
|
||||
if n.stmts != nil {
|
||||
vv := v.GetChildrenVisitor("stmts")
|
||||
|
||||
@@ -2,21 +2,15 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n TraitMethodRef) Name() string {
|
||||
return "TraitMethodRef"
|
||||
}
|
||||
|
||||
type TraitMethodRef struct {
|
||||
name string
|
||||
trait node.Node
|
||||
method token.Token
|
||||
method node.Node
|
||||
}
|
||||
|
||||
// TODO: method must be identifier
|
||||
func NewTraitMethodRef(trait node.Node, method token.Token) node.Node {
|
||||
func NewTraitMethodRef(trait node.Node, method node.Node) node.Node {
|
||||
return TraitMethodRef{
|
||||
"TraitMethodRef",
|
||||
trait,
|
||||
@@ -24,17 +18,28 @@ func NewTraitMethodRef(trait node.Node, method token.Token) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n TraitMethodRef) Name() string {
|
||||
return "TraitMethodRef"
|
||||
}
|
||||
|
||||
func (n TraitMethodRef) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n TraitMethodRef) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
}
|
||||
|
||||
v.Scalar("method", n.method.Value)
|
||||
|
||||
if n.trait != nil {
|
||||
vv := v.GetChildrenVisitor("trait")
|
||||
n.trait.Walk(vv)
|
||||
}
|
||||
|
||||
if n.method != nil {
|
||||
vv := v.GetChildrenVisitor("method")
|
||||
n.method.Walk(vv)
|
||||
}
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -2,28 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type TraitUse struct {
|
||||
name string
|
||||
traits []node.Node
|
||||
adaptations []node.Node
|
||||
}
|
||||
|
||||
func NewTraitUse(traits []node.Node, adaptations []node.Node) node.Node {
|
||||
return TraitUse{
|
||||
"TraitUse",
|
||||
traits,
|
||||
adaptations,
|
||||
}
|
||||
}
|
||||
|
||||
func (n TraitUse) Name() string {
|
||||
return "TraitUse"
|
||||
}
|
||||
|
||||
type TraitUse struct {
|
||||
name string
|
||||
token token.Token
|
||||
traits []node.Node
|
||||
adaptations []node.Node
|
||||
}
|
||||
|
||||
//TODO: traits myst be []node.Node
|
||||
func NewTraitUse(token token.Token, traits []node.Node, adaptations []node.Node) node.Node {
|
||||
return TraitUse{
|
||||
"TraitUse",
|
||||
token,
|
||||
traits,
|
||||
adaptations,
|
||||
}
|
||||
func (n TraitUse) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n TraitUse) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,21 +2,16 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n TraitUseAlias) Name() string {
|
||||
return "TraitUseAlias"
|
||||
}
|
||||
|
||||
type TraitUseAlias struct {
|
||||
name string
|
||||
ref node.Node
|
||||
modifier node.Node
|
||||
alias token.TokenInterface
|
||||
alias node.Node
|
||||
}
|
||||
|
||||
func NewTraitUseAlias(ref node.Node, modifier node.Node, alias token.TokenInterface) node.Node {
|
||||
func NewTraitUseAlias(ref node.Node, modifier node.Node, alias node.Node) node.Node {
|
||||
return TraitUseAlias{
|
||||
"TraitUseAlias",
|
||||
ref,
|
||||
@@ -25,6 +20,14 @@ func NewTraitUseAlias(ref node.Node, modifier node.Node, alias token.TokenInterf
|
||||
}
|
||||
}
|
||||
|
||||
func (n TraitUseAlias) Name() string {
|
||||
return "TraitUseAlias"
|
||||
}
|
||||
|
||||
func (n TraitUseAlias) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n TraitUseAlias) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
@@ -40,5 +43,10 @@ func (n TraitUseAlias) Walk(v node.Visitor) {
|
||||
n.modifier.Walk(vv)
|
||||
}
|
||||
|
||||
if n.alias != nil {
|
||||
vv := v.GetChildrenVisitor("alias")
|
||||
n.alias.Walk(vv)
|
||||
}
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
func (n TraitUsePrecedence) Name() string {
|
||||
return "TraitUsePrecedence"
|
||||
}
|
||||
|
||||
type TraitUsePrecedence struct {
|
||||
name string
|
||||
ref node.Node
|
||||
@@ -22,6 +18,14 @@ func NewTraitUsePrecedence(ref node.Node, insteadof node.Node) node.Node {
|
||||
}
|
||||
}
|
||||
|
||||
func (n TraitUsePrecedence) Name() string {
|
||||
return "TraitUsePrecedence"
|
||||
}
|
||||
|
||||
func (n TraitUsePrecedence) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n TraitUsePrecedence) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -2,31 +2,32 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
func (n Try) Name() string {
|
||||
return "Try"
|
||||
}
|
||||
|
||||
type Try struct {
|
||||
name string
|
||||
token token.Token
|
||||
stmts []node.Node
|
||||
catches []node.Node
|
||||
finally node.Node
|
||||
}
|
||||
|
||||
func NewTry(token token.Token, stmts []node.Node, catches []node.Node, finally node.Node) node.Node {
|
||||
func NewTry(stmts []node.Node, catches []node.Node, finally node.Node) node.Node {
|
||||
return Try{
|
||||
"Try",
|
||||
token,
|
||||
stmts,
|
||||
catches,
|
||||
finally,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Try) Name() string {
|
||||
return "Try"
|
||||
}
|
||||
|
||||
func (n Try) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Try) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
@@ -2,25 +2,26 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Unset struct {
|
||||
name string
|
||||
vars []node.Node
|
||||
}
|
||||
|
||||
func NewUnset(vars []node.Node) node.Node {
|
||||
return Unset{
|
||||
"Unset",
|
||||
vars,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Unset) Name() string {
|
||||
return "Unset"
|
||||
}
|
||||
|
||||
type Unset struct {
|
||||
name string
|
||||
token token.Token
|
||||
vars []node.Node
|
||||
}
|
||||
|
||||
func NewUnset(token token.Token, vars []node.Node) node.Node {
|
||||
return Unset{
|
||||
"Unset",
|
||||
token,
|
||||
vars,
|
||||
}
|
||||
func (n Unset) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Unset) Walk(v node.Visitor) {
|
||||
|
||||
@@ -2,17 +2,16 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Use struct {
|
||||
name string
|
||||
useType node.Node
|
||||
use node.Node
|
||||
alias token.TokenInterface
|
||||
alias node.Node
|
||||
}
|
||||
|
||||
func NewUse(useType node.Node, use node.Node, alias token.TokenInterface) node.Node {
|
||||
func NewUse(useType node.Node, use node.Node, alias node.Node) node.Node {
|
||||
return Use{
|
||||
"Use",
|
||||
useType,
|
||||
@@ -25,7 +24,11 @@ func (n Use) Name() string {
|
||||
return "Use"
|
||||
}
|
||||
|
||||
func (n Use) SetType(useType node.Node) node.Node {
|
||||
func (n Use) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Use) SetUseType(useType node.Node) node.Node {
|
||||
n.useType = useType
|
||||
return n
|
||||
}
|
||||
@@ -45,5 +48,10 @@ func (n Use) Walk(v node.Visitor) {
|
||||
n.use.Walk(vv)
|
||||
}
|
||||
|
||||
if n.alias != nil {
|
||||
vv := v.GetChildrenVisitor("alias")
|
||||
n.alias.Walk(vv)
|
||||
}
|
||||
|
||||
v.LeaveNode(n)
|
||||
}
|
||||
|
||||
@@ -2,27 +2,28 @@ package stmt
|
||||
|
||||
import (
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type UseList struct {
|
||||
name string
|
||||
useType node.Node
|
||||
uses []node.Node
|
||||
}
|
||||
|
||||
func NewUseList(useType node.Node, uses []node.Node) node.Node {
|
||||
return UseList{
|
||||
"UseList",
|
||||
useType,
|
||||
uses,
|
||||
}
|
||||
}
|
||||
|
||||
func (n UseList) Name() string {
|
||||
return "UseList"
|
||||
}
|
||||
|
||||
type UseList struct {
|
||||
name string
|
||||
token token.Token
|
||||
useType node.Node
|
||||
uses []node.Node
|
||||
}
|
||||
|
||||
func NewUseList(token token.Token, useType node.Node, uses []node.Node) node.Node {
|
||||
return UseList{
|
||||
"UseList",
|
||||
token,
|
||||
useType,
|
||||
uses,
|
||||
}
|
||||
func (n UseList) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n UseList) Walk(v node.Visitor) {
|
||||
|
||||
@@ -25,6 +25,10 @@ func (n While) Name() string {
|
||||
return "While"
|
||||
}
|
||||
|
||||
func (n While) Attributes() map[string]interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n While) Walk(v node.Visitor) {
|
||||
if v.EnterNode(n) == false {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user