diff options
Diffstat (limited to 'src/pkg/go/token/token.go')
-rw-r--r-- | src/pkg/go/token/token.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/pkg/go/token/token.go b/src/pkg/go/token/token.go index f165d1978..61a0c622c 100644 --- a/src/pkg/go/token/token.go +++ b/src/pkg/go/token/token.go @@ -8,7 +8,11 @@ // package token -import "strconv" +import ( + "fmt"; + "strconv"; +) + // Token is the set of lexical tokens of the Go programming language. type Token int @@ -346,3 +350,18 @@ func (pos *Position) Pos() Position { func (pos *Position) IsValid() bool { return pos.Line > 0 } + + +func (pos *Position) String() string { + s := pos.Filename; + if pos.IsValid() { + if s != "" { + s += ":"; + } + s += fmt.Sprintf("%d:%d", pos.Line, pos.Column); + } + if s != "" { + return s; + } + return "<unknown position>"; +} |