mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-24 20:22:39 +01:00
33 lines
655 B
Go
33 lines
655 B
Go
|
package ast
|
||
|
|
||
|
import "github.com/d5/tengo/compiler/source"
|
||
|
|
||
|
// IndexExpr represents an index expression.
|
||
|
type IndexExpr struct {
|
||
|
Expr Expr
|
||
|
LBrack source.Pos
|
||
|
Index Expr
|
||
|
RBrack source.Pos
|
||
|
}
|
||
|
|
||
|
func (e *IndexExpr) exprNode() {}
|
||
|
|
||
|
// Pos returns the position of first character belonging to the node.
|
||
|
func (e *IndexExpr) Pos() source.Pos {
|
||
|
return e.Expr.Pos()
|
||
|
}
|
||
|
|
||
|
// End returns the position of first character immediately after the node.
|
||
|
func (e *IndexExpr) End() source.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 + "]"
|
||
|
}
|