From 3bbf66f9f302e655d5d6a44029590df62dc5b4e6 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 10 Nov 2013 04:32:57 +0900 Subject: cancel #1565 since it breaks mirb; instead add special treatment to heredocs --- src/parse.y | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 6023d87eb..8b4348a77 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3333,19 +3333,13 @@ nextc(parser_state *p) return c; eof: - if (!p->eof) { - p->eof = TRUE; - return '\n'; - } - if (!p->cxt) return -1; else { mrbc_context *cxt = p->cxt; if (cxt->partial_hook(p) < 0) return -1; - p->eof = FALSE; - p->cxt = NULL; - c = nextc(p); + c = '\n'; + p->lineno = 1; p->cxt = cxt; return c; } @@ -3873,6 +3867,9 @@ heredoc_identifier(parser_state *p) return 0; } } else { + if (c == -1) { + return 0; /* missing here document identifier */ + } if (! identchar(c)) { pushback(p, c); if (indent) pushback(p, '-'); @@ -3936,7 +3933,10 @@ parser_yylex(parser_state *p) case '\0': /* NUL */ case '\004': /* ^D */ case '\032': /* ^Z */ + return 0; case -1: /* end of script. */ + if (p->heredocs_from_nextline) + goto maybe_heredoc; return 0; /* white spaces */ @@ -3949,6 +3949,7 @@ parser_yylex(parser_state *p) skip(p, '\n'); /* fall through */ case '\n': + maybe_heredoc: heredoc_treat_nextline(p); switch (p->lstate) { case EXPR_BEG: -- cgit v1.2.3