1
0
mirror of https://github.com/golang/go synced 2024-11-20 00:44:45 -07:00

gc: fix weird error message

Fixes #1670.

R=ken2
CC=golang-dev
https://golang.org/cl/4386045
This commit is contained in:
Russ Cox 2011-04-08 13:53:32 -04:00
parent 8dc0ba7ae5
commit e7c4a6dfca

View File

@ -135,6 +135,7 @@ yyerror(char *fmt, ...)
int i;
static int lastsyntax;
va_list arg;
char buf[512], *p;
if(strncmp(fmt, "syntax error", 12) == 0) {
nsyntaxerrors++;
@ -147,6 +148,16 @@ yyerror(char *fmt, ...)
return;
lastsyntax = lexlineno;
if(strstr(fmt, "{ or {")) {
// The grammar has { and LBRACE but both show up as {.
// Rewrite syntax error referring to "{ or {" to say just "{".
strecpy(buf, buf+sizeof buf, fmt);
p = strstr(buf, "{ or {");
if(p)
memmove(p+1, p+6, strlen(p+6)+1);
fmt = buf;
}
// look for parse state-specific errors in list (see go.errors).
for(i=0; i<nelem(yymsg); i++) {
if(yymsg[i].yystate == yystate && yymsg[i].yychar == yychar) {