clone node
This commit is contained in:
parent
cf084b5893
commit
df662aaa01
29
node/expr/clone.go
Normal file
29
node/expr/clone.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package expr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Clone struct {
|
||||||
|
node.SimpleNode
|
||||||
|
expr node.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClone(expression node.Node) node.Node {
|
||||||
|
return Clone{
|
||||||
|
node.SimpleNode{Name: "Clone", Attributes: make(map[string]string)},
|
||||||
|
expression,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n Clone) 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+" ")
|
||||||
|
}
|
||||||
|
}
|
@ -3822,7 +3822,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line parser/parser.y:819
|
//line parser/parser.y:819
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewSimpleNode("Clone").Append(yyDollar[2].node)
|
yyVAL.node = expr.NewClone(yyDollar[2].node)
|
||||||
}
|
}
|
||||||
case 298:
|
case 298:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
|
@ -816,7 +816,7 @@ expr_without_variable:
|
|||||||
| '[' array_pair_list ']' '=' expr { $$ = node.NewSimpleNode("Assign").Append($2).Append($5); }
|
| '[' array_pair_list ']' '=' expr { $$ = node.NewSimpleNode("Assign").Append($2).Append($5); }
|
||||||
| variable '=' expr { $$ = assign_op.NewAssign($1, $3, false) }
|
| variable '=' expr { $$ = assign_op.NewAssign($1, $3, false) }
|
||||||
| variable '=' '&' expr { $$ = assign_op.NewAssign($1, $4, true) }
|
| variable '=' '&' expr { $$ = assign_op.NewAssign($1, $4, true) }
|
||||||
| T_CLONE expr { $$ = node.NewSimpleNode("Clone").Append($2); }
|
| T_CLONE expr { $$ = expr.NewClone($2) }
|
||||||
| variable T_PLUS_EQUAL expr { $$ = assign_op.NewPlus($1, $3) }
|
| variable T_PLUS_EQUAL expr { $$ = assign_op.NewPlus($1, $3) }
|
||||||
| variable T_MINUS_EQUAL expr { $$ = assign_op.NewMinus($1, $3) }
|
| variable T_MINUS_EQUAL expr { $$ = assign_op.NewMinus($1, $3) }
|
||||||
| variable T_MUL_EQUAL expr { $$ = assign_op.NewMul($1, $3) }
|
| variable T_MUL_EQUAL expr { $$ = assign_op.NewMul($1, $3) }
|
||||||
|
Loading…
Reference in New Issue
Block a user