Fix parsing for block/if expression within if/for/etc. statements

This commit is contained in:
Ginger Bill
2017-01-27 23:02:55 +00:00
parent 92453369c5
commit 31aacd5bf4
10 changed files with 313 additions and 283 deletions
+8 -5
View File
@@ -1827,11 +1827,15 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
}
case Token_if:
if (lhs) goto error;
return parse_if_expr(f);
if (!lhs && f->expr_level >= 0) {
return parse_if_expr(f);
}
break;
case Token_OpenBrace:
if (lhs) goto error;
return parse_block_expr(f);
if (!lhs && f->expr_level >= 0) {
return parse_block_expr(f);
}
break;
default: {
AstNode *type = parse_identifier_or_type(f);
@@ -1846,7 +1850,6 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
}
}
error:
Token begin = f->curr_token;
syntax_error(begin, "Expected an operand");
fix_advance_to_next_stmt(f);