]> Cypherpunks.ru repositories - gostls13.git/commitdiff
gc: tweak error messages, avoid internalization settings in bison
authorRuss Cox <rsc@golang.org>
Thu, 28 Jan 2010 23:57:44 +0000 (15:57 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 28 Jan 2010 23:57:44 +0000 (15:57 -0800)
R=r
CC=golang-dev
https://golang.org/cl/194129

src/cmd/gc/Makefile
src/cmd/gc/go.errors
src/cmd/gc/lex.c
test/syntax/import.go
test/syntax/semi1.go
test/syntax/semi2.go
test/syntax/semi3.go
test/syntax/semi4.go
test/syntax/semi5.go
test/syntax/semi6.go
test/syntax/semi7.go

index 16bfc66398554d8d43b43f6d2be480435dad9aeb..0ca9e9d28eb848b581b77cba6dc931792692d68c 100644 (file)
@@ -49,7 +49,7 @@ $(LIB): $(OFILES)
 $(OFILES): $(HFILES)
 
 y.tab.h: $(YFILES)
-       bison -v -y $(YFLAGS) $(YFILES)
+       LANG=C bison -v -y $(YFLAGS) $(YFILES)
 
 y.tab.c: y.tab.h
        test -f y.tab.c && touch y.tab.c
index 215f28c5a2ace320d228c96605aed59049dce01f..3cb718adb130d2cb9e46d3bea48a18f0b6dac460 100644 (file)
@@ -15,28 +15,28 @@ static struct {
        // by that token list.
        
        % loadsys package LIMPORT '(' LLITERAL import_package import_there ','
-       "unexpected , during import block",
+       "unexpected comma during import block",
        
        % loadsys package imports LFUNC LNAME '(' ')' '{' LIF if_header ';'
-       "unexpected ; or newline before {",
+       "unexpected semicolon or newline before {",
        
        % loadsys package imports LFUNC LNAME '(' ')' '{' LSWITCH if_header ';'
-       "unexpected ; or newline before {",
+       "unexpected semicolon or newline before {",
        
        % loadsys package imports LFUNC LNAME '(' ')' '{' LFOR for_header ';'
-       "unexpected ; or newline before {",
+       "unexpected semicolon or newline before {",
        
        % loadsys package imports LFUNC LNAME '(' ')' '{' LFOR ';' LBODY
-       "unexpected ; or newline before {",
+       "unexpected semicolon or newline before {",
        
        % loadsys package imports LFUNC LNAME '(' ')' ';' '{'
-       "unexpected ; or newline before {",
+       "unexpected semicolon or newline before {",
        
        % loadsys package imports LTYPE LNAME ';'
-       "unexpected ; or newline in type declaration",
+       "unexpected semicolon or newline in type declaration",
        
        % loadsys package imports LFUNC LNAME '(' ')' '{' if_stmt ';' LELSE
-       "unexpected ; or newline before else",
+       "unexpected semicolon or newline before else",
        
        % loadsys package imports LTYPE LNAME LINTERFACE '{' LNAME ',' LNAME
        "name list not allowed in interface type",
index 4d74bb9631e99f4a0642000768954cf9e4c3d4c1..175d7a3efca33822fc03aa971349d5c2e871b6cd 100644 (file)
@@ -1523,6 +1523,10 @@ struct
        "LRSH", ">>",
        "LOROR",        "||",
        "LNE",  "!=",
+       
+       // spell out to avoid confusion with punctuation in error messages
+       "';'",  "semicolon or newline",
+       "','",  "comma",
 };
 
 void
@@ -1535,21 +1539,21 @@ yytinit(void)
        for(i=0; yytname[i] != nil; i++) {
                s = yytname[i];
                
+               // apply yytfix if possible
+               for(j=0; j<nelem(yytfix); j++) {
+                       if(strcmp(s, yytfix[j].have) == 0) {
+                               yytname[i] = yytfix[j].want;
+                               goto loop;
+                       }
+               }
+
                // turn 'x' into x.
                if(s[0] == '\'') {
                        t = strdup(s+1);
                        t[strlen(t)-1] = '\0';
                        yytname[i] = t;
-                       continue;
-               }
-               
-               // apply yytfix to the rest
-               for(j=0; j<nelem(yytfix); j++) {
-                       if(strcmp(s, yytfix[j].have) == 0) {
-                               yytname[i] = yytfix[j].want;
-                               break;
-                       }
                }
+       loop:;
        }               
 }
 
index 90e7df007ebdf95febb4dc5f80eaa02305d9a80f..dd1f2613445164383dbe4451bead730de762bdc8 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 import (
-       "io",   // ERROR "unexpected ,"
+       "io",   // ERROR "unexpected comma"
        "os"
 )
 
index c805bb0064bf90178db99bfbd5b16f37054c90f6..5ec776bba6bdeaa29de6db8057fdbb88a25905c3 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 func main() {
-       if x; y // ERROR "unexpected ; or newline before {"
+       if x; y // ERROR "unexpected semicolon or newline before {"
        {
                z
 
index 237fac8f3bea277aba565e2e933564470c6769b7..14800a33e7ef8cb8c65d681ae4626c8c72ebb73c 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 func main() {
-       switch x; y     // ERROR "unexpected ; or newline before {"
+       switch x; y     // ERROR "unexpected semicolon or newline before {"
        {
                z
 
index 2dbcb598433c4091c669322390fa387800a51519..d8e037fdc015833404280796017c8860762c9f8e 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 func main() {
-       for x; y; z     // ERROR "unexpected ; or newline before {"
+       for x; y; z     // ERROR "unexpected semicolon or newline before {"
        {
                z
 
index 2268cf75afa85646d1ebea4282bab16467b59fc3..81134c19b4e2e90ea3d206c47bc5c0ccdd978bb0 100644 (file)
@@ -8,7 +8,7 @@ package main
 
 func main() {
        for x
-       {       // ERROR "unexpected ; or newline before {"
+       {       // ERROR "unexpected semicolon or newline before {"
                z
 
 
index 7f907fb8f8c2f7e302a078d51f38c97c979bf1cc..0ba4df8d6dec132e3f94fc5c223483d8a6e4cfe6 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 func main()
-{      // ERROR "unexpected ; or newline before {"
+{      // ERROR "unexpected semicolon or newline before {"
 
 
 
index 75de3e0a15c35fa49a4bb78bb75787d2e6d3f790..b6279ed307abcd11b502d2d802d3ecaf2eb9c340 100644 (file)
@@ -6,7 +6,7 @@
 
 package main
 
-type T // ERROR "unexpected ; or newline in type declaration"
+type T // ERROR "unexpected semicolon or newline in type declaration"
 {
 
 
index 45890435755bea51afee6329e4ae2ad4ac9936e3..a4271ddc5c086d19b25bf2ee2939098e5ab566d3 100644 (file)
@@ -8,7 +8,7 @@ package main
 
 func main() {
        if x { }
-       else { }        // ERROR "unexpected ; or newline before else"
+       else { }        // ERROR "unexpected semicolon or newline before else"
 }