improve diagnostic formatting

This commit is contained in:
Michael Sippel 2024-06-11 15:16:05 +02:00
parent f5f22ad65d
commit 541702de55
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -54,21 +54,21 @@ fn print_diagnostic(
// display the source line
for (j,ll) in last_lines.iter() {
print!("{}\t{}{}",
format!("{}",j).to_string().bright_white(),
"|".yellow().bold(),
ll.white());
format!("{}",j).to_string().bright_black(),
"|".bright_black().bold(),
ll.bright_white());
}
print!("\t{}", "|".yellow().bold());
print!("\t{}", "|".bright_magenta());
for _ in 0..column_begin { print!("{}", ".".magenta().bold()); }
for _ in column_begin..column_end { print!("{}", "^".magenta().bold()); }
print!("\n");
print!("{} [{}-{}]: {}\n", "error".bright_red(), column_begin, column_end, message);
print!("{} [{}-{}]: {}\n", "error".bright_red(), column_begin, column_end, message.white());
}
else if next_lines > 0 {
next_lines -= 1;
print!("{}:\t{}{}", format!("{}", i+1).to_string().bright_white(), "|".yellow().bold(), l.white());
print!("{}\t{}{}", format!("{}", i+1).to_string().bright_black(), "|".bright_black().bold(), l.bright_white());
}
line_region.begin = line_region.end;
@ -126,7 +126,11 @@ fn main() {
.into_asm(&path);
for (region, message) in diagnostics {
print_diagnostic(path.as_str(), region, message);
print_diagnostic(
path.as_str(),
region,
format!("{}", message)
);
}
eprintln!("{} {}", "Compiled".green(), path.bold());