improve diagnostic formatting
This commit is contained in:
parent
f5f22ad65d
commit
541702de55
1 changed files with 11 additions and 7 deletions
18
src/main.rs
18
src/main.rs
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue