]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/yacc: fix debug print of token name
authorRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 21:45:35 +0000 (16:45 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 21:45:35 +0000 (16:45 -0500)
The array skips the first TOKSTART entries.

Fixes #4410.

R=golang-dev, ken2, ken
CC=golang-dev
https://golang.org/cl/6999054

src/cmd/yacc/units.y
src/cmd/yacc/yacc.go

index 00ccaf2ecece23f5d570b8cfa0cadb8a833a4522..9c1b0b3364f36d991e070c3fdcdf6500b3ab2703 100644 (file)
 
 %{
 
+// 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
index 62655e7cd2549747989ec11334dc371f4aaca5a9..0c18f93b6c95101cd5a9cd035f54c57b30aca70f 100644 (file)
@@ -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)