yield yield_from nodes

This commit is contained in:
z7zmey
2017-12-18 20:45:18 +02:00
parent 92b9453de7
commit 3ec45dc334
4 changed files with 73 additions and 8 deletions

36
node/expr/yield.go Normal file
View File

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

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

@@ -0,0 +1,29 @@
package expr
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
)
type YieldFrom struct {
node.SimpleNode
expr node.Node
}
func NewYieldFrom(expression node.Node) node.Node {
return YieldFrom{
node.SimpleNode{Name: "YieldFrom", Attributes: make(map[string]string)},
expression,
}
}
func (n YieldFrom) 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+" ")
}
}