diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-01-17 12:30:34 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-01-17 12:55:26 +0900 |
| commit | 22811834abe3603e28128a17ac004b1aeea3d651 (patch) | |
| tree | 071fb87406565a5950f9936dab4d94bb68b14eb6 /src/jq/compile.zig | |
| parent | 11b20173316188f511f24dc4121412097da7848d (diff) | |
| download | zgjq-22811834abe3603e28128a17ac004b1aeea3d651.tar.gz zgjq-22811834abe3603e28128a17ac004b1aeea3d651.tar.zst zgjq-22811834abe3603e28128a17ac004b1aeea3d651.zip | |
implement identity filter
Diffstat (limited to 'src/jq/compile.zig')
| -rw-r--r-- | src/jq/compile.zig | 22 |
1 files changed, 22 insertions, 0 deletions
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); +} |
