about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-07-09 22:19:53 +0200
committerMel <mel@rnrd.eu>2025-07-09 22:19:53 +0200
commitc55f2311d3c618187ad17804417cb7aec127cc6f (patch)
treec0a197af7832ee3e4659401cfb9547a14704228a
parent815869606771b0117dd7be657232ec6dfab136c4 (diff)
downloadcatskill-c55f2311d3c618187ad17804417cb7aec127cc6f.tar.zst
catskill-c55f2311d3c618187ad17804417cb7aec127cc6f.zip
Parse unary reference and dereference operators
Signed-off-by: Mel <mel@rnrd.eu>
-rw-r--r--boot/tree.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/boot/tree.c b/boot/tree.c
index 9ea9e6f..aab05eb 100644
--- a/boot/tree.c
+++ b/boot/tree.c
@@ -16,8 +16,10 @@ enum Unary_Operation
 
     UNARY_MINUS,
     UNARY_NOT,
-
     UNARY_BITWISE_NOT,
+
+    UNARY_REFERENCE,
+    UNARY_DEREFERENCE,
 };
 
 enum Unary_Operation
@@ -30,6 +32,10 @@ unary_operation_from_token(const struct Token* token)
         return UNARY_NOT;
     case TOKEN_TILDE:
         return UNARY_BITWISE_NOT;
+    case TOKEN_AMPERSAND:
+        return UNARY_REFERENCE;
+    case TOKEN_STAR:
+        return UNARY_DEREFERENCE;
 
     default:
         return UNARY_NONE;
@@ -46,6 +52,10 @@ unary_operation_to_string(enum Unary_Operation operation)
         return "!";
     case UNARY_BITWISE_NOT:
         return "~";
+    case UNARY_REFERENCE:
+        return "&";
+    case UNARY_DEREFERENCE:
+        return "*";
 
     default:
         failure("unexpected unary operation passed to `unary_operation_to_string`");