compiler-in-go/pkg/ast/index.go
jmug 0acd1d41e8 Add all the files from the interpreter repo
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
2025-01-13 19:51:49 -08:00

21 lines
428 B
Go

package ast
import (
"fmt"
"code.jmug.me/jmug/interpreter-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())
}