fix(diag): remove parser diag printing, fix String_CharAt and sourceName issues
This commit is contained in:
+4
-23
@@ -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, "<merged>");
|
||||
i = i + 1;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -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(" --> <input>:");
|
||||
PrintInt(d.line as int64);
|
||||
Print(":");
|
||||
PrintInt(d.column as int64);
|
||||
PrintLine("");
|
||||
Print(" |");
|
||||
PrintLine("");
|
||||
Print(" ");
|
||||
PrintInt(d.line as int64);
|
||||
Print(" | <source unavailable>");
|
||||
PrintLine("");
|
||||
Print(" | ");
|
||||
var sp: uint32 = 0;
|
||||
while sp < d.column - 1 && sp < 120 {
|
||||
Print(" ");
|
||||
sp = sp + 1;
|
||||
}
|
||||
PrintLine("^");
|
||||
di = di + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user