trait_use_precedence node
This commit is contained in:
parent
f4a0a56b14
commit
20232dd30c
36
node/stmt/trait_use_precedence.go
Normal file
36
node/stmt/trait_use_precedence.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package stmt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TraitUsePrecedence struct {
|
||||||
|
node.SimpleNode
|
||||||
|
ref node.Node
|
||||||
|
insteadof node.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTraitUsePrecedence(ref node.Node, insteadof node.Node) node.Node {
|
||||||
|
return TraitUsePrecedence{
|
||||||
|
node.SimpleNode{Name: "TraitUsePrecedence", Attributes: make(map[string]string)},
|
||||||
|
ref,
|
||||||
|
insteadof,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n TraitUsePrecedence) Print(out io.Writer, indent string) {
|
||||||
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||||
|
|
||||||
|
if n.ref != nil {
|
||||||
|
fmt.Fprintf(out, "\n%vmethod", indent+" ")
|
||||||
|
n.ref.Print(out, indent+" ")
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.insteadof != nil {
|
||||||
|
fmt.Fprintf(out, "\n%vinsteadof:", indent+" ")
|
||||||
|
n.insteadof.Print(out, indent+" ")
|
||||||
|
}
|
||||||
|
}
|
471
parser/parser.go
471
parser/parser.go
File diff suppressed because it is too large
Load Diff
@ -701,7 +701,10 @@ trait_adaptation:
|
|||||||
|
|
||||||
trait_precedence:
|
trait_precedence:
|
||||||
absolute_trait_method_reference T_INSTEADOF name_list
|
absolute_trait_method_reference T_INSTEADOF name_list
|
||||||
{ $$ = node.NewSimpleNode("TraitPrecedence").Append($1).Append($3) }
|
{
|
||||||
|
name := name.NewName($3.(node.SimpleNode).Children)
|
||||||
|
$$ = stmt.NewTraitUsePrecedence($1, name)
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
trait_alias:
|
trait_alias:
|
||||||
|
Loading…
Reference in New Issue
Block a user