aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c4
-rw-r--r--src/parse.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 34f6c23..f02a38c 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -87,6 +87,10 @@ static void codegen_unary_expr(CodeGen* g, AstNode* ast) {
fprintf(g->out, " sete al\n");
fprintf(g->out, " movzb rax, al\n");
fprintf(g->out, " push rax\n");
+ } else if (ast->node_op == TokenKind_tilde) {
+ fprintf(g->out, " pop rax\n");
+ fprintf(g->out, " not rax\n");
+ fprintf(g->out, " push rax\n");
} else {
unreachable();
}
diff --git a/src/parse.c b/src/parse.c
index 80c7aac..b82c45d 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -547,6 +547,9 @@ static AstNode* parse_prefix_expr(Parser* p) {
} else if (consume_token_if(p, TokenKind_not)) {
AstNode* operand = parse_prefix_expr(p);
return ast_new_unary_expr(op, operand);
+ } else if (consume_token_if(p, TokenKind_tilde)) {
+ AstNode* operand = parse_prefix_expr(p);
+ return ast_new_unary_expr(op, operand);
} else if (consume_token_if(p, TokenKind_and)) {
AstNode* operand = parse_prefix_expr(p);
return ast_new_ref_expr(operand);