Fix if parsing bug

This commit is contained in:
Krzosa Karol
2022-06-03 15:38:29 +02:00
parent dd8fbc20ed
commit 14af46125d
3 changed files with 6 additions and 2 deletions

View File

@@ -240,7 +240,7 @@ gen_ast(Ast *ast){
For(node->ifs){
if(it->init) gen_expr(it->init);
if(node->ifs.is_first(&it)){
genln("if(");
gen("if(");
gen_expr(it->expr);
gen(")");
gen_block(it->block);

View File

@@ -218,6 +218,7 @@ parse_block(){
if(token_match(TK_Comma)) expr = parse_expr();
else expr = 0;
}
if(init_val == expr) init_val = 0;
Ast_Block *if_block = parse_block();
Ast_If_Node *if_node = ast_if_node(token, init_val, expr, if_block);

View File

@@ -26,7 +26,10 @@ binary_test :: ()
boolean_var: Bool = boolean_equals
bvar2 := int_val > 1
bvar3 := int_val < 1
if int_val < 1
if int_val > 1
pass
basic_type_assignment :: ()