21 lines
425 B
Go
21 lines
425 B
Go
package ast
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.jmug.me/jmug/compiler-in-go/pkg/token"
|
|
)
|
|
|
|
type IndexExpression struct {
|
|
Token token.Token // The "[" token
|
|
Left Expression
|
|
Index Expression
|
|
}
|
|
|
|
func (ie *IndexExpression) expressionNode() {}
|
|
func (ie *IndexExpression) TokenLiteral() string {
|
|
return ie.Token.Literal
|
|
}
|
|
func (ie *IndexExpression) String() string {
|
|
return fmt.Sprintf("(%s[%s])", ie.Left.String(), ie.Index.String())
|
|
}
|