php-parser/node/stmt/interface.go

50 lines
930 B
Go
Raw Normal View History

2017-12-08 09:57:25 +00:00
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
2017-12-27 17:55:58 +00:00
func(n Interface) Name() string {
return "Interface"
}
2017-12-08 09:57:25 +00:00
type Interface struct {
2017-12-27 17:55:58 +00:00
name string
2017-12-08 09:57:25 +00:00
token token.Token
2017-12-27 17:55:58 +00:00
iName token.Token
2017-12-22 10:55:49 +00:00
extends []node.Node
2017-12-08 09:57:25 +00:00
stmts []node.Node
}
2017-12-22 10:55:49 +00:00
func NewInterface(token token.Token, name token.Token, extends []node.Node, stmts []node.Node) node.Node {
2017-12-08 09:57:25 +00:00
return Interface{
2017-12-27 17:55:58 +00:00
"Interface",
2017-12-08 09:57:25 +00:00
token,
name,
extends,
stmts,
}
}
func (n Interface) Print(out io.Writer, indent string) {
2017-12-27 17:55:58 +00:00
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.iName.Value)
2017-12-08 09:57:25 +00:00
if n.extends != nil {
fmt.Fprintf(out, "\n%vextends:", indent+" ")
2017-12-22 10:55:49 +00:00
for _, nn := range n.extends {
nn.Print(out, indent+" ")
}
2017-12-08 09:57:25 +00:00
}
if n.stmts != nil {
fmt.Fprintf(out, "\n%vstmts:", indent+" ")
for _, nn := range n.stmts {
nn.Print(out, indent+" ")
}
}
}