aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/jq/compile.zig
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-01-25 18:09:51 +0900
committernsfisis <nsfisis@gmail.com>2026-01-25 18:09:51 +0900
commit48d9ec8aef4c3e7f3574346a6cf6a1fa3d725561 (patch)
tree37ab7baf3d4008497c72dc57a60c7c77b5153fd4 /src/jq/compile.zig
parent20ff09460371b07d7e9683757657a5a3ead005a8 (diff)
downloadzgjq-48d9ec8aef4c3e7f3574346a6cf6a1fa3d725561.tar.gz
zgjq-48d9ec8aef4c3e7f3574346a6cf6a1fa3d725561.tar.zst
zgjq-48d9ec8aef4c3e7f3574346a6cf6a1fa3d725561.zip
refactor term parsing
Diffstat (limited to 'src/jq/compile.zig')
-rw-r--r--src/jq/compile.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/jq/compile.zig b/src/jq/compile.zig
index ec6ef63..fb2a691 100644
--- a/src/jq/compile.zig
+++ b/src/jq/compile.zig
@@ -68,9 +68,12 @@ fn compileExpr(allocator: std.mem.Allocator, compile_allocator: std.mem.Allocato
switch (ast.*) {
.identity => try instrs.append(allocator, .nop),
- .array_index => |index| {
- const index_instrs = try compileExpr(allocator, compile_allocator, index);
+ .array_index => |arr_idx| {
+ const base_instrs = try compileExpr(allocator, compile_allocator, arr_idx.base);
+ defer allocator.free(base_instrs);
+ const index_instrs = try compileExpr(allocator, compile_allocator, arr_idx.index);
defer allocator.free(index_instrs);
+ try instrs.appendSlice(allocator, base_instrs);
try instrs.append(allocator, .subexp_begin);
try instrs.appendSlice(allocator, index_instrs);
try instrs.append(allocator, .subexp_end);