Commit e7c4a6df authored by Russ Cox's avatar Russ Cox

gc: fix weird error message

Fixes #1670.

R=ken2
CC=golang-dev
https://golang.org/cl/4386045
parent 8dc0ba7a
...@@ -135,6 +135,7 @@ yyerror(char *fmt, ...) ...@@ -135,6 +135,7 @@ yyerror(char *fmt, ...)
int i; int i;
static int lastsyntax; static int lastsyntax;
va_list arg; va_list arg;
char buf[512], *p;
if(strncmp(fmt, "syntax error", 12) == 0) { if(strncmp(fmt, "syntax error", 12) == 0) {
nsyntaxerrors++; nsyntaxerrors++;
...@@ -147,6 +148,16 @@ yyerror(char *fmt, ...) ...@@ -147,6 +148,16 @@ yyerror(char *fmt, ...)
return; return;
lastsyntax = lexlineno; 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). // look for parse state-specific errors in list (see go.errors).
for(i=0; i<nelem(yymsg); i++) { for(i=0; i<nelem(yymsg); i++) {
if(yymsg[i].yystate == yystate && yymsg[i].yychar == yychar) { if(yymsg[i].yystate == yystate && yymsg[i].yychar == yychar) {
......
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