about summary refs log tree commit diff
path: root/boot/lex.c
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-06-03 01:46:34 +0200
committerMel <mel@rnrd.eu>2025-06-03 01:46:34 +0200
commitf4bcdb0373ac34349c6ecdb9a894c561e0cd419c (patch)
treeada9099eec92d0824b1943ff4ec453cc9682c2bd /boot/lex.c
parenta9b5fef2eb126500974a1cfe9ce4a8f7cc6e0490 (diff)
downloadcatskill-f4bcdb0373ac34349c6ecdb9a894c561e0cd419c.tar.zst
catskill-f4bcdb0373ac34349c6ecdb9a894c561e0cd419c.zip
Parse and lex ++, --, ** operators, with prefix and postfix handling
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/lex.c')
-rw-r--r--boot/lex.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/boot/lex.c b/boot/lex.c
index 37eabcd..30f4071 100644
--- a/boot/lex.c
+++ b/boot/lex.c
@@ -122,6 +122,10 @@ enum Token_Kind
     TOKEN_STAR,
     TOKEN_SLASH,
 
+    TOKEN_PLUS_PLUS,
+    TOKEN_MINUS_MINUS,
+    TOKEN_STAR_STAR,
+
     TOKEN_AND,
     TOKEN_OR,
     TOKEN_EQUAL,
@@ -239,6 +243,13 @@ token_kind_to_string(enum Token_Kind kind)
     case TOKEN_SLASH:
         return "SLASH";
 
+    case TOKEN_PLUS_PLUS:
+        return "PLUS_PLUS";
+    case TOKEN_MINUS_MINUS:
+        return "MINUS_MINUS";
+    case TOKEN_STAR_STAR:
+        return "STAR_STAR";
+
     case TOKEN_AND:
         return "AND";
     case TOKEN_OR:
@@ -582,20 +593,28 @@ lexer_symbol_token(struct Lexer* l, struct Lexer_Char current)
         if (a.got_match) RET{ TOKEN_ASSIGN_CARET, 2 };
         RET{ TOKEN_CARET, 1 };
     }
-    // todo: increment, decrement, power
     case '+': {
         a = lexer_match_char(l, '=');
         if (a.got_match) RET{ TOKEN_ASSIGN_PLUS, 2 };
+
+        a = lexer_match_char(l, '+');
+        if (a.got_match) RET{ TOKEN_PLUS_PLUS, 2 };
         RET{ TOKEN_PLUS, 1 };
     }
     case '-': {
         a = lexer_match_char(l, '=');
         if (a.got_match) RET{ TOKEN_ASSIGN_MINUS, 2 };
+
+        a = lexer_match_char(l, '-');
+        if (a.got_match) RET{ TOKEN_MINUS_MINUS, 2 };
         RET{ TOKEN_MINUS, 1 };
     }
     case '*': {
         a = lexer_match_char(l, '=');
         if (a.got_match) RET{ TOKEN_ASSIGN_STAR, 2 };
+
+        a = lexer_match_char(l, '*');
+        if (a.got_match) RET{ TOKEN_STAR_STAR, 2 };
         RET{ TOKEN_STAR, 1 };
     }
     case '/': {