Add description method to Location

This commit is contained in:
Sasha Koshka 2022-08-18 01:31:01 -04:00
parent 9e66305001
commit bb89009742
1 changed files with 11 additions and 0 deletions

View File

@ -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)
}