parse func decls

This commit is contained in:
2026-08-14 20:04:22 +02:00
parent 518037e7b7
commit cfd668b729
7 changed files with 397 additions and 85 deletions
+1
View File
@@ -202,6 +202,7 @@ scan proc(state @mut State, program []u8) void ! (mem.AllocError | strpool.Inter
# single character tokens
kind ?TokenKind :: match char {
'=': .equal
',': .comma
'(': .open_paren
')': .close_paren
'{': .open_curly
+7 -2
View File
@@ -43,6 +43,7 @@ TokenKind :: enum {
open_bracket, close_bracket
open_curly, close_curly
comma
colon
newline
@@ -54,8 +55,12 @@ TokenKind :: enum {
render_token proc(tok Token, program []u8) void {
match tok.kind {
.ident: {
str :: strpool.get_str(&strpool.STRINGS, tok.str_id) orelse "null"
debug.print("{}({})\n", {tok.kind, str})
if (strpool.get_str(&strpool.STRINGS, tok.str_id)) |str| {
debug.print("{}({})\n", {tok.kind, str})
} else {
res :: scan_ident(tok.start, program)
debug.print("{}({})\n", {tok.kind, program[tok.start..res.end]})
}
}
.string: {
res :: scan_string(tok.start, program) catch |_| {