aboutsummaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-01-27 23:02:55 +0000
committerGinger Bill <bill@gingerbill.org>2017-01-27 23:02:55 +0000
commit31aacd5bf435224c7d8f9b19359175d3e6d25660 (patch)
treeab9d62de198d9874e1afb7212ab3feb46fde4f01 /src/parser.c
parent92453369c5558feaaaa116fbc54968b087e1aeab (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.c13
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);