feat: support enums, distinct types, unions and matching

This commit is contained in:
2026-10-25 23:16:09 +01:00
parent 280059d83d
commit 9966a1f523
23 changed files with 3049 additions and 176 deletions
+7 -6
View File
@@ -34,6 +34,11 @@ keywords strmap.StaticStringMap(TokenKind) :: strmap.init([
{ "or", .or },
{ "mut", .mut },
{ "struct", .struct },
{ "enum", .enum },
{ "union", .union },
{ "distinct", .distinct },
{ "alias", .alias },
{ "match", .match },
{ "import", .import },
{ "test", .test },
])
@@ -85,7 +90,6 @@ scan proc(
if char == '#' {
while (cursor < program.len and program[cursor] != '\n') cursor += 1
if (cursor < program.len) cursor += 1
continue
}
@@ -352,12 +356,9 @@ scan_ident proc(
cursor += 1
}
# don't intern keywords (already O(1) lookup via token kind)
kind :: strmap.get(&keywords, program[start..cursor]) orelse .ident
str_id :: if (kind == .ident)
try strpool.intern(pool, program[start..cursor])
else
strpool.no_str
# member contexts accept keywords and therefore need their interned spelling too.
str_id :: try strpool.intern(pool, program[start..cursor])
return ScanIdentResult{ end = cursor, kind = kind, str_id = str_id }
}