From: ahmedsamyh Date: Tue, 8 Apr 2025 22:41:40 +0000 (+0500) Subject: [main.c] Lex bools. X-Git-Url: https://www.git.momoyon.org/?a=commitdiff_plain;h=a3ea9f5d32d55474989ab8dc41d2e3540a783a5d;p=lang.git [main.c] Lex bools. --- diff --git a/main.c b/main.c index 926da61..4ac64d3 100644 --- a/main.c +++ b/main.c @@ -52,6 +52,8 @@ typedef enum { TK_STRING, + TK_BOOL, + TK_LEFT_PAREN, TK_RIGHT_PAREN, TK_MINUS, @@ -166,6 +168,7 @@ const char *token_type_as_str(Token_type t) { case TK_COMMENT: return "COMMENT"; case TK_MULTILINE_COMMENT: return "MULTILINE_COMMENT"; case TK_STRING: return "STRING"; + case TK_BOOL: return "BOOL"; case TK_LEFT_PAREN: return "LEFT_PAREN"; case TK_RIGHT_PAREN: return "RIGHT_PAREN"; case TK_MINUS: return "MINUS"; @@ -572,6 +575,9 @@ bool next_token(Lexer *l, Token *t_out) { t_out->lexeme = ident_sv; t_out->loc = ident_loc; 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; + } if (DEBUG_PRINT) { print_token(stdout, *t_out); putc('\n', stdout);