aboutsummaryrefslogtreecommitdiff
path: root/ast
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-04-04 16:25:56 +0000
committerBobby <[email protected]>2024-04-04 16:25:56 +0000
commit77d0ea46b3f1de99357c7706c4c05eb44c237412 (patch)
treed6fa8ca0a89233b26591eaed72c1017ad6190dba /ast
parent3d4f24f7c4ea05471109c0b13abbc95e70c6924b (diff)
downloadmana-77d0ea46b3f1de99357c7706c4c05eb44c237412.tar.xz
mana-77d0ea46b3f1de99357c7706c4c05eb44c237412.zip
arrays and array indexes
Diffstat (limited to 'ast')
-rw-r--r--ast/ast.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/ast/ast.go b/ast/ast.go
index 9473f1a..cc30808 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -329,3 +329,23 @@ func (al *ArrayLiteral) String() string {
return out.String()
}
+
+type IndexExpression struct {
+ Token tokens.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 {
+ var out bytes.Buffer
+
+ out.WriteString("(")
+ out.WriteString(ie.Left.String())
+ out.WriteString("[")
+ out.WriteString(ie.Index.String())
+ out.WriteString("])")
+
+ return out.String()
+}