diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-01-25 18:09:51 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-01-25 18:09:51 +0900 |
| commit | 48d9ec8aef4c3e7f3574346a6cf6a1fa3d725561 (patch) | |
| tree | 37ab7baf3d4008497c72dc57a60c7c77b5153fd4 /src/jq/compile.zig | |
| parent | 20ff09460371b07d7e9683757657a5a3ead005a8 (diff) | |
| download | zgjq-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.zig | 7 |
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); |
