From 530bd872610f295220c03882c82abbf6b162f8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domas=20Tama=C5=A1auskas?= Date: Sat, 18 Jul 2026 23:29:19 +0300 Subject: [PATCH] Implement parser loop --- tests/token.odin | 1 - token/parser.odin | 2 +- token/token.odin | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/token.odin b/tests/token.odin index b09dcff..771a0f1 100644 --- a/tests/token.odin +++ b/tests/token.odin @@ -12,7 +12,6 @@ single_token :: proc(t: ^testing.T) { tests := []Test { {source = "~", token = {type = .Illegal}}, - {source = "", token = {type = .EndOfFile}}, {source = "x", token = {type = .Identifier}}, {source = "=", token = {type = .Assignment}}, {source = "+", token = {type = .Plus}}, diff --git a/token/parser.odin b/token/parser.odin index fa59913..a3ee76d 100644 --- a/token/parser.odin +++ b/token/parser.odin @@ -8,7 +8,7 @@ Parser :: struct { } read_symbol :: proc(p: ^Parser) { - if p.left >= len(p.input) { + if p.right >= len(p.input) { p.value = 0 } else { p.value = p.input[p.right] diff --git a/token/token.odin b/token/token.odin index 21b4386..1e5549a 100644 --- a/token/token.odin +++ b/token/token.odin @@ -26,7 +26,6 @@ parse :: proc(input: string, allocator := context.allocator) -> [dynamic]Token { input = input, } tokens := make([dynamic]Token, allocator) - token := next(&parser) - append(&tokens, token) + for token := next(&parser); token.type != .EndOfFile; token = next(&parser) do append(&tokens, token) return tokens } -- 2.51.2