mirror of
https://github.com/golang/go.git
synced 2025-05-31 23:25:39 +00:00
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:
parent
d8ecead73d
commit
4656686cf5
@ -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;
|
||||
n->lineno = lineno;
|
||||
if(yychar <= 0) // no lookahead
|
||||
n->lineno = lineno;
|
||||
else
|
||||
n->lineno = prevlineno;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user