xgo/ast/map_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 MapLit struct {
LBrace source.Pos
2019-01-09 10:17:42 +03:00
Elements []*MapElementLit
RBrace source.Pos
2019-01-09 10:17:42 +03:00
}
func (e *MapLit) exprNode() {}
func (e *MapLit) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return e.LBrace
}
func (e *MapLit) End() source.Pos {
2019-01-09 10:17:42 +03:00
return e.RBrace + 1
}
func (e *MapLit) String() string {
var elts []string
for _, m := range e.Elements {
elts = append(elts, m.String())
}
return "{" + strings.Join(elts, ", ") + "}"
}