Skip to content

Commit

Permalink
Make comment handler handle dynamic symbols with embedded code
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Jun 22, 2012
1 parent 605fcf0 commit 7318a7e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ripper_ruby_parser/commenting_sexp_builder.rb
Expand Up @@ -57,6 +57,11 @@ def on_symbol *args
super super
end end


def on_embexpr_beg *args
@in_symbol = false
super
end

def on_dyna_symbol *args def on_dyna_symbol *args
@in_symbol = false @in_symbol = false
super super
Expand Down
14 changes: 14 additions & 0 deletions test/unit/commenting_sexp_builder_test.rb
Expand Up @@ -94,6 +94,20 @@ def parse_with_builder str
[:params, nil, nil, nil, nil, nil], [:params, nil, nil, nil, nil, nil],
[:bodystmt, [[:void_stmt]], nil, nil, nil]]]]] [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]
end end

it "is not confused by a dynamic symbol containing a class definition" do
result = parse_with_builder ":\"foo\#{class Bar;end}\""
result.must_equal [:program,
[[:dyna_symbol,
[[:@tstring_content, "foo", [1, 2]],
[:string_embexpr,
[[:comment,
"",
[:class,
[:const_ref, [:@const, "Bar", [1, 13]]],
nil,
[:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]]]]]
end
end end
end end


0 comments on commit 7318a7e

Please sign in to comment.