From b1f44a120f55ad163bb9516ede57277cddc8e50b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 24 Sep 2010 17:09:31 -0400 Subject: [PATCH] gc: improve error message for x \= 0 was x.go:2: syntax error: unexpected $undefined now x.go:2: syntax error: unexpected \ R=ken2 CC=golang-dev https://golang.org/cl/2267044 --- src/cmd/gc/lex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c index 5d4230041c..7ddcdd21d2 100644 --- a/src/cmd/gc/lex.c +++ b/src/cmd/gc/lex.c @@ -538,7 +538,7 @@ isfrog(int c) return 0; return 1; } - if(0x80 <= c && c <= 0xa0) // unicode block including unbreakable space. + if(0x7f <= c && c <= 0xa0) // DEL, unicode block including unbreakable space. return 1; return 0; } @@ -947,6 +947,10 @@ lx: yyerror("illegal character 0x%ux", c); goto l0; } + if(importpkg == nil && (c == '#' || c == '$' || c == '?' || c == '@' || c == '\\')) { + yyerror("%s: unexpected %c", "syntax error", c); + goto l0; + } return c; asop: