xgo/ast/block_stmt.go

33 lines
475 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
"github.com/d5/tengo/source"
2019-01-09 10:17:42 +03:00
)
type BlockStmt struct {
Stmts []Stmt
LBrace source.Pos
RBrace source.Pos
2019-01-09 10:17:42 +03:00
}
func (s *BlockStmt) stmtNode() {}
func (s *BlockStmt) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return s.LBrace
}
func (s *BlockStmt) End() source.Pos {
2019-01-09 10:17:42 +03:00
return s.RBrace + 1
}
func (s *BlockStmt) String() string {
var list []string
for _, e := range s.Stmts {
list = append(list, e.String())
}
return "{" + strings.Join(list, "; ") + "}"
}