function_call node
This commit is contained in:
parent
3c6e40fbeb
commit
9095d3fef7
38
node/expr/function_call.go
Normal file
38
node/expr/function_call.go
Normal file
@ -0,0 +1,38 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
)
|
||||
|
||||
type FunctionCall struct {
|
||||
node.SimpleNode
|
||||
function node.Node
|
||||
arguments []node.Node
|
||||
}
|
||||
|
||||
func NewFunctionCall(function node.Node, arguments []node.Node) node.Node {
|
||||
return FunctionCall{
|
||||
node.SimpleNode{Name: "FunctionCall", Attributes: make(map[string]string)},
|
||||
function,
|
||||
arguments,
|
||||
}
|
||||
}
|
||||
|
||||
func (n FunctionCall) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||
|
||||
if n.function != nil {
|
||||
fmt.Fprintf(out, "\n%vfunction:", indent+" ")
|
||||
n.function.Print(out, indent+" ")
|
||||
}
|
||||
|
||||
if n.arguments != nil {
|
||||
fmt.Fprintf(out, "\n%varguments:", indent+" ")
|
||||
for _, nn := range n.arguments {
|
||||
nn.Print(out, indent+" ")
|
||||
}
|
||||
}
|
||||
}
|
@ -4303,7 +4303,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:920
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("FunctionCall").Append(yyDollar[1].node).Append(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(node.SimpleNode).Children)
|
||||
}
|
||||
case 378:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
@ -4321,7 +4321,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:925
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("Call").Append(yyDollar[1].node).Append(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewFunctionCall(yyDollar[1].node, yyDollar[2].node.(node.SimpleNode).Children)
|
||||
}
|
||||
case 381:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
|
@ -917,12 +917,12 @@ lexical_var:
|
||||
;
|
||||
|
||||
function_call:
|
||||
name argument_list { $$ = node.NewSimpleNode("FunctionCall").Append($1).Append($2) }
|
||||
name argument_list { $$ = expr.NewFunctionCall($1, $2.(node.SimpleNode).Children) }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
|
||||
{ $$ = node.NewSimpleNode("StaticCall").Append($1).Append($3).Append($4) }
|
||||
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
|
||||
{ $$ = node.NewSimpleNode("StaticCall").Append($1).Append($3).Append($4) }
|
||||
| callable_expr argument_list { $$ = node.NewSimpleNode("Call").Append($1).Append($2); }
|
||||
| callable_expr argument_list { $$ = expr.NewFunctionCall($1, $2.(node.SimpleNode).Children) }
|
||||
;
|
||||
|
||||
class_name:
|
||||
|
Loading…
Reference in New Issue
Block a user