expr assign binary and cast nodes

This commit is contained in:
z7zmey
2017-12-12 23:26:00 +02:00
parent ddf72d4b4f
commit d7a593ef3b
52 changed files with 1584 additions and 580 deletions

View File

@@ -0,0 +1,30 @@
package assign_op
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type Assign struct {
AssignOp
byRef bool
}
func NewAssign(variable node.Node, expression node.Node, byRef bool) node.Node {
return Assign{
AssignOp{
node.SimpleNode{Name: "AssignAssign", Attributes: make(map[string]string)},
variable,
expression,
},
byRef,
}
}
func (n Assign) Print(out io.Writer, indent string) {
n.AssignOp.Print(out, indent)
fmt.Fprintf(out, "\n%vbyRef: %t", indent+" ", n.byRef)
}

View File

@@ -0,0 +1,36 @@
package assign_op
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type AssignOp struct {
node.SimpleNode
variable node.Node
expression node.Node
}
func NewAssignOp(variable node.Node, expression node.Node) node.Node {
return AssignOp{
node.SimpleNode{Name: "AssignOp", Attributes: make(map[string]string)},
variable,
expression,
}
}
func (n AssignOp) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.variable != nil {
fmt.Fprintf(out, "\n%vvariable:", indent+" ")
n.variable.Print(out, indent+" ")
}
if n.expression != nil {
fmt.Fprintf(out, "\n%vexpression:", indent+" ")
n.expression.Print(out, indent+" ")
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type BitwiseAnd struct {
AssignOp
}
func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node {
return BitwiseAnd{
AssignOp{
node.SimpleNode{Name: "AssignBitwiseAnd", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type BitwiseOr struct {
AssignOp
}
func NewBitwiseOr(variable node.Node, expression node.Node) node.Node {
return BitwiseOr{
AssignOp{
node.SimpleNode{Name: "AssignBitwiseOr", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type BitwiseXor struct {
AssignOp
}
func NewBitwiseXor(variable node.Node, expression node.Node) node.Node {
return BitwiseXor{
AssignOp{
node.SimpleNode{Name: "AssignBitwiseXor", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Concat struct {
AssignOp
}
func NewConcat(variable node.Node, expression node.Node) node.Node {
return Concat{
AssignOp{
node.SimpleNode{Name: "AssignConcat", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Div struct {
AssignOp
}
func NewDiv(variable node.Node, expression node.Node) node.Node {
return Div{
AssignOp{
node.SimpleNode{Name: "AssignDiv", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Minus struct {
AssignOp
}
func NewMinus(variable node.Node, expression node.Node) node.Node {
return Minus{
AssignOp{
node.SimpleNode{Name: "AssignMinus", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Mod struct {
AssignOp
}
func NewMod(variable node.Node, expression node.Node) node.Node {
return Mod{
AssignOp{
node.SimpleNode{Name: "AssignMod", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Mul struct {
AssignOp
}
func NewMul(variable node.Node, expression node.Node) node.Node {
return Mul{
AssignOp{
node.SimpleNode{Name: "AssignMul", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Plus struct {
AssignOp
}
func NewPlus(variable node.Node, expression node.Node) node.Node {
return Plus{
AssignOp{
node.SimpleNode{Name: "AssignPlus", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type Pow struct {
AssignOp
}
func NewPow(variable node.Node, expression node.Node) node.Node {
return Pow{
AssignOp{
node.SimpleNode{Name: "AssignPow", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type ShiftLeft struct {
AssignOp
}
func NewShiftLeft(variable node.Node, expression node.Node) node.Node {
return ShiftLeft{
AssignOp{
node.SimpleNode{Name: "AssignShiftLeft", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package assign_op
import (
"github.com/z7zmey/php-parser/node"
)
type ShiftRight struct {
AssignOp
}
func NewShiftRight(variable node.Node, expression node.Node) node.Node {
return ShiftRight{
AssignOp{
node.SimpleNode{Name: "AssignShiftRight", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,36 @@
package binary_op
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type BinaryOp struct {
node.SimpleNode
left node.Node
right node.Node
}
func NewBinaryOp(left node.Node, right node.Node) node.Node {
return BinaryOp{
node.SimpleNode{Name: "BinaryOp", Attributes: make(map[string]string)},
left,
right,
}
}
func (n BinaryOp) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.left != nil {
fmt.Fprintf(out, "\n%vleft:", indent+" ")
n.left.Print(out, indent+" ")
}
if n.right != nil {
fmt.Fprintf(out, "\n%vright:", indent+" ")
n.right.Print(out, indent+" ")
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type BitwiseAnd struct {
BinaryOp
}
func NewBitwiseAnd(variable node.Node, expression node.Node) node.Node {
return BitwiseAnd{
BinaryOp{
node.SimpleNode{Name: "BinaryBitwiseAnd", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type BitwiseOr struct {
BinaryOp
}
func NewBitwiseOr(variable node.Node, expression node.Node) node.Node {
return BitwiseOr{
BinaryOp{
node.SimpleNode{Name: "BinaryBitwiseOr", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type BitwiseXor struct {
BinaryOp
}
func NewBitwiseXor(variable node.Node, expression node.Node) node.Node {
return BitwiseXor{
BinaryOp{
node.SimpleNode{Name: "BinaryBitwiseXor", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type BooleanAnd struct {
BinaryOp
}
func NewBooleanAnd(variable node.Node, expression node.Node) node.Node {
return BooleanAnd{
BinaryOp{
node.SimpleNode{Name: "BinaryBooleanAnd", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type BooleanOr struct {
BinaryOp
}
func NewBooleanOr(variable node.Node, expression node.Node) node.Node {
return BooleanOr{
BinaryOp{
node.SimpleNode{Name: "BinaryBooleanOr", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Coalesce struct {
BinaryOp
}
func NewCoalesce(variable node.Node, expression node.Node) node.Node {
return Coalesce{
BinaryOp{
node.SimpleNode{Name: "BinaryCoalesce", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Concat struct {
BinaryOp
}
func NewConcat(variable node.Node, expression node.Node) node.Node {
return Concat{
BinaryOp{
node.SimpleNode{Name: "BinaryConcat", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Div struct {
BinaryOp
}
func NewDiv(variable node.Node, expression node.Node) node.Node {
return Div{
BinaryOp{
node.SimpleNode{Name: "BinaryDiv", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Equal struct {
BinaryOp
}
func NewEqual(variable node.Node, expression node.Node) node.Node {
return Equal{
BinaryOp{
node.SimpleNode{Name: "BinaryEqual", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Greater struct {
BinaryOp
}
func NewGreater(variable node.Node, expression node.Node) node.Node {
return Greater{
BinaryOp{
node.SimpleNode{Name: "BinaryGreater", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type GreaterOrEqual struct {
BinaryOp
}
func NewGreaterOrEqual(variable node.Node, expression node.Node) node.Node {
return GreaterOrEqual{
BinaryOp{
node.SimpleNode{Name: "BinaryGreaterOrEqual", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Identical struct {
BinaryOp
}
func NewIdentical(variable node.Node, expression node.Node) node.Node {
return Identical{
BinaryOp{
node.SimpleNode{Name: "BinaryIdentical", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type LogicalAnd struct {
BinaryOp
}
func NewLogicalAnd(variable node.Node, expression node.Node) node.Node {
return LogicalAnd{
BinaryOp{
node.SimpleNode{Name: "BinaryLogicalAnd", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type LogicalOr struct {
BinaryOp
}
func NewLogicalOr(variable node.Node, expression node.Node) node.Node {
return LogicalOr{
BinaryOp{
node.SimpleNode{Name: "BinaryLogicalOr", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type LogicalXor struct {
BinaryOp
}
func NewLogicalXor(variable node.Node, expression node.Node) node.Node {
return LogicalXor{
BinaryOp{
node.SimpleNode{Name: "BinaryLogicalXor", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Minus struct {
BinaryOp
}
func NewMinus(variable node.Node, expression node.Node) node.Node {
return Minus{
BinaryOp{
node.SimpleNode{Name: "BinaryMinus", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Mod struct {
BinaryOp
}
func NewMod(variable node.Node, expression node.Node) node.Node {
return Mod{
BinaryOp{
node.SimpleNode{Name: "BinaryMod", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Mul struct {
BinaryOp
}
func NewMul(variable node.Node, expression node.Node) node.Node {
return Mul{
BinaryOp{
node.SimpleNode{Name: "BinaryMul", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type NotEqual struct {
BinaryOp
}
func NewNotEqual(variable node.Node, expression node.Node) node.Node {
return NotEqual{
BinaryOp{
node.SimpleNode{Name: "BinaryNotEqual", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type NotIdentical struct {
BinaryOp
}
func NewNotIdentical(variable node.Node, expression node.Node) node.Node {
return NotIdentical{
BinaryOp{
node.SimpleNode{Name: "BinaryNotIdentical", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Plus struct {
BinaryOp
}
func NewPlus(variable node.Node, expression node.Node) node.Node {
return Plus{
BinaryOp{
node.SimpleNode{Name: "BinaryPlus", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Pow struct {
BinaryOp
}
func NewPow(variable node.Node, expression node.Node) node.Node {
return Pow{
BinaryOp{
node.SimpleNode{Name: "BinaryPow", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type ShiftLeft struct {
BinaryOp
}
func NewShiftLeft(variable node.Node, expression node.Node) node.Node {
return ShiftLeft{
BinaryOp{
node.SimpleNode{Name: "BinaryShiftLeft", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type ShiftRight struct {
BinaryOp
}
func NewShiftRight(variable node.Node, expression node.Node) node.Node {
return ShiftRight{
BinaryOp{
node.SimpleNode{Name: "BinaryShiftRight", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Smaller struct {
BinaryOp
}
func NewSmaller(variable node.Node, expression node.Node) node.Node {
return Smaller{
BinaryOp{
node.SimpleNode{Name: "BinarySmaller", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type SmallerOrEqual struct {
BinaryOp
}
func NewSmallerOrEqual(variable node.Node, expression node.Node) node.Node {
return SmallerOrEqual{
BinaryOp{
node.SimpleNode{Name: "BinarySmallerOrEqual", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

View File

@@ -0,0 +1,19 @@
package binary_op
import (
"github.com/z7zmey/php-parser/node"
)
type Spaceship struct {
BinaryOp
}
func NewSpaceship(variable node.Node, expression node.Node) node.Node {
return Spaceship{
BinaryOp{
node.SimpleNode{Name: "BinarySpaceship", Attributes: make(map[string]string)},
variable,
expression,
},
}
}

29
node/expr/cast/cast.go Normal file
View File

@@ -0,0 +1,29 @@
package cast
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type Cast struct {
node.SimpleNode
expr node.Node
}
func NewCast(expr node.Node) node.Node {
return Cast{
node.SimpleNode{Name: "Cast", Attributes: make(map[string]string)},
expr,
}
}
func (n Cast) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
if n.expr != nil {
fmt.Fprintf(out, "\n%vexpr:", indent+" ")
n.expr.Print(out, indent+" ")
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastArray struct {
Cast
}
func NewCastArray(expr node.Node) node.Node {
return CastArray{
Cast{
node.SimpleNode{Name: "CastArray", Attributes: make(map[string]string)},
expr,
},
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastBool struct {
Cast
}
func NewCastBool(expr node.Node) node.Node {
return CastBool{
Cast{
node.SimpleNode{Name: "CastBool", Attributes: make(map[string]string)},
expr,
},
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastDouble struct {
Cast
}
func NewCastDouble(expr node.Node) node.Node {
return CastDouble{
Cast{
node.SimpleNode{Name: "CastDouble", Attributes: make(map[string]string)},
expr,
},
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastInt struct {
Cast
}
func NewCastInt(expr node.Node) node.Node {
return CastInt{
Cast{
node.SimpleNode{Name: "CastInt", Attributes: make(map[string]string)},
expr,
},
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastObject struct {
Cast
}
func NewCastObject(expr node.Node) node.Node {
return CastObject{
Cast{
node.SimpleNode{Name: "CastObject", Attributes: make(map[string]string)},
expr,
},
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastString struct {
Cast
}
func NewCastString(expr node.Node) node.Node {
return CastString{
Cast{
node.SimpleNode{Name: "CastString", Attributes: make(map[string]string)},
expr,
},
}
}

View File

@@ -0,0 +1,18 @@
package cast
import (
"github.com/z7zmey/php-parser/node"
)
type CastUnset struct {
Cast
}
func NewCastUnset(expr node.Node) node.Node {
return CastUnset{
Cast{
node.SimpleNode{Name: "CastUnset", Attributes: make(map[string]string)},
expr,
},
}
}