feat: support enums, distinct types, unions and matching
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user