diff options
| author | Bobby <[email protected]> | 2024-04-04 16:25:56 +0000 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-04-04 16:25:56 +0000 |
| commit | 77d0ea46b3f1de99357c7706c4c05eb44c237412 (patch) | |
| tree | d6fa8ca0a89233b26591eaed72c1017ad6190dba /ast | |
| parent | 3d4f24f7c4ea05471109c0b13abbc95e70c6924b (diff) | |
| download | mana-77d0ea46b3f1de99357c7706c4c05eb44c237412.tar.xz mana-77d0ea46b3f1de99357c7706c4c05eb44c237412.zip | |
arrays and array indexes
Diffstat (limited to 'ast')
| -rw-r--r-- | ast/ast.go | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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() +} |
