]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: establish principled position information
authorRobert Griesemer <gri@golang.org>
Tue, 14 Feb 2017 00:00:53 +0000 (16:00 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 15 Feb 2017 01:33:03 +0000 (01:33 +0000)
commit5267ac2732edd1ba4a13773987dff08e8b4a2dde
treee75fba029f50ffce20fa05525d2349cf7813bf74
parent6910756f9b8c7a97b1435ec40b8ebff9655611d7
cmd/compile/internal/syntax: establish principled position information

Until now, the parser set the position for each Node to the position of
the first token belonging to that node. For compatibility with the now
defunct gc parser, in many places that position information was modified
when the gcCompat flag was set (which it was, by default). Furthermore,
in some places, position information was not set at all.

This change removes the gcCompat flag and all associated code, and sets
position information for all nodes in a more principled way, as proposed
by mdempsky (see #16943 for details). Specifically, the position of a
node may not be at the very beginning of the respective production. For
instance for an Operation `a + b`, the position associated with the node
is the position of the `+`. Thus, for `a + b + c` we now get different
positions for the two additions.

This change does not pass toolstash -cmp because position information
recorded in export data and pcline tables is different. There are no
other functional changes.

Added test suite testing the position of all nodes.

Fixes #16943.

Change-Id: I3fc02bf096bc3b3d7d2fa655dfd4714a1a0eb90c
Reviewed-on: https://go-review.googlesource.com/37017
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/syntax/nodes.go
src/cmd/compile/internal/syntax/nodes_test.go [new file with mode: 0644]
src/cmd/compile/internal/syntax/parser.go
test/escape_closure.go