xgo/ast/index_expr.go

30 lines
461 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import "github.com/d5/tengo/scanner"
type IndexExpr struct {
Expr Expr
LBrack scanner.Pos
Index Expr
RBrack scanner.Pos
}
func (e *IndexExpr) exprNode() {}
func (e *IndexExpr) Pos() scanner.Pos {
return e.Expr.Pos()
}
func (e *IndexExpr) End() scanner.Pos {
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 + "]"
}