summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-28 10:33:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-28 10:33:58 +0000
commit448d1d147d3a0b636323d0c8d80f53a399d445af (patch)
tree163aa2ff30f32213db2391bd2928576e6af7f18b
parentef44c0ad2fc9c91e90b69a1cfa88f923ac169256 (diff)
parse.y: last content of heredoc
* parse.y (parser_here_document): store dispatched result of on_tstring_content at the last fragment of a here document. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--parse.y4
-rw-r--r--test/ripper/test_sexp.rb5
3 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 515b6974f5..024bc0c529 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Nov 28 19:33:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (parser_here_document): store dispatched result of
+ on_tstring_content at the last fragment of a here document.
+
Fri Nov 27 19:19:44 2015 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/http.rb (connect): detect closed connection and reconnect
diff --git a/parse.y b/parse.y
index 3a51893d30..86824f9199 100644
--- a/parse.y
+++ b/parse.y
@@ -6745,6 +6745,10 @@ parser_here_document(struct parser_params *parser, NODE *here)
str = STR_NEW3(tok(), toklen(), enc, func);
}
dispatch_heredoc_end();
+#ifdef RIPPER
+ str = ripper_new_yylval(ripper_token2eventid(tSTRING_CONTENT),
+ yylval.val, str);
+#endif
heredoc_restore(lex_strterm);
lex_strterm = NEW_STRTERM(-1, 0, 0);
set_yylval_str(str);
diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb
index 2c5bcdacde..8fc17fdd4a 100644
--- a/test/ripper/test_sexp.rb
+++ b/test/ripper/test_sexp.rb
@@ -33,6 +33,11 @@ class TestRipper::Sexp < Test::Unit::TestCase
assert_equal '(?<n>a(b|\g<n>))', search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1]
end
+ def test_heredoc_content
+ sexp = Ripper.sexp("<<E\nfoo\nE")
+ assert_equal "foo\n", search_sexp(:@tstring_content, sexp)[1]
+ end
+
def search_sexp(sym, sexp)
return sexp if !sexp or sexp[0] == sym
sexp.find do |e|