lexer touchups

This commit is contained in:
2026-08-05 08:53:51 +02:00
parent a2ccf60eb1
commit 1689c4db3c
4 changed files with 113 additions and 81 deletions
+19
View File
@@ -48,3 +48,22 @@ NodeKind :: enum {
invalid
}
# todo: render ast nodes as source code
render proc(node @Node, tokens []Token) void { }
render_literal proc(node @Node, tokens []Token, program []u8) []u8 ! lexer.ScanError {
tok :: tokens[node.main_token]
match node.kind {
.literal_int, .literal_float: {
result :: try lexer.scan_number(tok.start, program)
return program[tok.start..result.end]
}
.literal_string: {
result :: try lexer.scan_string(tok.start, program)
return program[tok.start..result.end]
}
else: unreachable
}
}