structstd.zon.parse.Status[src]

Information about the success or failure of a parse.

Fields

ast: ?Ast = null
zoir: ?Zoir = null
type_check: ?Error.TypeCheckFailure = null

Functions

Functiondeinit[src]

pub fn deinit(self: *Status, gpa: Allocator) void

Parameters

self: *Status

Source Code

Source code
pub fn deinit(self: *Status, gpa: Allocator) void {
    if (self.ast) |*ast| ast.deinit(gpa);
    if (self.zoir) |*zoir| zoir.deinit(gpa);
    if (self.type_check) |tc| tc.deinit(gpa);
    self.* = undefined;
}

FunctioniterateErrors[src]

pub fn iterateErrors(self: *const Status) Error.Iterator

Parameters

self: *const Status

Source Code

Source code
pub fn iterateErrors(self: *const Status) Error.Iterator {
    return .{ .status = self };
}

Functionformat[src]

pub fn format( self: *const @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void

Parameters

self: *const @This()
fmt: []const u8

Source Code

Source code
pub fn format(
    self: *const @This(),
    comptime fmt: []const u8,
    options: std.fmt.FormatOptions,
    writer: anytype,
) !void {
    _ = fmt;
    _ = options;
    var errors = self.iterateErrors();
    while (errors.next()) |err| {
        const loc = err.getLocation(self);
        const msg = err.fmtMessage(self);
        try writer.print("{}:{}: error: {}\n", .{ loc.line + 1, loc.column + 1, msg });

        var notes = err.iterateNotes(self);
        while (notes.next()) |note| {
            const note_loc = note.getLocation(self);
            const note_msg = note.fmtMessage(self);
            try writer.print("{}:{}: note: {s}\n", .{
                note_loc.line + 1,
                note_loc.column + 1,
                note_msg,
            });
        }
    }
}

Source Code

Source code
pub const Status = struct {
    ast: ?Ast = null,
    zoir: ?Zoir = null,
    type_check: ?Error.TypeCheckFailure = null,

    fn assertEmpty(self: Status) void {
        assert(self.ast == null);
        assert(self.zoir == null);
        assert(self.type_check == null);
    }

    pub fn deinit(self: *Status, gpa: Allocator) void {
        if (self.ast) |*ast| ast.deinit(gpa);
        if (self.zoir) |*zoir| zoir.deinit(gpa);
        if (self.type_check) |tc| tc.deinit(gpa);
        self.* = undefined;
    }

    pub fn iterateErrors(self: *const Status) Error.Iterator {
        return .{ .status = self };
    }

    pub fn format(
        self: *const @This(),
        comptime fmt: []const u8,
        options: std.fmt.FormatOptions,
        writer: anytype,
    ) !void {
        _ = fmt;
        _ = options;
        var errors = self.iterateErrors();
        while (errors.next()) |err| {
            const loc = err.getLocation(self);
            const msg = err.fmtMessage(self);
            try writer.print("{}:{}: error: {}\n", .{ loc.line + 1, loc.column + 1, msg });

            var notes = err.iterateNotes(self);
            while (notes.next()) |note| {
                const note_loc = note.getLocation(self);
                const note_msg = note.fmtMessage(self);
                try writer.print("{}:{}: note: {s}\n", .{
                    note_loc.line + 1,
                    note_loc.column + 1,
                    note_msg,
                });
            }
        }
    }
}