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 › compiler/ › translate-c/ › MacroTranslator.zig › parseCCastExpr
parseCCastExpr
MacroTranslator.parseCCastExpr
fn parseCCastExpr (mt : *MacroTranslator , scope : *Scope ) ParseError !ZigNode
File
Code
fn parseCCastExpr (mt : *MacroTranslator , scope : *Scope ) ParseError !ZigNode {
if (mt .eat (.l_paren )) {
if (try mt .parseCTypeName (scope )) |type_name | {
while (true ) {
const next_tok = mt .peek ();
if (next_tok == .r_paren ) {
mt .i += 1 ;
break ;
}
if ((next_tok == .identifier or next_tok == .extended_identifier ) and
mt .t .global_scope .blank_macros .contains (mt .tokSlice ()))
{
mt .i += 1 ;
continue ;
}
try mt .fail (
"unable to translate C expr: expected ')' instead got '{s}'" ,
.{next_tok .symbol ()},
);
return error .ParseError ;
}
if (mt .peek () == .l_brace ) {
return mt .parseCPostfixExpr (scope , type_name );
}
const node_to_cast = try mt .parseCCastExpr (scope );
return mt .t .createHelperCallNode (.cast , &.{ type_name , node_to_cast });
}
mt .i -= 1 ;
}
return mt .parseCUnaryExpr (scope );
}