diff options
| author | hachem <im@hachem.wtf> | 2026-09-04 20:00:52 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-04 20:00:52 +0200 |
| commit | 9283b46a08a1c58c321b6c7ebad1353725c3bc47 (patch) | |
| tree | 5fba917f42bdbaf86f27abc01577b3c1b232e409 /src/lexer | |
| parent | 56ba8b2a373dd1386950592bda9c68ff9f25c203 (diff) | |
feat: add if/else blocks
if now guards a { } block or bare statement with an optional else (and
now else-if chaining). The branch body becomes a statement list; a bare
guarded statement is a list of length one.
Diffstat (limited to 'src/lexer')
| -rw-r--r-- | src/lexer/lexer.c | 2 | ||||
| -rw-r--r-- | src/lexer/lexer.h | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 01bbd41..e08a458 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -38,6 +38,7 @@ static enum TokenType identifier_type(const char* start, size_t length) { "struct", 6, TOKEN_STRUCT }, { "stack", 5, TOKEN_STACK }, { "if", 2, TOKEN_IF }, + { "else", 4, TOKEN_ELSE }, { "goto", 4, TOKEN_GOTO }, { "syscall", 7, TOKEN_SYSCALL }, { "byte", 4, TOKEN_BYTE }, @@ -265,6 +266,7 @@ const char* token_type_name(enum TokenType type) case TOKEN_STRUCT: return "struct"; case TOKEN_STACK: return "stack"; case TOKEN_IF: return "if"; + case TOKEN_ELSE: return "else"; case TOKEN_GOTO: return "goto"; case TOKEN_SYSCALL: return "syscall"; case TOKEN_BYTE: return "byte"; diff --git a/src/lexer/lexer.h b/src/lexer/lexer.h index 45e9b3d..2bc43e0 100644 --- a/src/lexer/lexer.h +++ b/src/lexer/lexer.h @@ -19,6 +19,7 @@ enum TokenType TOKEN_STRUCT, TOKEN_STACK, TOKEN_IF, + TOKEN_ELSE, TOKEN_GOTO, TOKEN_SYSCALL, TOKEN_BYTE, |
