summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-28 09:29:24 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-28 09:29:24 +0900
commitace2eee544378eb03ea95b95c89434508325e8c8 (patch)
treec669df863a6a1f2af18c3c0b61dab68bdd436271 /parse.y
parent111b69e8a009f469356a723183b651626dbaa8c4 (diff)
downloadruby-ace2eee544378eb03ea95b95c89434508325e8c8.tar.gz
[Bug #18963] Separate string contents by here document terminator
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y13
1 files changed, 13 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 405a83a8cf..e6fee29595 100644
--- a/parse.y
+++ b/parse.y
@@ -7196,6 +7196,10 @@ tokadd_string(struct parser_params *p,
{
int c;
bool erred = false;
+#ifdef RIPPER
+ const int heredoc_end = (p->heredoc_end ? p->heredoc_end + 1 : 0);
+ int top_of_line = FALSE;
+#endif
#define mixed_error(enc1, enc2) \
(void)(erred || (parser_mixed_error(p, enc1, enc2), erred = true))
@@ -7206,6 +7210,12 @@ tokadd_string(struct parser_params *p,
if (p->heredoc_indent > 0) {
parser_update_heredoc_indent(p, c);
}
+#ifdef RIPPER
+ if (top_of_line && heredoc_end == p->ruby_sourceline) {
+ pushback(p, c);
+ break;
+ }
+#endif
if (paren && c == paren) {
++*nest;
@@ -7332,6 +7342,9 @@ tokadd_string(struct parser_params *p,
}
}
tokadd(p, c);
+#ifdef RIPPER
+ top_of_line = (c == '\n');
+#endif
}
terminate:
if (*enc) *encp = *enc;