]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: start line offset (column) numbers at 1
authorRobert Griesemer <gri@golang.org>
Thu, 9 Mar 2017 21:38:10 +0000 (13:38 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 9 Mar 2017 23:28:48 +0000 (23:28 +0000)
commit1f9f0ea32b2dcee027b107f2c3d0bc723274a810
tree1c3d499526e0ab668b714ebc2cb0ac1ed76fb7dc
parentbfc164c64d33edfaf774b5c29b9bf5648a6447fb
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>
src/cmd/compile/internal/syntax/nodes_test.go
src/cmd/compile/internal/syntax/parser_test.go
src/cmd/compile/internal/syntax/scanner.go
src/cmd/compile/internal/syntax/scanner_test.go
src/cmd/compile/internal/syntax/source.go