[dev.inline] cmd/compile/internal/syntax: use syntax.Pos for all external positions

- use syntax.Pos in syntax.Error (rather than line, col)
- use syntax.Pos in syntax.PragmaHandler (rather than just line)
- update uses
- better documentation in various places

Also:
- make Pos methods use Pos receiver (rather than *Pos)

Reviewed in and cherry-picked from https://go-review.googlesource.com/#/c/33891/.
With minor adjustments to noder.go to make merge compile.

Change-Id: I5507cea6c2be46a7677087c1aeb69382d31033eb
Reviewed-on: https://go-review.googlesource.com/34236
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2016-12-02 10:44:34 -08:00
parent 54ef0447fe
commit 3d5df64b3f
8 changed files with 93 additions and 64 deletions

View file

@ -77,9 +77,13 @@ func (s *source) error(msg string) {
}
// getr reads and returns the next rune.
// If an error occurs, the error handler provided to init
// is called with position (line and column) information
// and error message before getr returns.
//
// If a read or source encoding error occurs, getr
// calls the error handler installed with init.
// The handler must exist.
//
// The (line, col) position passed to the error handler
// is always at the current source reading position.
func (s *source) getr() rune {
redo:
s.r0, s.line0, s.col0 = s.r, s.line, s.col