xgo/ast/index_expr.go

30 lines
456 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 IndexExpr struct {
Expr Expr
LBrack source.Pos
2019-01-09 10:17:42 +03:00
Index Expr
RBrack source.Pos
2019-01-09 10:17:42 +03:00
}
func (e *IndexExpr) exprNode() {}
func (e *IndexExpr) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return e.Expr.Pos()
}
func (e *IndexExpr) End() source.Pos {
2019-01-09 10:17:42 +03:00
return e.RBrack + 1
}
func (e *IndexExpr) String() string {
var index string
if e.Index != nil {
index = e.Index.String()
}
return e.Expr.String() + "[" + index + "]"
}