From c55f2311d3c618187ad17804417cb7aec127cc6f Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 9 Jul 2025 22:19:53 +0200 Subject: Parse unary reference and dereference operators Signed-off-by: Mel --- boot/tree.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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`"); -- cgit 1.4.1