]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: remove reference to ? and @ symbols in error message
authorRuss Cox <rsc@golang.org>
Sun, 3 Feb 2013 06:25:47 +0000 (01:25 -0500)
committerRuss Cox <rsc@golang.org>
Sun, 3 Feb 2013 06:25:47 +0000 (01:25 -0500)
Those symbols are only allowed during imports;
the parser may expect them but saying that doesn't help users.

Fixes #3434.

R=ken2
CC=golang-dev
https://golang.org/cl/7277045

src/cmd/gc/subr.c

index 01e738bf9d60cb0aa23e4b046be91c68a5f29c35..323d4f392282b37766b97f668fee0eb9814c399a 100644 (file)
@@ -151,14 +151,23 @@ yyerror(char *fmt, ...)
                if(lastsyntax == lexlineno)
                        return;
                lastsyntax = lexlineno;
-               
-               if(strstr(fmt, "{ or {")) {
+                       
+               if(strstr(fmt, "{ or {") || strstr(fmt, " or ?") || 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);
+                       
+                       // The grammar has ? and @ but only for reading imports.
+                       // Silence them in ordinary errors.
+                       p = strstr(buf, " or ?");
+                       if(p)
+                               memmove(p, p+5, strlen(p+5)+1);
+                       p = strstr(buf, " or @");
+                       if(p)
+                               memmove(p, p+5, strlen(p+5)+1);
                        fmt = buf;
                }