summaryrefslogtreecommitdiff
path: root/src/lexer.c
diff options
context:
space:
mode:
authorCarlos Maniero <carlos@maniero.me>2023-05-08 23:53:41 -0300
committerJohnny Richard <johnny@johnnyrichard.com>2023-05-09 08:50:53 +0200
commitaba7302e7e98fd7bca2056d8ad622d9ca81c495f (patch)
tree59b4de4d4946f622b97ca7b6e1ded4d1e9cebbe5 /src/lexer.c
parentccd5e8585f10488eed72c772cc1804efea6b8fb4 (diff)
parser: Add the bool type
This commit introduces a new type for booleans. There is no code generation for this type yet. The intention of this commit is to enable flow control in the near future. Signed-off-by: Carlos Maniero <carlos@maniero.me> Reviewed-by: Johnny Richard <johnny@johnnyrichard.com>
Diffstat (limited to 'src/lexer.c')
-rw-r--r--src/lexer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lexer.c b/src/lexer.c
index 72c27cd..f84163d 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -111,6 +111,14 @@ lexer_token_process_keyword(token_t *token)
token->kind = TOKEN_KEYWORD_FN;
return;
}
+ if (string_view_eq(string_view_from_str("true"), token->value)) {
+ token->kind = TOKEN_TRUE;
+ return;
+ }
+ if (string_view_eq(string_view_from_str("false"), token->value)) {
+ token->kind = TOKEN_FALSE;
+ return;
+ }
}
void
@@ -454,6 +462,10 @@ token_kind_to_str(token_kind_t kind)
return "fn";
case TOKEN_KEYWORD_LET:
return "let";
+ case TOKEN_TRUE:
+ return "true";
+ case TOKEN_FALSE:
+ return "false";
case TOKEN_EOF:
return "TOKEN_EOF";
case TOKEN_UNKNOWN: