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