Add or_break and or_continue constructs

This commit is contained in:
gingerBill
2023-09-30 15:04:17 +01:00
parent 4e97b83312
commit 648b83d6ea
11 changed files with 401 additions and 82 deletions

View File

@@ -52,6 +52,7 @@ gb_internal Token ast_token(Ast *node) {
case Ast_TernaryWhenExpr: return ast_token(node->TernaryWhenExpr.x);
case Ast_OrElseExpr: return ast_token(node->OrElseExpr.x);
case Ast_OrReturnExpr: return ast_token(node->OrReturnExpr.expr);
case Ast_OrBranchExpr: return ast_token(node->OrBranchExpr.expr);
case Ast_TypeAssertion: return ast_token(node->TypeAssertion.expr);
case Ast_TypeCast: return node->TypeCast.token;
case Ast_AutoCast: return node->AutoCast.token;
@@ -195,6 +196,11 @@ Token ast_end_token(Ast *node) {
case Ast_TernaryWhenExpr: return ast_end_token(node->TernaryWhenExpr.y);
case Ast_OrElseExpr: return ast_end_token(node->OrElseExpr.y);
case Ast_OrReturnExpr: return node->OrReturnExpr.token;
case Ast_OrBranchExpr:
if (node->OrBranchExpr.label != nullptr) {
return ast_end_token(node->OrBranchExpr.label);
}
return node->OrBranchExpr.token;
case Ast_TypeAssertion: return ast_end_token(node->TypeAssertion.type);
case Ast_TypeCast: return ast_end_token(node->TypeCast.expr);
case Ast_AutoCast: return ast_end_token(node->AutoCast.expr);