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.
Zig › std/ › zig/ › ZonGen.zig › lowerAstErrors
lowerAstErrors
ZonGen.lowerAstErrors
fn lowerAstErrors (zg : *ZonGen ) Allocator .Error !void
File
Code
fn lowerAstErrors (zg : *ZonGen ) Allocator .Error !void {
const gpa = zg .gpa ;
const tree = zg .tree ;
assert (tree .errors .len > 0 );
var msg : Writer .Allocating = .init (gpa );
defer msg .deinit ();
const msg_bw = &msg .writer ;
var notes : std .ArrayList (Zoir .CompileError .Note ) = .empty ;
defer notes .deinit (gpa );
var cur_err = tree .errors [0 ];
for (tree .errors [1 ..]) |err | {
if (err .is_note ) {
tree .renderError (err , msg_bw ) catch return error .OutOfMemory ;
try notes .append (gpa , try zg .errNoteTok (err .token , "{s}" , .{msg .written ()}));
} else {
tree .renderError (cur_err , msg_bw ) catch return error .OutOfMemory ;
const extra_offset = tree .errorOffset (cur_err );
try zg .addErrorTokNotesOff (cur_err .token , extra_offset , "{s}" , .{msg .written ()}, notes .items );
notes .clearRetainingCapacity ();
cur_err = err ;
// mechanisms, so the remaining errors could be bogus. As such,
// we'll ignore all remaining errors for now. We should improve
// `Parse` so that we can report all the errors.
return ;
}
msg .clearRetainingCapacity ();
}
const extra_offset = tree .errorOffset (cur_err );
tree .renderError (cur_err , msg_bw ) catch return error .OutOfMemory ;
try zg .addErrorTokNotesOff (cur_err .token , extra_offset , "{s}" , .{msg .written ()}, notes .items );
}