parse await and suspend syntax

See #727
This commit is contained in:
Andrew Kelley
2018-02-26 00:04:11 -05:00
parent 6fef7406c8
commit c60496a297
6 changed files with 139 additions and 6 deletions

View File

@@ -246,6 +246,10 @@ static const char *node_type_str(NodeType node_type) {
return "ErrorSetDecl";
case NodeTypeCancel:
return "Cancel";
case NodeTypeAwaitExpr:
return "AwaitExpr";
case NodeTypeSuspend:
return "Suspend";
}
zig_unreachable();
}
@@ -1045,6 +1049,23 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
render_node_grouped(ar, node->data.cancel_expr.expr);
break;
}
case NodeTypeAwaitExpr:
{
fprintf(ar->f, "await ");
render_node_grouped(ar, node->data.await_expr.expr);
break;
}
case NodeTypeSuspend:
{
fprintf(ar->f, "suspend");
if (node->data.suspend.block != nullptr) {
fprintf(ar->f, " |");
render_node_grouped(ar, node->data.suspend.promise_symbol);
fprintf(ar->f, "| ");
render_node_grouped(ar, node->data.suspend.block);
}
break;
}
case NodeTypeFnDecl:
case NodeTypeParamDecl:
case NodeTypeTestDecl: