cmd/yacc: Prevent index out of range. Fixes #9099.

Change-Id: I7ef01a738b6ca49af1c148146d439c81b0a33b16
Reviewed-on: https://go-review.googlesource.com/1785
Reviewed-by: Ian Lance Taylor <iant@golang.org>