aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/scanner.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2017-03-09 13:38:10 -0800
committerRobert Griesemer <gri@golang.org>2017-03-09 23:28:48 +0000
commit1f9f0ea32b2dcee027b107f2c3d0bc723274a810 (patch)
tree1c3d499526e0ab668b714ebc2cb0ac1ed76fb7dc /src/cmd/compile/internal/syntax/scanner.go
parentbfc164c64d33edfaf774b5c29b9bf5648a6447fb (diff)
downloadgo-1f9f0ea32b2dcee027b107f2c3d0bc723274a810.tar.gz
go-1f9f0ea32b2dcee027b107f2c3d0bc723274a810.zip
cmd/compile/internal/syntax: start line offset (column) numbers at 1
We could leave it alone and fix line offset (column) numbers when reporting errors, but that is likely to cause confusion (internal numbers don't match reported numbers). Instead, switch to default numbering starting at 1. For package syntax-internal use only, introduced constants defining the line and column bases, and use them throughout the code and its tests. It is possible to change these constants and package syntax will continue to work. But changing them is going to break any client that makes explicit assumptions about line and column numbers (which is "all of them"). Change-Id: Ia3d136a8ec8d9372ed9c05ca47d3dff222cf030e Reviewed-on: https://go-review.googlesource.com/37996 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/scanner.go')
-rw-r--r--src/cmd/compile/internal/syntax/scanner.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/syntax/scanner.go b/src/cmd/compile/internal/syntax/scanner.go
index c2de9ce686..05391e5efb 100644
--- a/src/cmd/compile/internal/syntax/scanner.go
+++ b/src/cmd/compile/internal/syntax/scanner.go
@@ -577,12 +577,12 @@ func (s *scanner) skipLine(r rune) {
func (s *scanner) lineComment() {
r := s.getr()
- // directives must start at the beginning of the line (s.col == 0)
- if s.col != 0 || s.pragh == nil || (r != 'g' && r != 'l') {
+ // directives must start at the beginning of the line (s.col == colbase)
+ if s.col != colbase || s.pragh == nil || (r != 'g' && r != 'l') {
s.skipLine(r)
return
}
- // s.col == 0 && s.pragh != nil && (r == 'g' || r == 'l')
+ // s.col == colbase && s.pragh != nil && (r == 'g' || r == 'l')
// recognize directives
prefix := "go:"