Error -> errset (temporarily). Catch / throw now works, but it will not yet correctly handle defer.

This commit is contained in:
Christoffer Lerno
2020-05-03 02:04:13 +02:00
parent 78aa49cc0e
commit 373001fd12
23 changed files with 1268 additions and 209 deletions

View File

@@ -219,6 +219,7 @@ static Expr *parse_ternary_expr(Context *context, Expr *left_side)
Expr *false_expr = TRY_EXPR_OR(parse_precedence(context, PREC_TERNARY + 1), poisoned_expr);
expr_ternary->ternary_expr.else_expr = false_expr;
RANGE_EXTEND_PREV(expr_ternary);
return expr_ternary;
}
@@ -399,8 +400,20 @@ static Expr *parse_try_expr(Context *context, Expr *left)
Expr *try_expr = EXPR_NEW_TOKEN(EXPR_TRY, context->tok);
advance_and_verify(context, TOKEN_TRY);
try_expr->try_expr.expr = TRY_EXPR_OR(parse_precedence(context, PREC_TRY + 1), poisoned_expr);
try_expr->try_expr.type = TRY_EXPR_ELSE_EXPR;
if (try_consume(context, TOKEN_ELSE))
{
switch (context->tok.type)
{
case TOKEN_RETURN:
case TOKEN_BREAK:
case TOKEN_CONTINUE:
case TOKEN_THROW:
try_expr->try_expr.type = TRY_EXPR_ELSE_JUMP;
TODO
default:
break;
}
try_expr->try_expr.else_expr = TRY_EXPR_OR(parse_precedence(context, PREC_ASSIGNMENT), poisoned_expr);
}
return try_expr;