ruby-changes:40698
From: nobu <ko1@a...>
Date: Sat, 28 Nov 2015 19:34:15 +0900 (JST)
Subject: [ruby-changes:40698] nobu:r52777 (trunk): parse.y: last content of heredoc
nobu 2015-11-28 19:33:58 +0900 (Sat, 28 Nov 2015) New Revision: 52777 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52777 Log: 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. Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ripper/test_sexp.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52776) +++ ChangeLog (revision 52777) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 28 19:33:55 2015 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * lib/net/http.rb (connect): detect closed connection and reconnect Index: parse.y =================================================================== --- parse.y (revision 52776) +++ parse.y (revision 52777) @@ -6745,6 +6745,10 @@ parser_here_document(struct parser_param https://github.com/ruby/ruby/blob/trunk/parse.y#L6745 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); Index: test/ripper/test_sexp.rb =================================================================== --- test/ripper/test_sexp.rb (revision 52776) +++ test/ripper/test_sexp.rb (revision 52777) @@ -33,6 +33,11 @@ class TestRipper::Sexp < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L33 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| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/