xgo/ast/branch_stmt.go

36 lines
567 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"github.com/d5/tengo/source"
2019-01-09 10:17:42 +03:00
"github.com/d5/tengo/token"
)
type BranchStmt struct {
Token token.Token
TokenPos source.Pos
2019-01-09 10:17:42 +03:00
Label *Ident
}
func (s *BranchStmt) stmtNode() {}
func (s *BranchStmt) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return s.TokenPos
}
func (s *BranchStmt) End() source.Pos {
2019-01-09 10:17:42 +03:00
if s.Label != nil {
return s.Label.End()
}
return source.Pos(int(s.TokenPos) + len(s.Token.String()))
2019-01-09 10:17:42 +03:00
}
func (s *BranchStmt) String() string {
var label string
if s.Label != nil {
label = " " + s.Label.Name
}
return s.Token.String() + label
}