Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

parseLabeledStatement

Private Function
std.zig.Parse.parseLabeledStatement
fn parseLabeledStatement(p: *Parse) !?Node.Index

Params

File

zig/Parse.zig:1208
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
fn parseLabeledStatement(p: *Parse) !?Node.Index {
    const opt_label_token = p.parseBlockLabel();

    if (try p.parseBlock()) |block| return block;
    if (try p.parseLoopStatement()) |loop_stmt| return loop_stmt;
    if (try p.parseSwitchExpr(opt_label_token != null)) |switch_expr| return switch_expr;

    const label_token = opt_label_token orelse return null;

    const after_colon = p.tok_i;
    // Don't bother trying to give a better error message if recovery is disabled.
    // This avoids a possible stack overflow in e.g. parseTypeExpr() when fuzzing.
    if (p.recover) {
        if (try p.parseTypeExpr()) |_| {
            const a = try p.parseByteAlign();
            const b = try p.parseAddrSpace();
            const c = try p.parseLinkSection();
            const d = if (p.eatToken(.equal) == null) null else try p.expectExpr();
            if (a != null or b != null or c != null or d != null) {
                return p.failMsg(.{ .tag = .expected_var_const, .token = label_token });
            }
        }
    }
    return p.failMsg(.{ .tag = .expected_labelable, .token = after_colon });
}