]> www.git.momoyon.org Git - lang.git/commitdiff
[main.c] Lex null.
authorahmedsamyh <ahmedsamyh10@gmail.com>
Tue, 8 Apr 2025 22:46:54 +0000 (03:46 +0500)
committerahmedsamyh <ahmedsamyh10@gmail.com>
Tue, 8 Apr 2025 23:51:45 +0000 (04:51 +0500)
main.c

diff --git a/main.c b/main.c
index 4ac64d30635ba7ba12837baf73cb83892d4e3339..ac183c0c1fa44a7852f047bfb0861ff0ae98f073 100644 (file)
--- a/main.c
+++ b/main.c
@@ -53,6 +53,7 @@ typedef enum {
     TK_STRING,
 
     TK_BOOL,
+    TK_NULL,
 
     TK_LEFT_PAREN,
     TK_RIGHT_PAREN,
@@ -169,6 +170,7 @@ const char *token_type_as_str(Token_type t) {
         case TK_MULTILINE_COMMENT: return "MULTILINE_COMMENT";
         case TK_STRING: return "STRING";
         case TK_BOOL: return "BOOL";
+        case TK_NULL: return "NULL";
         case TK_LEFT_PAREN: return "LEFT_PAREN";
         case TK_RIGHT_PAREN: return "RIGHT_PAREN";
         case TK_MINUS: return "MINUS";
@@ -577,6 +579,8 @@ bool next_token(Lexer *l, Token *t_out) {
         t_out->type   = (is_keyword(ident_sv) ? TK_KEYWORD : TK_IDENT);
         if (sv_equals(ident_sv, SV("true")) || sv_equals(ident_sv, SV("false"))) {
             t_out->type = TK_BOOL;
+        } else if (sv_equals(ident_sv, SV("null"))) {
+            t_out->type = TK_NULL;
         }
         if (DEBUG_PRINT) {
             print_token(stdout, *t_out);