Commit b3bb4bd2 authored by Russ Cox's avatar Russ Cox

cmd/yacc: fix debug print of token name

The array skips the first TOKSTART entries.

Fixes #4410.

R=golang-dev, ken2, ken
CC=golang-dev
https://golang.org/cl/6999054
parent ec59b840
......@@ -11,6 +11,11 @@
%{
// 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
......
......@@ -3228,9 +3228,10 @@ type $$Lexer interface {
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment