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 › parseCStyleContainer Private Function parseCStyleContainer Doc Source Private Function std.zig.Parse.parseCStyleContainer
fn parseCStyleContainer (p : *Parse ) Error !bool Params File zig/Parse.zig: 3128
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156 fn parseCStyleContainer (p : *Parse ) Error !bool {
if (!p .recover ) return false ;
const main_token = p .tok_i ;
switch (p .tokenTag (p .tok_i )) {
.keyword_enum , .keyword_union , .keyword_struct => {},
else => return false ,
}
const identifier = p .tok_i + 1 ;
if (p .tokenTag (identifier ) != .identifier ) return false ;
p .tok_i += 2 ;
try p .warnMsg (.{
.tag = .c_style_container ,
.token = identifier ,
.extra = .{ .expected_tag = p .tokenTag (main_token ) },
});
try p .warnMsg (.{
.tag = .zig_style_container ,
.is_note = true ,
.token = identifier ,
.extra = .{ .expected_tag = p .tokenTag (main_token ) },
});
_ = try p .expectToken (.l_brace );
_ = try p .parseContainerMembers ();
_ = try p .expectToken (.r_brace );
try p .expectSemicolon (.expected_semi_after_decl , true );
return true ;
}
Give a helpful error message for those transitioning from C's 'struct Foo {};' to Zig's 'const Foo = struct {};'.