xgo/ast/slice_expr.go

34 lines
526 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import "github.com/d5/tengo/source"
2019-01-09 10:17:42 +03:00
type SliceExpr struct {
Expr Expr
LBrack source.Pos
2019-01-09 10:17:42 +03:00
Low Expr
High Expr
RBrack source.Pos
2019-01-09 10:17:42 +03:00
}
func (e *SliceExpr) exprNode() {}
func (e *SliceExpr) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return e.Expr.Pos()
}
func (e *SliceExpr) End() source.Pos {
2019-01-09 10:17:42 +03:00
return e.RBrack + 1
}
func (e *SliceExpr) String() string {
var low, high string
if e.Low != nil {
low = e.Low.String()
}
if e.High != nil {
high = e.High.String()
}
return e.Expr.String() + "[" + low + ":" + high + "]"
}