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 › findNextContainerMember Private Function findNextContainerMember Doc Source Private Function std.zig.Parse.findNextContainerMember
fn findNextContainerMember (p : *Parse ) void Params File zig/Parse.zig: 515
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575 fn findNextContainerMember (p : *Parse ) void {
if (!p .recover ) {
while (p .tokenTag (p .tok_i ) != .eof ) {
p .tok_i += 1 ;
}
return ;
}
var level : u32 = 0 ;
while (true ) {
const tok = p .nextToken ();
switch (p .tokenTag (tok )) {
// Any of these can start a new top level declaration.
.keyword_test ,
.keyword_comptime ,
.keyword_pub ,
.keyword_export ,
.keyword_extern ,
.keyword_inline ,
.keyword_noinline ,
.keyword_threadlocal ,
.keyword_const ,
.keyword_var ,
.keyword_fn ,
=> {
if (level == 0 ) {
p .tok_i -= 1 ;
return ;
}
},
.identifier => {
if (p .tokenTag (tok + 1 ) == .comma and level == 0 ) {
p .tok_i -= 1 ;
return ;
}
},
.comma , .semicolon => {
// this decl was likely meant to end here
if (level == 0 ) {
return ;
}
},
.l_paren , .l_bracket , .l_brace => level += 1 ,
.r_paren , .r_bracket => {
if (level != 0 ) level -= 1 ;
},
.r_brace => {
if (level == 0 ) {
// end of container, exit
p .tok_i -= 1 ;
return ;
}
level -= 1 ;
},
.eof => {
p .tok_i -= 1 ;
return ;
},
else => {},
}
}
}
Attempts to find next container member by searching for certain tokens