1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:24:45 -07:00

gc: tweak error messages, avoid internalization settings in bison

R=r
CC=golang-dev
https://golang.org/cl/194129
This commit is contained in:
Russ Cox 2010-01-28 15:57:44 -08:00
parent dd77c63d3d
commit 288c1c83d9
11 changed files with 30 additions and 26 deletions

View File

@ -49,7 +49,7 @@ $(LIB): $(OFILES)
$(OFILES): $(HFILES) $(OFILES): $(HFILES)
y.tab.h: $(YFILES) y.tab.h: $(YFILES)
bison -v -y $(YFLAGS) $(YFILES) LANG=C bison -v -y $(YFLAGS) $(YFILES)
y.tab.c: y.tab.h y.tab.c: y.tab.h
test -f y.tab.c && touch y.tab.c test -f y.tab.c && touch y.tab.c

View File

@ -15,28 +15,28 @@ static struct {
// by that token list. // by that token list.
% loadsys package LIMPORT '(' LLITERAL import_package import_there ',' % 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 ';' % 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 ';' % 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 ';' % loadsys package imports LFUNC LNAME '(' ')' '{' LFOR for_header ';'
"unexpected ; or newline before {", "unexpected semicolon or newline before {",
% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR ';' LBODY % loadsys package imports LFUNC LNAME '(' ')' '{' LFOR ';' LBODY
"unexpected ; or newline before {", "unexpected semicolon or newline before {",
% loadsys package imports LFUNC LNAME '(' ')' ';' '{' % loadsys package imports LFUNC LNAME '(' ')' ';' '{'
"unexpected ; or newline before {", "unexpected semicolon or newline before {",
% loadsys package imports LTYPE LNAME ';' % 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 % 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 % loadsys package imports LTYPE LNAME LINTERFACE '{' LNAME ',' LNAME
"name list not allowed in interface type", "name list not allowed in interface type",

View File

@ -1523,6 +1523,10 @@ struct
"LRSH", ">>", "LRSH", ">>",
"LOROR", "||", "LOROR", "||",
"LNE", "!=", "LNE", "!=",
// spell out to avoid confusion with punctuation in error messages
"';'", "semicolon or newline",
"','", "comma",
}; };
void void
@ -1535,21 +1539,21 @@ yytinit(void)
for(i=0; yytname[i] != nil; i++) { for(i=0; yytname[i] != nil; i++) {
s = yytname[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. // turn 'x' into x.
if(s[0] == '\'') { if(s[0] == '\'') {
t = strdup(s+1); t = strdup(s+1);
t[strlen(t)-1] = '\0'; t[strlen(t)-1] = '\0';
yytname[i] = t; 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:;
} }
} }

View File

@ -7,7 +7,7 @@
package main package main
import ( import (
"io", // ERROR "unexpected ," "io", // ERROR "unexpected comma"
"os" "os"
) )

View File

@ -7,7 +7,7 @@
package main package main
func main() { func main() {
if x; y // ERROR "unexpected ; or newline before {" if x; y // ERROR "unexpected semicolon or newline before {"
{ {
z z

View File

@ -7,7 +7,7 @@
package main package main
func main() { func main() {
switch x; y // ERROR "unexpected ; or newline before {" switch x; y // ERROR "unexpected semicolon or newline before {"
{ {
z z

View File

@ -7,7 +7,7 @@
package main package main
func main() { func main() {
for x; y; z // ERROR "unexpected ; or newline before {" for x; y; z // ERROR "unexpected semicolon or newline before {"
{ {
z z

View File

@ -8,7 +8,7 @@ package main
func main() { func main() {
for x for x
{ // ERROR "unexpected ; or newline before {" { // ERROR "unexpected semicolon or newline before {"
z z

View File

@ -7,7 +7,7 @@
package main package main
func main() func main()
{ // ERROR "unexpected ; or newline before {" { // ERROR "unexpected semicolon or newline before {"

View File

@ -6,7 +6,7 @@
package main package main
type T // ERROR "unexpected ; or newline in type declaration" type T // ERROR "unexpected semicolon or newline in type declaration"
{ {

View File

@ -8,7 +8,7 @@ package main
func main() { func main() {
if x { } if x { }
else { } // ERROR "unexpected ; or newline before else" else { } // ERROR "unexpected semicolon or newline before else"
} }