trait_method_ref node
This commit is contained in:
parent
20232dd30c
commit
1efa7ff5ee
32
node/stmt/trait_method_ref.go
Normal file
32
node/stmt/trait_method_ref.go
Normal file
@ -0,0 +1,32 @@
|
||||
package stmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type TraitMethodRef struct {
|
||||
node.SimpleNode
|
||||
trait node.Node
|
||||
method token.Token
|
||||
}
|
||||
|
||||
func NewTraitMethodRef(trait node.Node, method token.Token) node.Node {
|
||||
return TraitMethodRef{
|
||||
node.SimpleNode{Name: "TraitMethodRef", Attributes: make(map[string]string)},
|
||||
trait,
|
||||
method,
|
||||
}
|
||||
}
|
||||
|
||||
func (n TraitMethodRef) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [- -] %q", indent, n.Name, n.method.Value)
|
||||
|
||||
if n.trait != nil {
|
||||
fmt.Fprintf(out, "\n%vtrait", indent+" ")
|
||||
n.trait.Print(out, indent+" ")
|
||||
}
|
||||
}
|
@ -3585,7 +3585,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line parser/parser.y:720
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("TraitMethodRef").Attribute("value", yyDollar[1].token.Value)
|
||||
yyVAL.node = stmt.NewTraitMethodRef(nil, yyDollar[1].token)
|
||||
}
|
||||
case 259:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
@ -3597,7 +3597,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line parser/parser.y:725
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("TraitMethodRef").Append(yyDollar[1].node).Attribute("value", yyDollar[3].token.Value)
|
||||
yyVAL.node = stmt.NewTraitMethodRef(yyDollar[1].node, yyDollar[3].token)
|
||||
}
|
||||
case 261:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
|
@ -717,12 +717,12 @@ trait_alias:
|
||||
;
|
||||
|
||||
trait_method_reference:
|
||||
identifier { $$ = node.NewSimpleNode("TraitMethodRef").Attribute("value", $1.Value); }
|
||||
identifier { $$ = stmt.NewTraitMethodRef(nil, $1) }
|
||||
| absolute_trait_method_reference { $$ = $1; }
|
||||
;
|
||||
|
||||
absolute_trait_method_reference:
|
||||
name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = node.NewSimpleNode("TraitMethodRef").Append($1).Attribute("value", $3.Value) }
|
||||
name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = stmt.NewTraitMethodRef($1, $3) }
|
||||
;
|
||||
|
||||
method_body:
|
||||
|
Loading…
Reference in New Issue
Block a user