other stuff idk

This commit is contained in:
mehbark 2024-12-19 19:42:24 -05:00
parent a4f175ac61
commit a521a0f18a

18
bf.zig
View file

@ -24,8 +24,6 @@ const Level1 = union(enum) {
loop_end: u24,
zero,
find_zero_left,
find_zero_right,
const Self = @This();
@ -59,8 +57,6 @@ const Level1 = union(enum) {
.loop_start => |n| try writer.print("JEZ {d:0>4}", .{n}),
.loop_end => |n| try writer.print("JNZ {d:0>4}", .{n}),
.zero => try writer.print("ZER ", .{}),
.find_zero_left => try writer.print("FZL ", .{}),
.find_zero_right => try writer.print("FZR ", .{}),
}
}
};
@ -113,10 +109,6 @@ fn compileLevel1(allocator: mem.Allocator, src: []const u8) !ArrayList(Level1) {
try out.append(.zero);
skip = 2;
cur = Level1.nothing();
} else if ((src[i + 1] == '>' or src[i + 1] == '<') and src[i + 2] == ']') {
try out.append(if (src[i + 1] == '>') .find_zero_right else .find_zero_left);
skip = 2;
cur = Level1.nothing();
} else {
cur = .{ .loop_start = 0 };
try openers.append(@as(u24, @truncate(out.items.len)));
@ -318,16 +310,6 @@ pub fn main() !void {
if (memory[mp] != 0) ip = new_ip;
},
.zero => memory[mp] = 0,
.find_zero_right => {
while (memory[mp] != 0) {
mp +%= 1;
}
},
.find_zero_left => {
while (memory[mp] != 0) {
mp -%= 1;
}
},
}
ip += 1;
}