Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

parse

reduce.parse
fn parse(gpa: Allocator, io: Io, file_path: []const u8) !Ast

File

lib/compiler/reduce.zig:397

Code

fn parse(gpa: Allocator, io: Io, file_path: []const u8) !Ast {
    const source_code = Io.Dir.cwd().readFileAllocOptions(
        io,
        file_path,
        gpa,
        .limited(std.math.maxInt(u32)),
        .fromByteUnits(1),
        0,
    ) catch |err| {
        fatal("unable to open '{s}': {s}", .{ file_path, @errorName(err) });
    };
    errdefer gpa.free(source_code);

    var tree = try Ast.parse(gpa, source_code, .{});
    errdefer tree.deinit(gpa);

    if (tree.errors.len != 0) {
        @panic("syntax errors occurred");
    }

    return tree;
}