implement support for multiple index operations

This commit is contained in:
Alex Zenla
2025-07-26 16:31:12 -07:00
parent b451f74239
commit 48e19a8068
2 changed files with 5 additions and 1 deletions

4
examples/index.pork Normal file
View File

@ -0,0 +1,4 @@
export func main() {
let items = [["Hello"], ["Goodbye"]]
println(items[0][0])
}

View File

@ -63,7 +63,7 @@ class Parser(source: TokenSource, attribution: NodeAttribution) :
} }
} }
if (peek(TokenType.LeftBracket)) { while (peek(TokenType.LeftBracket)) {
expression = produce(NodeType.IndexedBy) { expression = produce(NodeType.IndexedBy) {
attribution.adopt(expression) attribution.adopt(expression)
expect(TokenType.LeftBracket) expect(TokenType.LeftBracket)