xgo/compiler/ast/block_stmt.go

36 lines
672 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/source"
2019-01-09 10:17:42 +03:00
)
// BlockStmt represents a block statement.
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() {}
// Pos returns the position of first character belonging to the node.
func (s *BlockStmt) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return s.LBrace
}
// End returns the position of first character immediately after the node.
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, "; ") + "}"
}