The array skips the first TOKSTART entries.
Fixes #4410.
R=golang-dev, ken2, ken
CC=golang-dev
https://golang.org/cl/
6999054
%{
+// This tag will end up in the generated y.go, so that forgetting
+// 'make clean' does not fail the next build.
+
+// +build ignore
+
// units.y
// example of a Go yacc program
// usage is
const $$Flag = -1000
func $$Tokname(c int) string {
- if c > 0 && c <= len($$Toknames) {
- if $$Toknames[c-1] != "" {
- return $$Toknames[c-1]
+ // 4 is TOKSTART above
+ if c >= 4 && c-4 < len($$Toknames) {
+ if $$Toknames[c-4] != "" {
+ return $$Toknames[c-4]
}
}
return __yyfmt__.Sprintf("tok-%v", c)