summaryrefslogtreecommitdiff
path: root/src/pkg/go/token/token.go
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-07-30 16:58:19 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-07-30 16:58:19 -0700
commite383d220bd4e700a329ac87dd8ff3fc14eb3e545 (patch)
tree48be18906a57eed3291b9c905275afed0048fb2e /src/pkg/go/token/token.go
parent775a36ebf074ae48e5db28d257a7eaa9d1407955 (diff)
downloadgolang-e383d220bd4e700a329ac87dd8ff3fc14eb3e545.tar.gz
String method for token.Position. Extracted from gri's tree.
R=gri APPROVED=gri DELTA=33 (20 added, 6 deleted, 7 changed) OCL=32544 CL=32546
Diffstat (limited to 'src/pkg/go/token/token.go')
-rw-r--r--src/pkg/go/token/token.go21
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>";
+}