summaryrefslogtreecommitdiff
path: root/src/zisp/io/Parser.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/zisp/io/Parser.zig')
-rw-r--r--src/zisp/io/Parser.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/zisp/io/Parser.zig b/src/zisp/io/Parser.zig
index 57cdc14..2c381e1 100644
--- a/src/zisp/io/Parser.zig
+++ b/src/zisp/io/Parser.zig
@@ -119,7 +119,8 @@ pub const Alloc = struct {
};
alloc: Alloc,
-input: std.io.AnyReader = undefined,
+io: std.Io,
+input: *std.Io.Reader = undefined,
context: Context = .{},
stack: List(Context) = undefined,
chars: List(u8) = undefined,
@@ -130,10 +131,11 @@ err_msg: []const u8 = undefined,
pub fn init(
alloc: Alloc,
+ io: std.Io,
init_stack_capacity: usize,
init_chars_capacity: usize,
) !Parser {
- var p: Parser = .{ .alloc = alloc };
+ var p: Parser = .{ .alloc = alloc, .io = io };
p.stack = try .initCapacity(alloc.stack, init_stack_capacity);
p.chars = try .initCapacity(alloc.chars, init_chars_capacity);
return p;
@@ -155,7 +157,7 @@ fn read(p: *Parser) !?u8 {
.{p.unread_char.?},
);
}
- const c = p.input.readByte() catch |e| switch (e) {
+ const c = p.input.takeByte() catch |e| switch (e) {
error.EndOfStream => return null,
else => return p.err(.ReadError, "???"),
};
@@ -242,7 +244,7 @@ fn call(p: *Parser, f: Fn) !void {
};
}
-pub fn run(p: *Parser, input: std.io.AnyReader) !Value {
+pub fn run(p: *Parser, input: *std.Io.Reader) !Value {
p.input = input;
p.context.next = .parseUnit;
while (p.context.next) |next| {