use correct lineno in nod even if yacc has looked ahead.

makes lineno correct for statements without semicolons.

R=ken
OCL=19454
CL=19454
This commit is contained in:
Russ Cox 2008-11-18 09:32:05 -08:00
parent d8ecead73d
commit 4656686cf5
3 changed files with 8 additions and 1 deletions

View File

@ -419,6 +419,7 @@ EXTERN Dlist dotlist[10]; // size is max depth of embeddeds
EXTERN Io curio;
EXTERN Io pushedio;
EXTERN int32 lineno;
EXTERN int32 prevlineno;
EXTERN char* pathname;
EXTERN Hist* hist;
EXTERN Hist* ehist;

View File

@ -300,6 +300,8 @@ yylex(void)
int escflag;
Sym *s;
prevlineno = lineno;
l0:
c = getc();
if(isspace(c))

View File

@ -269,6 +269,7 @@ dcl(void)
return d;
}
extern int yychar;
Node*
nod(int op, Node *nleft, Node *nright)
{
@ -278,7 +279,10 @@ nod(int op, Node *nleft, Node *nright)
n->op = op;
n->left = nleft;
n->right = nright;
n->lineno = lineno;
if(yychar <= 0) // no lookahead
n->lineno = lineno;
else
n->lineno = prevlineno;
return n;
}