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 standard library.
std › zig › Parse › expectIf Private Function expectIf Doc Source Private Function std.zig.Parse.expectIf
fn expectIf (p : *Parse , comptime bodyParseFn : fn (p : *Parse ) Error !Node .Index ) !Node .Index Params File zig/Parse.zig: 3271
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302 fn expectIf (p : *Parse , comptime bodyParseFn : fn (p : *Parse ) Error !Node .Index ) !Node .Index {
const if_token = p .assertToken (.keyword_if );
_ = try p .expectToken (.l_paren );
const condition = try p .expectExpr ();
_ = try p .expectToken (.r_paren );
_ = try p .parsePtrPayload ();
const then_expr = try bodyParseFn (p );
_ = p .eatToken (.keyword_else ) orelse return try p .addNode (.{
.tag = .if_simple ,
.main_token = if_token ,
.data = .{ .node_and_node = .{
condition ,
then_expr ,
} },
});
_ = try p .parsePayload ();
const else_expr = try bodyParseFn (p );
return try p .addNode (.{
.tag = .@"if" ,
.main_token = if_token ,
.data = .{ .node_and_extra = .{
condition ,
try p .addExtra (Node .If {
.then_expr = then_expr ,
.else_expr = else_expr ,
}),
} },
});
}