checkpoint

This commit is contained in:
2026-07-20 08:57:12 +02:00
parent a4e6f96951
commit 0338e35e75
9 changed files with 284 additions and 127 deletions
+27 -8
View File
@@ -1,13 +1,16 @@
import "@std"
import "@std/debug"
import "@std/mem"
import "@std/arraylist"
test import "@std/enums"
test import "@std/arraylist"
test import "@std/hashmap"
test import "@std/static_string_map"
import "@source/strpool"
import "@source/lexer"
test import "@source/strpool"
program ::
`# these are immutable
`x :: 32
@@ -15,21 +18,37 @@ program ::
`
`# these are mutable
`z u32 = 54
`
`# keywords
`if
`else
`for
`while
`func
`return
`
`main func() void {}
# cross-cutting concern, hence global singleton
strings StringPool = undefined
main func() void {
strings = strpool.init(mem.c_allocator)
defer strpool.deinit(&strings)
debug.print("PROGRAM::[[\n{}\n]]\n\n", {program})
tokens std.ArrayList(Token) = arraylist.init(mem.c_allocator)
defer arraylist.deinit(&tokens)
scan_state lexer.State = lexer.init(mem.c_allocator)
defer lexer.deinit(&scan_state)
scan(&tokens, program) catch |_| {
debug.print("failed to scan: out of memory\n", {})
lexer.scan(&scan_state, program) catch |err| {
debug.print("failed to scan: {}\n", {err})
return
}
debug.print("TOKENS::[[\n", {})
for tokens.items |token| {
debug.print("{}\n", { token.kind })
for scan_state.tokens.items |token| {
debug.print("{}\n", {token.kind})
}
debug.print("]]\n", {})
}