summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/compiler/ast/block_stmt.go
blob: 9bde9fa31d1a69451d4f08957b5a61148b919c92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package ast

import (
	"strings"

	"github.com/d5/tengo/compiler/source"
)

// BlockStmt represents a block statement.
type BlockStmt struct {
	Stmts  []Stmt
	LBrace source.Pos
	RBrace source.Pos
}

func (s *BlockStmt) stmtNode() {}

// Pos returns the position of first character belonging to the node.
func (s *BlockStmt) Pos() source.Pos {
	return s.LBrace
}

// End returns the position of first character immediately after the node.
func (s *BlockStmt) End() source.Pos {
	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, "; ") + "}"
}