Commit 4656686c authored by Russ Cox's avatar Russ Cox

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

makes lineno correct for statements without semicolons.

R=ken
OCL=19454
CL=19454
parent d8ecead7
......@@ -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;
......
......@@ -300,6 +300,8 @@ yylex(void)
int escflag;
Sym *s;
prevlineno = lineno;
l0:
c = getc();
if(isspace(c))
......
......@@ -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;
if(yychar <= 0) // no lookahead
n->lineno = lineno;
else
n->lineno = prevlineno;
return n;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment