diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-27 23:02:55 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-27 23:02:55 +0000 |
| commit | 31aacd5bf435224c7d8f9b19359175d3e6d25660 (patch) | |
| tree | ab9d62de198d9874e1afb7212ab3feb46fde4f01 /src/parser.c | |
| parent | 92453369c5558feaaaa116fbc54968b087e1aeab (diff) | |
Fix parsing for block/if expression within if/for/etc. statementsv0.0.6
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/parser.c b/src/parser.c index 0a9b39ea9..eac6fbd68 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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); |