data-section #3

Merged
sashakoshka merged 42 commits from data-section into main 2022-08-17 12:21:20 -06:00
Showing only changes of commit 7fc51c278f - Show all commits

View File

@ -52,20 +52,30 @@ func (err Error) Error () (formattedMessage string) {
if err.width > 0 { if err.width > 0 {
// print erroneous line // print erroneous line
line := err.Location.file.lines[err.Location.row]
formattedMessage += formattedMessage +=
err.Location.file.lines[err.Location.row] + "\n" err.Location.file.lines[err.Location.row] + "\n"
// print an arrow with a tail spanning the width of the mistake // position error marker
columnCountdown := err.Location.column var index int
for columnCountdown > 1 { for index = 0; index < err.Location.column; index ++ {
// TODO: for tabs, print out a teb instead. if line[index] == '\t' {
formattedMessage += "\t"
} else {
formattedMessage += " " formattedMessage += " "
columnCountdown --
} }
}
// print an arrow with a tail spanning the width of the mistake
for err.width > 1 { for err.width > 1 {
// TODO: for tabs, print out 8 of these instead. if line[index] == '\t' {
formattedMessage += "--------"
} else {
formattedMessage += "-" formattedMessage += "-"
} }
index ++
}
formattedMessage += "^\n" formattedMessage += "^\n"
} }
formattedMessage += err.message + "\n" formattedMessage += err.message + "\n"