From 9a63dcca115a6aec031d5409459d0c3709f19695 Mon Sep 17 00:00:00 2001 From: dimgigov Date: Wed, 10 Jun 2026 20:08:20 +0300 Subject: [PATCH] fix(diag): remove parser diag printing, fix String_CharAt and sourceName issues --- src/cli.bux | 27 ++++----------------------- src/parser.bux | 29 ----------------------------- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/src/cli.bux b/src/cli.bux index b906def..61e99f3 100644 --- a/src/cli.bux +++ b/src/cli.bux @@ -47,27 +47,8 @@ struct Diagnostic { func Diagnostic_GetLine(path: String, lineNum: uint32) -> String { let content: String = bux_read_file(path); if String_Eq(content, "") { return ""; } - - var currentLine: uint32 = 1; - var pos: uint = 0; - let len: uint = String_Len(content); - - /* Skip lines until we reach lineNum */ - while currentLine < lineNum && pos < len { - if String_CharAt(content, pos) == 10 { /* '\n' */ - currentLine = currentLine + 1; - } - pos = pos + 1; - } - - /* Collect characters until newline or EOF */ - var buf: String = ""; - while pos < len && String_CharAt(content, pos) != 10 { - buf = String_Concat(buf, String_FromChar(String_CharAt(content, pos) as int)); - pos = pos + 1; - } - - return buf; + /* bux_str_split_part uses 0-based index */ + return bux_str_split_part(content, "\n", lineNum - 1); } /* Print a diagnostic in Rust-style format: @@ -344,7 +325,7 @@ func Cli_Check(srcPath: String) -> int { column: sema.diags[i].column, severity: 0, }; - Diagnostic_Print(&diag, sourceName); + Diagnostic_Print(&diag, srcPath); i = i + 1; } return 1; @@ -1096,7 +1077,7 @@ func Cli_BuildProject(projectDir: String) -> int { column: sema.diags[i].column, severity: 0, }; - Diagnostic_Print(&diag, sourceName); + Diagnostic_Print(&diag, ""); i = i + 1; } return 1; diff --git a/src/parser.bux b/src/parser.bux index d2c9b70..db1c3a5 100644 --- a/src/parser.bux +++ b/src/parser.bux @@ -1773,35 +1773,6 @@ func Parser_Parse(tokens: *LexToken, tokenCount: int) -> *Module { } } - /* Print parser diagnostics */ - if p.diagCount > 0 { - var di: int = 0; - while di < p.diagCount { - let d: ParserDiag = p.diags[di]; - Print("error: "); - PrintLine(d.message); - Print(" --> :"); - PrintInt(d.line as int64); - Print(":"); - PrintInt(d.column as int64); - PrintLine(""); - Print(" |"); - PrintLine(""); - Print(" "); - PrintInt(d.line as int64); - Print(" | "); - PrintLine(""); - Print(" | "); - var sp: uint32 = 0; - while sp < d.column - 1 && sp < 120 { - Print(" "); - sp = sp + 1; - } - PrintLine("^"); - di = di + 1; - } - } - return mod; }