mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: preserve tSTRING_CONTENT results
* parse.y (ripper_flush_string_content): preserve the dispatched results at tSTRING_CONTENT. [ruby-dev:48714] [Bug #10437] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1549a6b78d
commit
0a190272cd
3 changed files with 13 additions and 4 deletions
|
@ -1,4 +1,7 @@
|
|||
Tue Dec 2 06:31:31 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Tue Dec 2 06:32:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (ripper_flush_string_content): preserve the dispatched
|
||||
results at tSTRING_CONTENT. [ruby-dev:48714] [Bug #10437]
|
||||
|
||||
* parse.y (regexp_contents): check in ripper only if the whole
|
||||
content is a single regexp without interpolation.
|
||||
|
|
9
parse.y
9
parse.y
|
@ -6302,6 +6302,8 @@ static void
|
|||
ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc)
|
||||
{
|
||||
VALUE content = yylval.val;
|
||||
if (!ripper_is_node_yylval(content))
|
||||
content = ripper_new_yylval(0, 0, content);
|
||||
if (!NIL_P(parser->delayed)) {
|
||||
ptrdiff_t len = lex_p - parser->tokp;
|
||||
if (len > 0) {
|
||||
|
@ -6309,11 +6311,12 @@ ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc)
|
|||
}
|
||||
ripper_dispatch_delayed_token(parser, tSTRING_CONTENT);
|
||||
parser->tokp = lex_p;
|
||||
RNODE(content)->nd_rval = yylval.val;
|
||||
}
|
||||
if (!ripper_is_node_yylval(content))
|
||||
content = ripper_new_yylval(0, 0, content);
|
||||
yylval.val = content;
|
||||
ripper_dispatch_scan_event(parser, tSTRING_CONTENT);
|
||||
if (yylval.val != content)
|
||||
RNODE(content)->nd_rval = yylval.val;
|
||||
yylval.val = content;
|
||||
}
|
||||
|
||||
#define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
|
||||
|
|
|
@ -26,6 +26,9 @@ class TestRipper::Sexp < Test::Unit::TestCase
|
|||
sexp = Ripper.sexp('/foo/')
|
||||
assert_equal 'foo', search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1]
|
||||
|
||||
sexp = Ripper.sexp("/foo\nbar/")
|
||||
assert_equal "foo\nbar", search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1]
|
||||
|
||||
sexp = Ripper.sexp('/(?<n>a(b|\g<n>))/')
|
||||
assert_equal '(?<n>a(b|\g<n>))', search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))[1]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue