aboutsummaryrefslogtreecommitdiffstats
path: root/src/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer.c')
-rw-r--r--src/lexer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lexer.c b/src/lexer.c
index e5bea2e..36a5636 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -27,6 +27,7 @@ typedef enum TokenKind {
27 TOK_FALSE, // false 27 TOK_FALSE, // false
28 TOK_FUN, // fun 28 TOK_FUN, // fun
29 TOK_IF, // if 29 TOK_IF, // if
30 TOK_ELSE, // else
30 TOK_LET, // let 31 TOK_LET, // let
31 TOK_MATCH, // match 32 TOK_MATCH, // match
32 TOK_NIL, // nil 33 TOK_NIL, // nil
@@ -93,6 +94,7 @@ Str token_str[] = {
93 [TOK_BREAK] = cstr("BREAK"), 94 [TOK_BREAK] = cstr("BREAK"),
94 [TOK_CASE] = cstr("CASE"), 95 [TOK_CASE] = cstr("CASE"),
95 [TOK_CONTINUE] = cstr("CONTINUE"), 96 [TOK_CONTINUE] = cstr("CONTINUE"),
97 [TOK_ELSE] = cstr("ELSE"),
96 [TOK_FALSE] = cstr("FALSE"), 98 [TOK_FALSE] = cstr("FALSE"),
97 [TOK_FUN] = cstr("FUN"), 99 [TOK_FUN] = cstr("FUN"),
98 [TOK_IF] = cstr("IF"), 100 [TOK_IF] = cstr("IF"),
@@ -539,6 +541,11 @@ scan_token(Scanner *scanner) {
539 return emit_token(current, scanner, TOK_CONTINUE); 541 return emit_token(current, scanner, TOK_CONTINUE);
540 } 542 }
541 } break; 543 } break;
544 case 'e': {
545 if (str_has_prefix(val, cstr("else"))) {
546 return emit_token(current, scanner, TOK_ELSE);
547 }
548 } break;
542 case 'f': { 549 case 'f': {
543 if (str_has_prefix(val, cstr("false"))) { 550 if (str_has_prefix(val, cstr("false"))) {
544 return emit_token(current, scanner, TOK_FALSE); 551 return emit_token(current, scanner, TOK_FALSE);