control flow

This commit is contained in:
uan
2026-02-06 17:03:35 +01:00
parent db1b4b88c0
commit a09a642bb7
5 changed files with 80 additions and 22 deletions

View File

@@ -8,6 +8,7 @@ enum TokenType as u8 {
type
kw_if
kw_else
kw_elif
kw_for
kw_break
kw_fn
@@ -99,6 +100,7 @@ fn toktype_from_kw(kw string) TokenType {
'void', 'real', 'bool', 'int', 'string'{.type}
'if' {.kw_if}
'else' {.kw_else}
'elif' {.kw_elif}
'for' {.kw_for}
'break' {.kw_break}
'fn' {.kw_fn}
@@ -125,7 +127,7 @@ fn is_real(str string) bool {
fn is_keyword(str string) bool {
return [
"void", "int", "real", "bool", "string", "if", "else", "for", "break", "fn", "return", "let", "const", "true", "false", "print", "class"
"void", "int", "real", "bool", "string", "if", "else", "elif", "for", "break", "fn", "return", "let", "const", "true", "false", "print", "class"
].contains(str)
}