Got all programs working, now adding unary not and neg

This commit is contained in:
Krzosa Karol
2022-06-03 17:58:20 +02:00
parent 25820a0c5b
commit 42699034ae
6 changed files with 84 additions and 55 deletions

View File

@@ -315,6 +315,8 @@ binding_power(Binding binding, Token_Kind kind){
case TK_OpenParen:
case TK_Sub:
case TK_Add:
case TK_Neg:
case TK_Not:
return{-2, 20};
default: return {-1, -1};
}
@@ -370,6 +372,8 @@ parse_expr(S64 min_bp){
case TK_Dereference: left = ast_expr_unary(token, TK_Dereference, parse_expr(prefix_bp.right)); break;
case TK_Sub : left = ast_expr_unary(token, TK_Sub, parse_expr(prefix_bp.right)); break;
case TK_Add : left = ast_expr_unary(token, TK_Add, parse_expr(prefix_bp.right)); break;
case TK_Not : left = ast_expr_unary(token, TK_Not, parse_expr(prefix_bp.right)); break;
case TK_Neg : left = ast_expr_unary(token, TK_Neg, parse_expr(prefix_bp.right)); break;
case TK_OpenBracket: {
Ast_Array *result = ast_array(token, parse_expr(0));