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/ › Parse.zig › expectIf
expectIf
Parse.expectIf
fn expectIf (p : *Parse , comptime bodyParseFn : fn (p : *Parse ) Error !Node .Index ) !Node .Index
File
Code
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 ,
}),
} },
});
}