From 48d9ec8aef4c3e7f3574346a6cf6a1fa3d725561 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 25 Jan 2026 18:09:51 +0900 Subject: refactor term parsing --- src/jq/compile.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/jq/compile.zig') 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); -- cgit v1.3-1-g0d28