Fix line number bug; fix #4513

Also fix the misfeature introduced in 23783a44, that ignores newlines
between method chains.
parent 42fb251d
...@@ -4731,6 +4731,7 @@ parser_yylex(parser_state *p) ...@@ -4731,6 +4731,7 @@ parser_yylex(parser_state *p)
case '\n': case '\n':
maybe_heredoc: maybe_heredoc:
heredoc_treat_nextline(p); heredoc_treat_nextline(p);
p->column = 0;
switch (p->lstate) { switch (p->lstate) {
case EXPR_BEG: case EXPR_BEG:
case EXPR_FNAME: case EXPR_FNAME:
...@@ -4738,7 +4739,6 @@ parser_yylex(parser_state *p) ...@@ -4738,7 +4739,6 @@ parser_yylex(parser_state *p)
case EXPR_CLASS: case EXPR_CLASS:
case EXPR_VALUE: case EXPR_VALUE:
p->lineno++; p->lineno++;
p->column = 0;
if (p->parsing_heredoc != NULL) { if (p->parsing_heredoc != NULL) {
if (p->lex_strterm) { if (p->lex_strterm) {
return parse_string(p); return parse_string(p);
...@@ -4759,15 +4759,12 @@ parser_yylex(parser_state *p) ...@@ -4759,15 +4759,12 @@ parser_yylex(parser_state *p)
break; break;
case '#': /* comment as a whitespace */ case '#': /* comment as a whitespace */
pushback(p, '#'); pushback(p, '#');
goto retry;
case '\n': /* consecutive newlines */
p->lineno++; p->lineno++;
p->column = 0;
pushback(p, '\n');
goto retry; goto retry;
case '.': case '.':
if (!peek(p, '.')) { if (!peek(p, '.')) {
pushback(p, '.'); pushback(p, '.');
p->lineno++;
goto retry; goto retry;
} }
pushback(p, c); pushback(p, c);
...@@ -4775,6 +4772,7 @@ parser_yylex(parser_state *p) ...@@ -4775,6 +4772,7 @@ parser_yylex(parser_state *p)
case '&': case '&':
if (peek(p, '.')) { if (peek(p, '.')) {
pushback(p, '&'); pushback(p, '&');
p->lineno++;
goto retry; goto retry;
} }
pushback(p, c); pushback(p, c);
......
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