From 22811834abe3603e28128a17ac004b1aeea3d651 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 17 Jan 2026 12:30:34 +0900 Subject: implement identity filter --- src/jq/compile.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/jq/compile.zig (limited to 'src/jq/compile.zig') diff --git a/src/jq/compile.zig b/src/jq/compile.zig new file mode 100644 index 0000000..d81f8ac --- /dev/null +++ b/src/jq/compile.zig @@ -0,0 +1,22 @@ +const std = @import("std"); +const Ast = @import("./parse.zig").Ast; + +pub const Opcode = enum { + nop, + identity, +}; + +pub const Instr = struct { + op: Opcode, +}; + +pub fn compile(allocator: std.mem.Allocator, compile_allocator: std.mem.Allocator, ast: *const Ast) ![]Instr { + _ = compile_allocator; + var instrs = try std.array_list.Aligned(Instr, null).initCapacity(allocator, 16); + + switch (ast.kind) { + .identity => try instrs.append(allocator, .{ .op = .identity }), + } + + return instrs.toOwnedSlice(allocator); +} -- cgit v1.3-1-g0d28