diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-05 12:38:26 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:45 +0000 |
| commit | 53efae0d632480d420f85dabfdc6ea5293536ef5 (patch) | |
| tree | d73af0ec3d6a6de3253656a0e0575c4c9849861a /lib | |
| parent | b0ee9c8f28249b3de644383901bb637b8eb7275b (diff) | |
[ruby/prism] Implement other call nodes for ripper translation
https://github.com/ruby/prism/commit/a76744be47
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/translation/ripper.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index d92ff83ed3..8ab7b4a6aa 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -498,13 +498,43 @@ module Prism # foo.bar &&= baz # ^^^^^^^^^^^^^^^ def visit_call_and_write_node(node) - raise NoMethodError, __method__ + receiver = visit(node.receiver) + + bounds(node.call_operator_loc) + call_operator = visit_token(node.call_operator) + + bounds(node.message_loc) + message = visit_token(node.message) + + bounds(node.location) + target = on_field(receiver, call_operator, message) + + bounds(node.operator_loc) + operator = on_op("&&=") + + value = visit(node.value) + on_opassign(target, operator, value) end # foo.bar ||= baz # ^^^^^^^^^^^^^^^ def visit_call_or_write_node(node) - raise NoMethodError, __method__ + receiver = visit(node.receiver) + + bounds(node.call_operator_loc) + call_operator = visit_token(node.call_operator) + + bounds(node.message_loc) + message = visit_token(node.message) + + bounds(node.location) + target = on_field(receiver, call_operator, message) + + bounds(node.operator_loc) + operator = on_op("||=") + + value = visit(node.value) + on_opassign(target, operator, value) end # foo.bar, = 1 @@ -2250,6 +2280,8 @@ module Prism # split into the various token types. def visit_token(token) case token + when "." + on_period(token) when *RUBY_KEYWORDS on_kw(token) when /^[[:upper:]]/ |
