From bb8900974249d8e6305468e8bc08f98cfbaa99fe Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 18 Aug 2022 01:31:01 -0400 Subject: [PATCH] Add description method to Location --- file/location.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) +}