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 ...@@ -419,6 +419,7 @@ EXTERN Dlist dotlist[10]; // size is max depth of embeddeds
EXTERN Io curio; EXTERN Io curio;
EXTERN Io pushedio; EXTERN Io pushedio;
EXTERN int32 lineno; EXTERN int32 lineno;
EXTERN int32 prevlineno;
EXTERN char* pathname; EXTERN char* pathname;
EXTERN Hist* hist; EXTERN Hist* hist;
EXTERN Hist* ehist; EXTERN Hist* ehist;
......
...@@ -300,6 +300,8 @@ yylex(void) ...@@ -300,6 +300,8 @@ yylex(void)
int escflag; int escflag;
Sym *s; Sym *s;
prevlineno = lineno;
l0: l0:
c = getc(); c = getc();
if(isspace(c)) if(isspace(c))
......
...@@ -269,6 +269,7 @@ dcl(void) ...@@ -269,6 +269,7 @@ dcl(void)
return d; return d;
} }
extern int yychar;
Node* Node*
nod(int op, Node *nleft, Node *nright) nod(int op, Node *nleft, Node *nright)
{ {
...@@ -278,7 +279,10 @@ nod(int op, Node *nleft, Node *nright) ...@@ -278,7 +279,10 @@ nod(int op, Node *nleft, Node *nright)
n->op = op; n->op = op;
n->left = nleft; n->left = nleft;
n->right = nright; n->right = nright;
n->lineno = lineno; if(yychar <= 0) // no lookahead
n->lineno = lineno;
else
n->lineno = prevlineno;
return n; 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