xgo/ast/array_lit.go

33 lines
479 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 ArrayLit struct {
Elements []Expr
LBrack source.Pos
RBrack source.Pos
2019-01-09 10:17:42 +03:00
}
func (e *ArrayLit) exprNode() {}
func (e *ArrayLit) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return e.LBrack
}
func (e *ArrayLit) End() source.Pos {
2019-01-09 10:17:42 +03:00
return e.RBrack + 1
}
func (e *ArrayLit) String() string {
var elts []string
for _, m := range e.Elements {
elts = append(elts, m.String())
}
return "[" + strings.Join(elts, ", ") + "]"
}