php-parser/node/stmt/goto.go

34 lines
479 B
Go
Raw Normal View History

2017-12-07 16:51:40 +00:00
package stmt
import (
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
2017-12-27 23:23:32 +00:00
func (n Goto) Name() string {
2017-12-27 17:55:58 +00:00
return "Goto"
}
2017-12-07 16:51:40 +00:00
type Goto struct {
2017-12-27 17:55:58 +00:00
name string
2017-12-07 16:51:40 +00:00
token token.Token
2017-12-27 17:55:58 +00:00
label token.Token
2017-12-07 16:51:40 +00:00
}
2017-12-27 23:23:32 +00:00
// todl label must be identifier
func NewGoto(token token.Token, label token.Token) node.Node {
2017-12-07 16:51:40 +00:00
return Goto{
2017-12-27 17:55:58 +00:00
"Goto",
2017-12-07 16:51:40 +00:00
token,
2017-12-27 23:23:32 +00:00
label,
2017-12-07 16:51:40 +00:00
}
}
2017-12-27 23:23:32 +00:00
func (n Goto) Walk(v node.Visitor) {
if v.Visit(n) == false {
return
}
v.Scalar("label", n.label.Value)
2017-12-07 16:51:40 +00:00
}