diff options
| author | Robert Griesemer <gri@golang.org> | 2017-05-12 12:49:47 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-05-14 20:24:34 +0000 |
| commit | fca6ad45e25647d8d156a8ecd29137000408efeb (patch) | |
| tree | 10849464d892473ef5fd028125a7193b960ed392 /src/text | |
| parent | cfae61b65a66d958367270d4d58ce7996a4987b7 (diff) | |
| download | go-fca6ad45e25647d8d156a8ecd29137000408efeb.tar.xz | |
text/scanner: clarify documentation on Pos and Position
For #20292. (See discussion in that issue.)
Change-Id: I44cd69394fc47a01776905ec34305ba524c89883
Reviewed-on: https://go-review.googlesource.com/43452
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/text')
| -rw-r--r-- | src/text/scanner/scanner.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/text/scanner/scanner.go b/src/text/scanner/scanner.go index e085f8a7d9..6fb0422fe5 100644 --- a/src/text/scanner/scanner.go +++ b/src/text/scanner/scanner.go @@ -166,7 +166,8 @@ type Scanner struct { // The Filename field is always left untouched by the Scanner. // If an error is reported (via Error) and Position is invalid, // the scanner is not inside a token. Call Pos to obtain an error - // position in that case. + // position in that case, or to obtain the position immediately + // after the most recently scanned token. Position } @@ -637,6 +638,8 @@ redo: // Pos returns the position of the character immediately after // the character or token returned by the last call to Next or Scan. +// Use the Scanner's Position field for the start position of the most +// recently scanned token. func (s *Scanner) Pos() (pos Position) { pos.Filename = s.Filename pos.Offset = s.srcBufOffset + s.srcPos - s.lastCharLen |
