Root pointer instead of a loop
This commit is contained in:
+1
-6
@@ -1,6 +1,5 @@
|
||||
package main
|
||||
|
||||
import "core:fmt"
|
||||
import "core:strings"
|
||||
|
||||
TokenType :: enum {
|
||||
@@ -26,8 +25,6 @@ Token :: struct {
|
||||
parent: ^Token,
|
||||
}
|
||||
|
||||
current_token: ^Token
|
||||
|
||||
replace_text :: proc(text: string, start: int, len_: int, repl: string) -> string {
|
||||
builder := strings.builder_make(context.temp_allocator)
|
||||
strings.write_string(&builder, text[:start])
|
||||
@@ -60,9 +57,7 @@ parse :: proc(lines: []string, allocator := context.allocator) -> Token {
|
||||
|
||||
if len(line) == 0 {
|
||||
if line_index != len(lines) - 1 {
|
||||
for current_token.parent != nil {
|
||||
current_token = current_token.parent
|
||||
}
|
||||
current_token = &root
|
||||
|
||||
append(
|
||||
¤t_token.children,
|
||||
|
||||
Reference in New Issue
Block a user