1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:14:45 -07:00

better diagnostics for eof in a string.

this assumes that embedded newlines are
legal in back-quote strings.

R=r
OCL=30502
CL=30502
This commit is contained in:
Ken Thompson 2009-06-18 15:49:41 -07:00
parent db7a6221e9
commit eba82f4391

View File

@ -371,11 +371,11 @@ isfrog(int c)
static int32
_yylex(void)
{
int c, c1, clen;
int c, c1, clen, escflag;
vlong v;
char *cp;
Rune rune;
int escflag;
int32 lno;
Sym *s;
prevlineno = lineno;
@ -459,9 +459,14 @@ l0:
clen = sizeof(int32);
casebq:
lno = lineno;
for(;;) {
c = getc();
if(c == EOF || c == '`')
if(c == EOF) {
yyerror("eof in string starting at line %L", lno);
break;
}
if(c == '`')
break;
cp = remal(cp, clen, 1);
cp[clen++] = c;
@ -1082,11 +1087,16 @@ escchar(int e, int *escflg, vlong *val)
loop:
c = getr();
if(c == '\n') {
switch(c) {
case EOF:
yyerror("eof in string");
return 1;
case '\n':
yyerror("newline in string");
return 1;
}
if(c != '\\') {
case '\\':
break;
default:
if(c == e)
return 1;
*val = c;