Root Token
This commit is contained in:
+4
-8
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user