diff options
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() +} |
