Compare commits

..

No commits in common. "d42d0c5b34e3d470073ab42c49f821e7d5d9900d" and "abc6e44fb223241e23e321e54534dd98c8f74bfd" have entirely different histories.

View File

@ -1,8 +1,7 @@
package infoerr
package file
import "os"
import "fmt"
import "git.tebibyte.media/sashakoshka/arf/file"
type ErrorKind int
@ -12,14 +11,14 @@ const (
)
type Error struct {
file.Location
Location
message string
kind ErrorKind
}
// NewError creates a new error at the specified location.
func NewError (
location file.Location,
location Location,
message string,
kind ErrorKind,
) (
@ -42,23 +41,24 @@ func (err Error) Error () (formattedMessage string) {
}
// print information about the location of the mistake
if err.Width() > 0 {
if err.width > 0 {
formattedMessage += fmt.Sprint (
" \033[34m", err.Row() + 1,
":", err.Column() + 1)
" \033[34m", err.Location.row + 1,
":", err.Location.column + 1)
}
formattedMessage +=
" \033[90min\033[0m " +
err.File().Path() + "\n"
err.Location.file.path + "\n"
if err.Width() > 0 {
if err.width > 0 {
// print erroneous line
line := err.File().GetLine(err.Row())
formattedMessage += line + "\n"
line := err.Location.file.lines[err.Location.row]
formattedMessage +=
err.Location.file.lines[err.Location.row] + "\n"
// position error marker
var index int
for index = 0; index < err.Column(); index ++ {
for index = 0; index < err.Location.column; index ++ {
if line[index] == '\t' {
formattedMessage += "\t"
} else {
@ -67,7 +67,7 @@ func (err Error) Error () (formattedMessage string) {
}
// print an arrow with a tail spanning the width of the mistake
for err.Width() > 1 {
for err.width > 1 {
if line[index] == '\t' {
formattedMessage += "--------"
} else {