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,
},
}
}

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,9 @@ import (
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/expr/assign_op"
"github.com/z7zmey/php-parser/node/expr/binary_op"
"github.com/z7zmey/php-parser/node/expr/cast"
)
var rootnode = node.NewSimpleNode("Root")
@ -807,69 +810,69 @@ new_expr:
expr_without_variable:
T_LIST '(' array_pair_list ')' '=' expr { $$ = node.NewSimpleNode("Assign").Append($3).Append($6); }
| '[' array_pair_list ']' '=' expr { $$ = node.NewSimpleNode("Assign").Append($2).Append($5); }
| variable '=' expr { $$ = node.NewSimpleNode("Assign").Append($1).Append($3); }
| variable '=' '&' expr { $$ = node.NewSimpleNode("AssignRef").Append($1).Append($4); }
| variable '=' expr { $$ = assign_op.NewAssign($1, $3, false) }
| variable '=' '&' expr { $$ = assign_op.NewAssign($1, $4, true) }
| T_CLONE expr { $$ = node.NewSimpleNode("Clone").Append($2); }
| variable T_PLUS_EQUAL expr { $$ = node.NewSimpleNode("AssignAdd").Append($1).Append($3); }
| variable T_MINUS_EQUAL expr { $$ = node.NewSimpleNode("AssignSub").Append($1).Append($3); }
| variable T_MUL_EQUAL expr { $$ = node.NewSimpleNode("AssignMul").Append($1).Append($3); }
| variable T_POW_EQUAL expr { $$ = node.NewSimpleNode("AssignPow").Append($1).Append($3); }
| variable T_DIV_EQUAL expr { $$ = node.NewSimpleNode("AssignDiv").Append($1).Append($3); }
| variable T_CONCAT_EQUAL expr { $$ = node.NewSimpleNode("AssignConcat").Append($1).Append($3); }
| variable T_MOD_EQUAL expr { $$ = node.NewSimpleNode("AssignMod").Append($1).Append($3); }
| variable T_AND_EQUAL expr { $$ = node.NewSimpleNode("AssignAnd").Append($1).Append($3); }
| variable T_OR_EQUAL expr { $$ = node.NewSimpleNode("AssignOr").Append($1).Append($3); }
| variable T_XOR_EQUAL expr { $$ = node.NewSimpleNode("AssignXor").Append($1).Append($3); }
| variable T_SL_EQUAL expr { $$ = node.NewSimpleNode("AssignShiftLeft").Append($1).Append($3); }
| variable T_SR_EQUAL expr { $$ = node.NewSimpleNode("AssignShiftRight").Append($1).Append($3); }
| variable T_PLUS_EQUAL expr { $$ = assign_op.NewPlus($1, $3) }
| variable T_MINUS_EQUAL expr { $$ = assign_op.NewMinus($1, $3) }
| variable T_MUL_EQUAL expr { $$ = assign_op.NewMul($1, $3) }
| variable T_POW_EQUAL expr { $$ = assign_op.NewPow($1, $3) }
| variable T_DIV_EQUAL expr { $$ = assign_op.NewDiv($1, $3) }
| variable T_CONCAT_EQUAL expr { $$ = assign_op.NewConcat($1, $3) }
| variable T_MOD_EQUAL expr { $$ = assign_op.NewMod($1, $3) }
| variable T_AND_EQUAL expr { $$ = assign_op.NewBitwiseAnd($1, $3) }
| variable T_OR_EQUAL expr { $$ = assign_op.NewBitwiseOr($1, $3) }
| variable T_XOR_EQUAL expr { $$ = assign_op.NewBitwiseXor($1, $3) }
| variable T_SL_EQUAL expr { $$ = assign_op.NewShiftLeft($1, $3) }
| variable T_SR_EQUAL expr { $$ = assign_op.NewShiftRight($1, $3) }
| variable T_INC { $$ = node.NewSimpleNode("PostIncrement").Append($1) }
| T_INC variable { $$ = node.NewSimpleNode("PreIncrement").Append($2) }
| variable T_DEC { $$ = node.NewSimpleNode("PostDecrement").Append($1) }
| T_DEC variable { $$ = node.NewSimpleNode("PreDecrement").Append($2) }
| expr T_BOOLEAN_OR expr { $$ = node.NewSimpleNode("Or").Append($1).Append($3) }
| expr T_BOOLEAN_AND expr { $$ = node.NewSimpleNode("And").Append($1).Append($3) }
| expr T_LOGICAL_OR expr { $$ = node.NewSimpleNode("Or").Append($1).Append($3) }
| expr T_LOGICAL_AND expr { $$ = node.NewSimpleNode("And").Append($1).Append($3) }
| expr T_LOGICAL_XOR expr { $$ = node.NewSimpleNode("Xor").Append($1).Append($3) }
| expr '|' expr { $$ = node.NewSimpleNode("BitwiseOr").Append($1).Append($3) }
| expr '&' expr { $$ = node.NewSimpleNode("BitwiseAnd").Append($1).Append($3) }
| expr '^' expr { $$ = node.NewSimpleNode("BitwiseXor").Append($1).Append($3) }
| expr '.' expr { $$ = node.NewSimpleNode("Concat").Append($1).Append($3) }
| expr '+' expr { $$ = node.NewSimpleNode("Add").Append($1).Append($3) }
| expr '-' expr { $$ = node.NewSimpleNode("Sub").Append($1).Append($3) }
| expr '*' expr { $$ = node.NewSimpleNode("Mul").Append($1).Append($3) }
| expr T_POW expr { $$ = node.NewSimpleNode("Pow").Append($1).Append($3) }
| expr '/' expr { $$ = node.NewSimpleNode("Div").Append($1).Append($3) }
| expr '%' expr { $$ = node.NewSimpleNode("Mod").Append($1).Append($3) }
| expr T_SL expr { $$ = node.NewSimpleNode("ShiftLeft").Append($1).Append($3) }
| expr T_SR expr { $$ = node.NewSimpleNode("ShiftRight").Append($1).Append($3) }
| expr T_BOOLEAN_OR expr { $$ = binary_op.NewBooleanOr($1, $3) }
| expr T_BOOLEAN_AND expr { $$ = binary_op.NewBooleanAnd($1, $3) }
| expr T_LOGICAL_OR expr { $$ = binary_op.NewLogicalOr($1, $3) }
| expr T_LOGICAL_AND expr { $$ = binary_op.NewLogicalAnd($1, $3) }
| expr T_LOGICAL_XOR expr { $$ = binary_op.NewLogicalXor($1, $3) }
| expr '|' expr { $$ = binary_op.NewBitwiseOr($1, $3) }
| expr '&' expr { $$ = binary_op.NewBitwiseAnd($1, $3) }
| expr '^' expr { $$ = binary_op.NewBitwiseXor($1, $3) }
| expr '.' expr { $$ = binary_op.NewConcat($1, $3) }
| expr '+' expr { $$ = binary_op.NewPlus($1, $3) }
| expr '-' expr { $$ = binary_op.NewMinus($1, $3) }
| expr '*' expr { $$ = binary_op.NewMul($1, $3) }
| expr T_POW expr { $$ = binary_op.NewPow($1, $3) }
| expr '/' expr { $$ = binary_op.NewDiv($1, $3) }
| expr '%' expr { $$ = binary_op.NewMod($1, $3) }
| expr T_SL expr { $$ = binary_op.NewShiftLeft($1, $3) }
| expr T_SR expr { $$ = binary_op.NewShiftRight($1, $3) }
| '+' expr %prec T_INC { $$ = node.NewSimpleNode("UnaryPlus").Append($2) }
| '-' expr %prec T_INC { $$ = node.NewSimpleNode("UnaryMinus").Append($2) }
| '!' expr { $$ = node.NewSimpleNode("BooleanNot").Append($2) }
| '~' expr { $$ = node.NewSimpleNode("BitwiseNot").Append($2) }
| expr T_IS_IDENTICAL expr { $$ = node.NewSimpleNode("Identical").Append($1).Append($3) }
| expr T_IS_NOT_IDENTICAL expr { $$ = node.NewSimpleNode("NotIdentical").Append($1).Append($3) }
| expr T_IS_EQUAL expr { $$ = node.NewSimpleNode("Equal").Append($1).Append($3) }
| expr T_IS_NOT_EQUAL expr { $$ = node.NewSimpleNode("NotEqual").Append($1).Append($3) }
| expr '<' expr { $$ = node.NewSimpleNode("Smaller").Append($1).Append($3) }
| expr T_IS_SMALLER_OR_EQUAL expr { $$ = node.NewSimpleNode("SmallerOrEqual").Append($1).Append($3) }
| expr '>' expr { $$ = node.NewSimpleNode("Greater").Append($1).Append($3) }
| expr T_IS_GREATER_OR_EQUAL expr { $$ = node.NewSimpleNode("GreaterOrEqual").Append($1).Append($3) }
| expr T_SPACESHIP expr { $$ = node.NewSimpleNode("Spaceship").Append($1).Append($3); }
| expr T_IS_IDENTICAL expr { $$ = binary_op.NewIdentical($1, $3) }
| expr T_IS_NOT_IDENTICAL expr { $$ = binary_op.NewNotIdentical($1, $3) }
| expr T_IS_EQUAL expr { $$ = binary_op.NewEqual($1, $3) }
| expr T_IS_NOT_EQUAL expr { $$ = binary_op.NewNotEqual($1, $3) }
| expr '<' expr { $$ = binary_op.NewSmaller($1, $3) }
| expr T_IS_SMALLER_OR_EQUAL expr { $$ = binary_op.NewSmallerOrEqual($1, $3) }
| expr '>' expr { $$ = binary_op.NewGreater($1, $3) }
| expr T_IS_GREATER_OR_EQUAL expr { $$ = binary_op.NewGreaterOrEqual($1, $3) }
| expr T_SPACESHIP expr { $$ = binary_op.NewSpaceship($1, $3) }
| expr T_INSTANCEOF class_name_reference { $$ = node.NewSimpleNode("InstanceOf").Append($1).Append($3) }
| '(' expr ')' { $$ = $2; }
| new_expr { $$ = $1; }
| expr '?' expr ':' expr { $$ = node.NewSimpleNode("Ternary").Append($1).Append($3).Append($5); }
| expr '?' ':' expr { $$ = node.NewSimpleNode("Ternary").Append($1).Append($4); }
| expr T_COALESCE expr { $$ = node.NewSimpleNode("Coalesce").Append($1).Append($3); }
| expr T_COALESCE expr { $$ = binary_op.NewCoalesce($1, $3) }
| internal_functions_in_yacc { $$ = $1}
| T_INT_CAST expr { $$ = node.NewSimpleNode("CastInt").Append($2); }
| T_DOUBLE_CAST expr { $$ = node.NewSimpleNode("CastDouble").Append($2); }
| T_STRING_CAST expr { $$ = node.NewSimpleNode("CastString").Append($2); }
| T_ARRAY_CAST expr { $$ = node.NewSimpleNode("CastArray").Append($2); }
| T_OBJECT_CAST expr { $$ = node.NewSimpleNode("CastObject").Append($2); }
| T_BOOL_CAST expr { $$ = node.NewSimpleNode("CastBool").Append($2); }
| T_UNSET_CAST expr { $$ = node.NewSimpleNode("CastUnset").Append($2); }
| T_INT_CAST expr { $$ = cast.NewCastInt($2) }
| T_DOUBLE_CAST expr { $$ = cast.NewCastDouble($2) }
| T_STRING_CAST expr { $$ = cast.NewCastString($2) }
| T_ARRAY_CAST expr { $$ = cast.NewCastArray($2) }
| T_OBJECT_CAST expr { $$ = cast.NewCastObject($2) }
| T_BOOL_CAST expr { $$ = cast.NewCastBool($2) }
| T_UNSET_CAST expr { $$ = cast.NewCastUnset($2) }
| T_EXIT exit_expr { $$ = node.NewSimpleNode("Exit").Append($2); }
| '@' expr { $$ = node.NewSimpleNode("Silence").Append($2); }
| scalar { $$ = $1; }