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.

parseCCondExpr

MacroTranslator.parseCCondExpr
fn parseCCondExpr(mt: *MacroTranslator, scope: *Scope) ParseError!ZigNode

File

lib/compiler/translate-c/MacroTranslator.zig:735

Code

fn parseCCondExpr(mt: *MacroTranslator, scope: *Scope) ParseError!ZigNode {
    const condition = try mt.parseCOrExpr(scope);
    if (!mt.eat(.question_mark)) return condition;
    const bool_ty = try ZigTag.type.create(mt.t.arena, "bool");
    const node = try mt.t.createHelperCallNode(.cast, &.{ bool_ty, condition });

    const then_body = try mt.parseCOrExpr(scope);
    try mt.expect(.colon);
    const else_body = try mt.parseCCondExpr(scope);
    return ZigTag.@"if".create(mt.t.arena, .{ .cond = node, .then = then_body, .@"else" = else_body });
}