Added unary ++ --, prefix and postfix, working on running a program

This commit is contained in:
Krzosa Karol
2022-06-07 09:05:02 +02:00
parent d3da979d64
commit c5b82c0532
6 changed files with 51 additions and 15 deletions

View File

@@ -132,8 +132,10 @@ gen_expr(Ast_Expr *ast){
}
CASE(UNARY, Unary){
gen("(%s", name(node->op));
gen("(");
if(node->op != TK_PostIncrement && node->op != TK_PostDecrement) gen("%s", name(node->op));
gen_expr(node->expr);
if(node->op == TK_PostIncrement || node->op == TK_PostDecrement) gen("%s", name(node->op));
gen(")");
BREAK();
}
@@ -388,7 +390,11 @@ gen_ast(Ast *ast){
BREAK();
}
invalid_default_case;
default: {
assert(is_flag_set(ast->flags, AST_EXPR));
gen_expr((Ast_Expr *)ast);
gen(";");
}
}
}