Root Token

This commit is contained in:
2026-07-13 14:56:06 +02:00
parent f875b2917a
commit d48c508f31
3 changed files with 23 additions and 19 deletions
+4 -8
View File
@@ -10,11 +10,13 @@ read_stdin :: proc() -> []string {
return strings.split_lines(content)
}
print_token :: proc(token: Token, depth: int) {
print_token :: proc(token: Token, depth: int = 0) {
indent := strings.repeat(" ", depth, context.temp_allocator)
type_str := ""
switch token.type {
case TokenType.Root:
type_str = "Root"
case TokenType.Text:
type_str = "Text"
case TokenType.Italics:
@@ -49,14 +51,8 @@ print_token :: proc(token: Token, depth: int) {
}
}
print_token_tree :: proc(tokens: [dynamic]Token) {
for token in tokens {
print_token(token, 0)
}
}
main :: proc() {
lines := read_stdin()
parsed := parse(lines)
print_token_tree(parsed)
print_token(parsed)
}