]> Cypherpunks repositories - gostls13.git/commit
scanner: fix Position returned by Scan, Pos
authorRobert Griesemer <gri@golang.org>
Tue, 25 Jan 2011 21:32:56 +0000 (13:32 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 25 Jan 2011 21:32:56 +0000 (13:32 -0800)
commiteaae95fa3d9f54665ef954df26c2fd54a32460c3
treea88800c64be311df238bf7461de44ea7760b4876
parent2ae953bfc31a9f87daf38df0b185c701a56b32e6
scanner: fix Position returned by Scan, Pos

The implementation of the position computation
was surprisingly broken. Implemented fixes and
added extra test cases.

There is a slight interface change: Calling
Pos() returns the current position; but if
called before Scan() that position may not
be the position of the next token returned
by Scan() (depending on the scan settings
and the source text) - this in contrast to
the original comment.

However, after calling Scan(), the Scanner's
Position field reports the position of the
scanned token, as before.

Fixes #1327.

R=rsc
CC=golang-dev
https://golang.org/cl/3972047
src/pkg/scanner/scanner.go
src/pkg/scanner/scanner_test.go