diff --git a/file/location.go b/file/location.go index bd2004e..c05fb7e 100644 --- a/file/location.go +++ b/file/location.go @@ -1,5 +1,7 @@ package file +import "fmt" + // Location represents a specific point in a file. It is used for error // reporting. type Location struct { @@ -31,3 +33,12 @@ func (location Location) Column () (column int) { func (location Location) Width () (width int) { return location.width } + +// Describe generates a description of the location for debug purposes +func (location Location) Describe () (description string) { + return fmt.Sprint ( + "in ", location.file.Path(), + " row ", location.row, + " column ", location.column, + " width ", location.width) +}