From 48e19a806860e56ede7598a3ecafbd0d427e305e Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 26 Jul 2025 16:31:12 -0700 Subject: [PATCH] implement support for multiple index operations --- examples/index.pork | 4 ++++ parser/src/main/kotlin/gay/pizza/pork/parser/Parser.kt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 examples/index.pork diff --git a/examples/index.pork b/examples/index.pork new file mode 100644 index 0000000..d3ecdea --- /dev/null +++ b/examples/index.pork @@ -0,0 +1,4 @@ +export func main() { + let items = [["Hello"], ["Goodbye"]] + println(items[0][0]) +} diff --git a/parser/src/main/kotlin/gay/pizza/pork/parser/Parser.kt b/parser/src/main/kotlin/gay/pizza/pork/parser/Parser.kt index 8be465e..e66b8e6 100644 --- a/parser/src/main/kotlin/gay/pizza/pork/parser/Parser.kt +++ b/parser/src/main/kotlin/gay/pizza/pork/parser/Parser.kt @@ -63,7 +63,7 @@ class Parser(source: TokenSource, attribution: NodeAttribution) : } } - if (peek(TokenType.LeftBracket)) { + while (peek(TokenType.LeftBracket)) { expression = produce(NodeType.IndexedBy) { attribution.adopt(expression) expect(TokenType.LeftBracket)