strings handled as built-in struct, and added immutable keyword

This commit is contained in:
uan
2026-02-07 11:06:55 +01:00
parent c0bbb82e71
commit 99d63ff769
4 changed files with 62 additions and 28 deletions

View File

@@ -5,6 +5,7 @@ import term
enum TokenType as u8 {
kw_let
kw_const
kw_immutable
type
kw_if
kw_else
@@ -108,6 +109,7 @@ fn toktype_from_kw(kw string) TokenType {
'true', 'false' {.boolean}
'print' {.kw_print}
'class' {.kw_class}
'immutable' {.kw_immutable}
else {.unknown}
}
}
@@ -127,7 +129,7 @@ fn is_real(str string) bool {
fn is_keyword(str string) bool {
return [
"void", "int", "real", "bool", "string", "if", "else", "elif", "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", "immutable"
].contains(str)
}