Skip to content

Handle "#{}" as dynamic string #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,8 @@ def identify_string(ltype, quoted = ltype, type = nil)
break
elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
ch = getc
subtype = true
if ch == "{" then
subtype = true
str << ch << skip_inner_expression
next
else
Expand Down
8 changes: 5 additions & 3 deletions test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,7 @@ def test_parse_statements_class_nested
end

def test_parse_statements_def_percent_string_pound
util_parser "class C\ndef a\n%r{#}\nend\ndef b() end\nend"
util_parser "class C\ndef a\n%r{#}\n%r{\#{}}\nend\ndef b() end\nend"

@parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL

Expand All @@ -2080,9 +2080,11 @@ def test_parse_statements_def_percent_string_pound
tk(:SPACE, 11, 2, 3, nil, ' '),
tk(:IDENTIFIER, 12, 2, 4, 'a', 'a'),
tk(:NL, 13, 2, 5, nil, "\n"),
tk(:DREGEXP, 14, 3, 0, nil, '%r{#}'),
tk(:REGEXP, 14, 3, 0, nil, '%r{#}'),
tk(:NL, 19, 3, 5, nil, "\n"),
tk(:END, 20, 4, 0, 'end', 'end'),
tk(:DREGEXP, 20, 4, 0, nil, '%r{#{}}'),
tk(:NL, 27, 4, 7, nil, "\n"),
tk(:END, 28, 5, 0, 'end', 'end'),
]

assert_equal expected, a.token_stream
Expand Down