aboutsummaryrefslogtreecommitdiff
path: root/src/root.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-19 22:28:56 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-19 22:28:56 +0200
commitdb2f49115713c47b48587022511b3654a7042493 (patch)
tree159535d22691f2d1287e568e44fe3a90dc8443c7 /src/root.zig
parentb9d58fbbd94dc8f97f9f4c6c333039386bbbeaa1 (diff)
feat(lib): support input from file and from reader
Diffstat (limited to 'src/root.zig')
-rw-r--r--src/root.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig
index 4750814..956f584 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -56,6 +56,15 @@ pub fn zigParse(alloc: std.mem.Allocator, content: []const u8) Error![]const u8
return parser.parse(alloc, content);
}
+pub fn zigParseReader(alloc: std.mem.Allocator, r: *std.io.Reader) ![]const u8 {
+ return parser.parseReader(alloc, r);
+}
+
+pub fn zigParseFile(alloc: std.mem.Allocator, path: []const u8) ![]const u8 {
+ const file = try std.fs.cwd().readFileAlloc(alloc, path, std.math.maxInt(usize));
+ return zigParse(alloc, file);
+}
+
test {
std.testing.refAllDeclsRecursive(@This());
}