summaryrefslogtreecommitdiff
path: root/src/lexer.c
diff options
context:
space:
mode:
authorCarlos Maniero <carlos@maniero.me>2023-05-09 16:18:18 -0300
committerJohnny Richard <johnny@johnnyrichard.com>2023-05-09 22:54:46 +0200
commitad54ee1182b1549880eddc8b1969d3992d9f7f1d (patch)
tree34d6a33a6a5ccba3ff6198d0e49f1e1d4701fc27 /src/lexer.c
parent8c8fc8cc30b38ef00d606a4991b655df97a52fb6 (diff)
parser: parses an if statement no code generation
This commit parses a if statement following the grammar bellow: if boolean_expression { n_epressions; } No else neither code generation was implemented. Signed-off-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'src/lexer.c')
-rw-r--r--src/lexer.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lexer.c b/src/lexer.c
index f84163d..a6c8ae2 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -111,6 +111,10 @@ lexer_token_process_keyword(token_t *token)
token->kind = TOKEN_KEYWORD_FN;
return;
}
+ if (string_view_eq(string_view_from_str("if"), token->value)) {
+ token->kind = TOKEN_KEYWORD_IF;
+ return;
+ }
if (string_view_eq(string_view_from_str("true"), token->value)) {
token->kind = TOKEN_TRUE;
return;
@@ -462,6 +466,8 @@ token_kind_to_str(token_kind_t kind)
return "fn";
case TOKEN_KEYWORD_LET:
return "let";
+ case TOKEN_KEYWORD_IF:
+ return "if";
case TOKEN_TRUE:
return "true";
case TOKEN_FALSE: