unary_plus unary_minus boolean_not bitwise_not nodes
This commit is contained in:
parent
d971494d12
commit
ae759c26c7
29
node/expr/bitwise_not.go
Normal file
29
node/expr/bitwise_not.go
Normal file
@ -0,0 +1,29 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type BitwiseNot struct {
|
||||
node.SimpleNode
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewBitwiseNot(expression node.Node) node.Node {
|
||||
return BitwiseNot{
|
||||
node.SimpleNode{Name: "BitwiseNot", Attributes: make(map[string]string)},
|
||||
expression,
|
||||
}
|
||||
}
|
||||
|
||||
func (n BitwiseNot) 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+" ")
|
||||
}
|
||||
}
|
29
node/expr/boolean_not.go
Normal file
29
node/expr/boolean_not.go
Normal file
@ -0,0 +1,29 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type BooleanNot struct {
|
||||
node.SimpleNode
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewBooleanNot(expression node.Node) node.Node {
|
||||
return BooleanNot{
|
||||
node.SimpleNode{Name: "BooleanNot", Attributes: make(map[string]string)},
|
||||
expression,
|
||||
}
|
||||
}
|
||||
|
||||
func (n BooleanNot) 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+" ")
|
||||
}
|
||||
}
|
29
node/expr/unary_minus.go
Normal file
29
node/expr/unary_minus.go
Normal file
@ -0,0 +1,29 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type UnaryMinus struct {
|
||||
node.SimpleNode
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewUnaryMinus(expression node.Node) node.Node {
|
||||
return UnaryMinus{
|
||||
node.SimpleNode{Name: "UnaryMinus", Attributes: make(map[string]string)},
|
||||
expression,
|
||||
}
|
||||
}
|
||||
|
||||
func (n UnaryMinus) 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+" ")
|
||||
}
|
||||
}
|
29
node/expr/unary_plus.go
Normal file
29
node/expr/unary_plus.go
Normal file
@ -0,0 +1,29 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type UnaryPlus struct {
|
||||
node.SimpleNode
|
||||
expr node.Node
|
||||
}
|
||||
|
||||
func NewUnaryPlus(expression node.Node) node.Node {
|
||||
return UnaryPlus{
|
||||
node.SimpleNode{Name: "UnaryPlus", Attributes: make(map[string]string)},
|
||||
expression,
|
||||
}
|
||||
}
|
||||
|
||||
func (n UnaryPlus) 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+" ")
|
||||
}
|
||||
}
|
@ -4026,25 +4026,25 @@ yydefault:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:853
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("UnaryPlus").Append(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewUnaryPlus(yyDollar[2].node)
|
||||
}
|
||||
case 332:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:854
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("UnaryMinus").Append(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewUnaryMinus(yyDollar[2].node)
|
||||
}
|
||||
case 333:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:855
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("BooleanNot").Append(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewBooleanNot(yyDollar[2].node)
|
||||
}
|
||||
case 334:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:856
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("BitwiseNot").Append(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewBitwiseNot(yyDollar[2].node)
|
||||
}
|
||||
case 335:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
|
@ -850,10 +850,10 @@ expr_without_variable:
|
||||
| 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 %prec T_INC { $$ = expr.NewUnaryPlus($2) }
|
||||
| '-' expr %prec T_INC { $$ = expr.NewUnaryMinus($2) }
|
||||
| '!' expr { $$ = expr.NewBooleanNot($2) }
|
||||
| '~' expr { $$ = expr.NewBitwiseNot($2) }
|
||||
| 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) }
|
||||
|
Loading…
Reference in New Issue
Block a user