aboutsummaryrefslogtreecommitdiff
path: root/synth.zig
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-10-17 07:41:10 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-10-17 07:41:10 +0900
commit3a2e8fd0b06ebb738d9d4677659249e05b09e7cb (patch)
tree46e7ab24161958d60fb980dd1e28096c0fb28dd6 /synth.zig
parent663ea12374e958fa83ac7e1b439dd6ab22bb59ed (diff)
downloadtaosc-3a2e8fd0b06ebb738d9d4677659249e05b09e7cb.tar.gz
Give up fancy things0.0.3.dev1
Diffstat (limited to 'synth.zig')
-rw-r--r--synth.zig13
1 files changed, 10 insertions, 3 deletions
diff --git a/synth.zig b/synth.zig
index 4e74cd8..3e04407 100644
--- a/synth.zig
+++ b/synth.zig
@@ -29,6 +29,7 @@ const page_allocator = std.heap.page_allocator;
const parseUnsigned = std.fmt.parseUnsigned;
const print = std.debug.print;
const std = @import("std");
+const stdout = std.fs.File.stdout;
const RegisterEnum = Variables.RegisterEnum;
const Variables = @import("Variables.zig");
@@ -52,7 +53,7 @@ const Comparison = struct {
}
pub fn format(cmp: Comparison, writer: *Writer) Writer.Error!void {
- try writer.print("{s}{f}{f}", .{
+ try writer.print("{s} {f} {f}", .{
switch (cmp.op) {
.lt => "<",
.lte => "<=",
@@ -68,13 +69,18 @@ const Comparison = struct {
};
pub fn main() !void {
+ var buffer: [80]u8 = undefined;
+ var writer = stdout().writer(&buffer);
var arena = ArenaAllocator.init(page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
const args = try argsAlloc(allocator);
defer argsFree(allocator, args);
if (args.len != 4) {
- print("Usage: taosc-synth STACK_SIZE BOTTOM_DIR TOP_DIR", .{});
+ try writer.interface.print("Usage: taosc-synth {s} {s} {s}\n", .{
+ "STACK_SIZE", "BOTTOM_DIR", "TOP_DIR",
+ });
+ try writer.interface.flush();
exit(1);
}
const stack_size = try parseUnsigned(usize, args[1], 0);
@@ -91,6 +97,7 @@ pub fn main() !void {
for (enums.values(CompareOperator)) |op| {
const cmp = Comparison{ .lhs = lhs, .op = op, .rhs = rhs };
if (try cmp.check(bot, top))
- print("{f}\n", .{ cmp });
+ try writer.interface.print("{f}\n", .{ cmp });
};
+ try writer.interface.flush();
}