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.

expectStatementRecoverable

If a parse error occurs, reports an error, but then finds the next statement and returns that one instead. If a parse error occurs but there is no following statement, returns null.

Parse.expectStatementRecoverable
fn expectStatementRecoverable(p: *Parse) Error!?Node.Index

File

lib/std/zig/Parse.zig:1135

Code

fn expectStatementRecoverable(p: *Parse) Error!?Node.Index {
    while (true) {
        return p.expectStatement(true) catch |err| switch (err) {
            error.OutOfMemory => |e| return e,
            error.ParseError => {
                p.findNextStmt(); // Try to skip to the next statement.
                switch (p.tokenTag(p.tok_i)) {
                    .r_brace => return null,
                    .eof => return error.ParseError,
                    else => continue,
                }
            },
        };
    }
}