mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
ef44c0ad2f
commit
448d1d147d
3 changed files with 14 additions and 0 deletions
|
@ -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>
|
Fri Nov 27 19:19:44 2015 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb (connect): detect closed connection and reconnect
|
* lib/net/http.rb (connect): detect closed connection and reconnect
|
||||||
|
|
4
parse.y
4
parse.y
|
@ -6745,6 +6745,10 @@ parser_here_document(struct parser_params *parser, NODE *here)
|
||||||
str = STR_NEW3(tok(), toklen(), enc, func);
|
str = STR_NEW3(tok(), toklen(), enc, func);
|
||||||
}
|
}
|
||||||
dispatch_heredoc_end();
|
dispatch_heredoc_end();
|
||||||
|
#ifdef RIPPER
|
||||||
|
str = ripper_new_yylval(ripper_token2eventid(tSTRING_CONTENT),
|
||||||
|
yylval.val, str);
|
||||||
|
#endif
|
||||||
heredoc_restore(lex_strterm);
|
heredoc_restore(lex_strterm);
|
||||||
lex_strterm = NEW_STRTERM(-1, 0, 0);
|
lex_strterm = NEW_STRTERM(-1, 0, 0);
|
||||||
set_yylval_str(str);
|
set_yylval_str(str);
|
||||||
|
|
|
@ -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]
|
assert_equal '(?<n>a(b|\g<n>))', search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1]
|
||||||
end
|
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)
|
def search_sexp(sym, sexp)
|
||||||
return sexp if !sexp or sexp[0] == sym
|
return sexp if !sexp or sexp[0] == sym
|
||||||
sexp.find do |e|
|
sexp.find do |e|
|
||||||
|
|
Loading…
Add table
Reference in a new issue