2019-01-09 10:17:42 +03:00
|
|
|
package ast
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
"github.com/d5/tengo/source"
|
2019-01-09 10:17:42 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type ArrayLit struct {
|
|
|
|
Elements []Expr
|
2019-01-11 12:16:34 +03:00
|
|
|
LBrack source.Pos
|
|
|
|
RBrack source.Pos
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e *ArrayLit) exprNode() {}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
func (e *ArrayLit) Pos() source.Pos {
|
2019-01-09 10:17:42 +03:00
|
|
|
return e.LBrack
|
|
|
|
}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
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, ", ") + "]"
|
|
|
|
}
|