unary_plus unary_minus boolean_not bitwise_not nodes

This commit is contained in:
z7zmey
2017-12-16 21:31:47 +02:00
parent d971494d12
commit ae759c26c7
6 changed files with 124 additions and 8 deletions

29
node/expr/bitwise_not.go Normal file
View 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
View 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
View 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
View 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+" ")
}
}