ripper_ruby_parser 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -1
  3. data/README.md +41 -9
  4. data/Rakefile +2 -0
  5. data/lib/ripper_ruby_parser.rb +2 -0
  6. data/lib/ripper_ruby_parser/commenting_ripper_parser.rb +23 -45
  7. data/lib/ripper_ruby_parser/parser.rb +11 -1
  8. data/lib/ripper_ruby_parser/sexp_handlers.rb +2 -6
  9. data/lib/ripper_ruby_parser/sexp_handlers/assignment.rb +49 -35
  10. data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +78 -39
  11. data/lib/ripper_ruby_parser/sexp_handlers/conditionals.rb +16 -15
  12. data/lib/ripper_ruby_parser/sexp_handlers/helper_methods.rb +19 -15
  13. data/lib/ripper_ruby_parser/sexp_handlers/literals.rb +138 -30
  14. data/lib/ripper_ruby_parser/sexp_handlers/loops.rb +10 -6
  15. data/lib/ripper_ruby_parser/sexp_handlers/method_calls.rb +59 -14
  16. data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +56 -32
  17. data/lib/ripper_ruby_parser/sexp_handlers/operators.rb +20 -27
  18. data/lib/ripper_ruby_parser/sexp_processor.rb +40 -10
  19. data/lib/ripper_ruby_parser/syntax_error.rb +2 -0
  20. data/lib/ripper_ruby_parser/unescape.rb +32 -11
  21. data/lib/ripper_ruby_parser/version.rb +3 -1
  22. data/test/end_to_end/comments_test.rb +2 -0
  23. data/test/end_to_end/comparison_test.rb +2 -0
  24. data/test/end_to_end/lib_comparison_test.rb +2 -0
  25. data/test/end_to_end/line_numbering_test.rb +2 -0
  26. data/test/end_to_end/samples_comparison_test.rb +5 -29
  27. data/test/end_to_end/test_comparison_test.rb +2 -0
  28. data/test/pt_testcase/pt_test.rb +2 -0
  29. data/test/ripper_ruby_parser/commenting_ripper_parser_test.rb +16 -2
  30. data/test/ripper_ruby_parser/parser_test.rb +17 -688
  31. data/test/ripper_ruby_parser/sexp_handlers/assignment_test.rb +459 -26
  32. data/test/ripper_ruby_parser/sexp_handlers/blocks_test.rb +152 -82
  33. data/test/ripper_ruby_parser/sexp_handlers/conditionals_test.rb +91 -0
  34. data/test/ripper_ruby_parser/sexp_handlers/literals_test.rb +331 -24
  35. data/test/ripper_ruby_parser/sexp_handlers/loops_test.rb +88 -0
  36. data/test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb +58 -5
  37. data/test/ripper_ruby_parser/sexp_handlers/methods_test.rb +392 -0
  38. data/test/ripper_ruby_parser/sexp_handlers/operators_test.rb +174 -12
  39. data/test/ripper_ruby_parser/sexp_processor_test.rb +8 -18
  40. data/test/ripper_ruby_parser/version_test.rb +2 -0
  41. data/test/samples/comments.rb +13 -0
  42. data/test/samples/conditionals.rb +23 -0
  43. data/test/samples/loops.rb +36 -0
  44. data/test/samples/misc.rb +157 -5
  45. data/test/samples/number.rb +7 -0
  46. data/test/samples/strings.rb +39 -0
  47. data/test/test_helper.rb +22 -1
  48. metadata +18 -12
  49. data/lib/ripper_ruby_parser/sexp_handlers/arguments.rb +0 -29
  50. data/lib/ripper_ruby_parser/sexp_handlers/arrays.rb +0 -21
  51. data/lib/ripper_ruby_parser/sexp_handlers/hashes.rb +0 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab036613dacd6865ca8103db78c67273d6fad340e3a6a7ed1fe5450c5511cc05
4
- data.tar.gz: 182feec3370738d6d5516e5615022a045ed717edf489cc694ac02eda97e6e6bb
3
+ metadata.gz: 05e260a0b747a456d0a25ce09e6607bcaf29fcfef68eec466c87e502ad27d435
4
+ data.tar.gz: 77a0985075b11dd8461dd96a4b1def05c34bee338713701cfc2fa0fa026414bd
5
5
  SHA512:
6
- metadata.gz: 9c5f17c00265aaf9df0741c5afee3b90f000141d4285bce067953bb1feac645779c8e4b9db2319baa9a3f6822b46a9f6edbeef87af1177b22a03cd437fecad51
7
- data.tar.gz: 7001633d0756ab5afb2b2813572550f3cea1df75c11e82fe8117e4243aaa6cf4386512b3a7754b76f0a5a8be7c4b49f8b1e5a0148b4465e7aa72658b7c951acc
6
+ metadata.gz: a9d499d3e3d60b5d758884e0f4c3667e19c58943f0662aa0936e8188ba6a8767b844734a930e32e7485196abc5e050986f27cd491829500c639562de3d1e54e9
7
+ data.tar.gz: 8476d87b6a80339014fc7e47a1d795ce6554d9f89650a272ea7040a7e84922b491ef0dd48a2fa858d436b3538d5c670624303a5f9a11b4f501fc3351a3d6aa15
@@ -1,12 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0 / 2019-03-18
4
+
5
+ * Process embedded documents as comments
6
+ * Handle \u{xxxx} form of unicode escape sequence
7
+ * Treat keyword rest arguments (double spats) as local variables, for blocks
8
+ and for methods.
9
+ Versions of Ripper before CRuby 2.6 do not handle these correctly, so
10
+ RipperRubyParser adds its own accounting of these parameters.
11
+ * Do not unescape heredocs with single quotes. These are heredocs where the
12
+ marker is a single-quoted string
13
+ * Increase compatibility when handling a begin..end block, e.g., as an assigned
14
+ value, as a receiver, as a condition
15
+ * Fix handling of for loops that assign to multiple loop variables
16
+ * Handle aliasing for method names that are keywords, e.g., `alias next succ`
17
+ * Do not crash on rational literals
18
+ * Restore `#extra_compatible` flag
19
+ * Match RubyParser bug in handling rescue modifier when combined with
20
+ assignment. See RubyParser
21
+ [issue #227](https://github.com/seattlerb/ruby_parser/issues/227).
22
+ This behavior is only enabled when `#extra_compatible` is set to true
23
+ * Fix compatibility when assigning to a class variable inside the method
24
+ argument specification
25
+ * Match RubyParser's handling of byte sequences in second and further literal
26
+ parts of strings with interpolations. This behavior is only enabled when
27
+ `#extra_compatible` is set to true
28
+ * Require Ruby 2.3 or higher
29
+ * Mark as compatible with RubyParser 3.12.0
30
+ * Match RubyParser's handling of block keyword rest arguments.
31
+ This behavior is only enabled when `#extra_compatible` is set to true
32
+ * Support Ruby 2.6
33
+
3
34
  ## 1.4.2 / 2018-04-03
4
35
 
5
36
  * Fix handling of strings delimited by %()
6
37
  * Handle line continuations in stringlike literals
7
38
  - Handle line continuations in string and regexp literals
8
39
  - Handle escaped line continuations
9
- - Hanlde line continuations in word and symbol list literals
40
+ - Handle line continuations in word and symbol list literals
10
41
  * Force encoding of string literals to UTF-8 if the result is valid
11
42
  * Fix handling of range operators with float literals
12
43
 
@@ -40,6 +71,7 @@
40
71
  * Improve handling of boolean operators with parenthes
41
72
  * Improve compatibility for begin..end blocks used as method and operator
42
73
  arguments.
74
+ * Support Ruby 2.5
43
75
  * Drop support for Ruby 2.0 and 2.1
44
76
  * Handle `__ENCODING__` constant.
45
77
 
data/README.md CHANGED
@@ -2,35 +2,67 @@
2
2
 
3
3
  by Matijs van Zuijlen
4
4
 
5
- http://www.github.com/mvz/ripper_ruby_parser
6
-
7
5
  ## Description
8
6
 
9
7
  Parse with Ripper, produce sexps that are compatible with RubyParser.
10
8
 
11
9
  ## Features/Notes
12
10
 
13
- * Drop-in replacement for RubyParser.
14
- * Should handle 1.9 and later syntax gracefully.
15
- * Requires MRI 2.2 or higher
11
+ * Drop-in replacement for RubyParser
12
+ * Should handle 1.9 and later syntax gracefully
13
+ * Requires MRI 2.3 or higher
14
+ * Compatible with RubyParser 3.12.0
15
+
16
+ ## Known incompatibilities
17
+
18
+ RipperRubyParser has some incompatibilities with RubyParser. For some of these,
19
+ the behavior can be changed by turning on extra-compatible mode.
20
+
21
+ The following incompatibilities cannot be changed:
22
+
23
+ * RipperRubyParser won't handle non-UTF-8 files without an encoding comment,
24
+ just like regular Ruby
25
+ * RipperRubyParser keeps carriage return characters in heredocs that include them
26
+ * RipperRubyParser does not attempt to match RubyParser's line numbering bugs
27
+
28
+ The following incompatibilities can be made compatible by turning on
29
+ extra-compatible mode:
30
+
31
+ * RipperRubyParser handles unicode escapes without braces correctly, while
32
+ RubyParser absorbs trailing hexadecimal characters
33
+ * RipperRubyParser handles the rescue modifier correctly, while RubyParser
34
+ still contains a bug that was fixed in Ruby 2.4. See RubyParser
35
+ [issue #227](https://github.com/seattlerb/ruby_parser/issues/227).
36
+ * RubyParser handles byte sequences in second and further literal parts of a
37
+ strings with interpolations differently. RipperRubyParser will convert these
38
+ to unicode if possible.
39
+ * RubyParser handles byte sequences in heredocs and interpolating word lists
40
+ differently. RipperRubyParser will convert these to unicode if possible.
16
41
 
17
42
  ## Install
18
43
 
19
- * gem install ripper_ruby_parser
44
+ gem install ripper_ruby_parser
20
45
 
21
46
  ## Synopsis
22
47
 
23
48
  require 'ripper_ruby_parser'
24
49
 
25
50
  parser = RipperRubyParser::Parser.new
26
- result = parser.parse "puts 'Hello World'"
27
- p result
51
+ parser.parse "puts 'Hello World'"
28
52
  # => s(:call, nil, :puts, s(:arglist, s(:str, "Hello World!")))
29
53
 
54
+ parser.parse '"foo\u273bbar"'
55
+ # => s(:str, "foo✻bar")
56
+
57
+ parser.extra_compatible = true
58
+
59
+ parser.parse '"foo\u273bbar"'
60
+ # => s(:str, "foo✻r")
61
+
30
62
  ## Requirements
31
63
 
32
64
  * Ruby 2.2 or higher
33
- * sexp_processor
65
+ * `sexp_processor`
34
66
 
35
67
  ## Hacking and contributing
36
68
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/clean'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'rake/testtask'
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ripper_ruby_parser/version'
2
4
  require 'ripper_ruby_parser/parser'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ripper'
2
4
  require 'ripper_ruby_parser/syntax_error'
3
5
  require 'ripper_ruby_parser/unescape'
@@ -10,14 +12,16 @@ module RipperRubyParser
10
12
  class CommentingRipperParser < Ripper::SexpBuilder
11
13
  def initialize(*args)
12
14
  super
13
- @comment = nil
15
+ @comment = ''
14
16
  @comment_stack = []
15
17
  @delimiter_stack = []
18
+ @space_before = false
19
+ @seen_space = false
16
20
  @in_symbol = false
17
21
  end
18
22
 
19
23
  def parse
20
- result = suppress_warnings { super }
24
+ result = super
21
25
  raise 'Ripper parse failed.' unless result
22
26
 
23
27
  Sexp.from_array(result)
@@ -25,13 +29,22 @@ module RipperRubyParser
25
29
 
26
30
  def on_backtick(delimiter)
27
31
  @delimiter_stack.push delimiter
28
- super
29
32
  end
30
33
 
31
34
  def on_comment(tok)
32
- @comment ||= ''
33
35
  @comment += tok
34
- super
36
+ end
37
+
38
+ def on_embdoc_beg(tok)
39
+ @comment += tok
40
+ end
41
+
42
+ def on_embdoc(tok)
43
+ @comment += tok
44
+ end
45
+
46
+ def on_embdoc_end(tok)
47
+ @comment += tok
35
48
  end
36
49
 
37
50
  def on_kw(tok)
@@ -39,7 +52,7 @@ module RipperRubyParser
39
52
  when 'class', 'def', 'module'
40
53
  unless @in_symbol
41
54
  @comment_stack.push [tok.to_sym, @comment]
42
- @comment = nil
55
+ @comment = ''
43
56
  end
44
57
  end
45
58
  super
@@ -75,12 +88,10 @@ module RipperRubyParser
75
88
 
76
89
  def on_heredoc_beg(delimiter)
77
90
  @delimiter_stack.push delimiter
78
- super
79
91
  end
80
92
 
81
- def on_heredoc_end(delimiter)
93
+ def on_heredoc_end(_delimiter)
82
94
  @delimiter_stack.pop
83
- super
84
95
  end
85
96
 
86
97
  def on_mlhs_new
@@ -105,7 +116,6 @@ module RipperRubyParser
105
116
 
106
117
  def on_qsymbols_beg(delimiter)
107
118
  @delimiter_stack.push delimiter
108
- super
109
119
  end
110
120
 
111
121
  def on_qsymbols_new
@@ -118,7 +128,6 @@ module RipperRubyParser
118
128
 
119
129
  def on_qwords_beg(delimiter)
120
130
  @delimiter_stack.push delimiter
121
- super
122
131
  end
123
132
 
124
133
  def on_qwords_new
@@ -131,7 +140,6 @@ module RipperRubyParser
131
140
 
132
141
  def on_regexp_beg(delimiter)
133
142
  @delimiter_stack.push delimiter
134
- super
135
143
  end
136
144
 
137
145
  def on_regexp_end(delimiter)
@@ -161,7 +169,6 @@ module RipperRubyParser
161
169
 
162
170
  def on_symbols_beg(delimiter)
163
171
  @delimiter_stack.push delimiter
164
- super
165
172
  end
166
173
 
167
174
  def on_symbols_new
@@ -174,27 +181,10 @@ module RipperRubyParser
174
181
 
175
182
  def on_tstring_beg(delimiter)
176
183
  @delimiter_stack.push delimiter
177
- super
178
184
  end
179
185
 
180
186
  def on_tstring_content(content)
181
- content = case @delimiter_stack.last
182
- when /^<</
183
- Unescape.unescape(content)
184
- when '"', '`', ':"', /^%Q.$/, /^%.$/
185
- Unescape.fix_encoding(Unescape.unescape(content))
186
- when /^%[WI].$/
187
- Unescape.fix_encoding(Unescape.unescape_wordlist_word(content))
188
- when "'", ":'", /^%q.$/
189
- Unescape.simple_unescape(content)
190
- when '/', /^%r.$/
191
- Unescape.unescape_regexp(content)
192
- when /^%[wi].$/
193
- Unescape.simple_unescape_wordlist_word(content)
194
- else
195
- content
196
- end
197
- super(content)
187
+ super(content) << @delimiter_stack.last
198
188
  end
199
189
 
200
190
  def on_tstring_end(delimiter)
@@ -212,7 +202,6 @@ module RipperRubyParser
212
202
 
213
203
  def on_words_beg(delimiter)
214
204
  @delimiter_stack.push delimiter
215
- super
216
205
  end
217
206
 
218
207
  def on_words_new
@@ -238,7 +227,6 @@ module RipperRubyParser
238
227
 
239
228
  def on_sp(_token)
240
229
  @seen_space = true
241
- super
242
230
  end
243
231
 
244
232
  def on_int(_token)
@@ -269,7 +257,6 @@ module RipperRubyParser
269
257
  def on_symbeg(delimiter)
270
258
  @delimiter_stack.push delimiter
271
259
  @in_symbol = true
272
- super
273
260
  end
274
261
 
275
262
  def on_symbol(*args)
@@ -280,7 +267,6 @@ module RipperRubyParser
280
267
 
281
268
  def on_embexpr_beg(_delimiter)
282
269
  @in_symbol = false
283
- super
284
270
  end
285
271
 
286
272
  def on_dyna_symbol(*args)
@@ -312,16 +298,8 @@ module RipperRubyParser
312
298
 
313
299
  def commentize(_name, exp)
314
300
  _tok, comment = @comment_stack.pop
315
- @comment = nil
316
- [:comment, comment || '', exp]
317
- end
318
-
319
- def suppress_warnings
320
- old_verbose = $VERBOSE
321
- $VERBOSE = nil
322
- result = yield
323
- $VERBOSE = old_verbose
324
- result
301
+ @comment = ''
302
+ [:comment, comment, exp]
325
303
  end
326
304
  end
327
305
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ripper_ruby_parser/commenting_ripper_parser'
2
4
  require 'ripper_ruby_parser/sexp_processor'
3
5
 
@@ -5,13 +7,21 @@ module RipperRubyParser
5
7
  # Main parser class. Brings together Ripper and our
6
8
  # RipperRubyParser::SexpProcessor.
7
9
  class Parser
10
+ attr_accessor :extra_compatible
11
+
12
+ def initialize
13
+ @extra_compatible = false
14
+ end
15
+
8
16
  def parse(source, filename = '(string)', lineno = 1)
9
17
  parser = CommentingRipperParser.new(source, filename, lineno)
10
18
  exp = parser.parse
11
19
 
12
- processor = SexpProcessor.new(filename: filename)
20
+ processor = SexpProcessor.new(filename: filename, extra_compatible: extra_compatible)
13
21
  result = processor.process exp
14
22
 
23
+ result = result[1] if result.sexp_type == :begin
24
+
15
25
  if result.sexp_type == :void_stmt
16
26
  nil
17
27
  else
@@ -1,11 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ripper_ruby_parser/sexp_handlers/helper_methods'
2
4
 
3
- require 'ripper_ruby_parser/sexp_handlers/arguments'
4
- require 'ripper_ruby_parser/sexp_handlers/arrays'
5
5
  require 'ripper_ruby_parser/sexp_handlers/assignment'
6
6
  require 'ripper_ruby_parser/sexp_handlers/blocks'
7
7
  require 'ripper_ruby_parser/sexp_handlers/conditionals'
8
- require 'ripper_ruby_parser/sexp_handlers/hashes'
9
8
  require 'ripper_ruby_parser/sexp_handlers/literals'
10
9
  require 'ripper_ruby_parser/sexp_handlers/loops'
11
10
  require 'ripper_ruby_parser/sexp_handlers/method_calls'
@@ -21,12 +20,9 @@ module RipperRubyParser
21
20
  base.class_eval do
22
21
  include HelperMethods
23
22
 
24
- include Arguments
25
- include Arrays
26
23
  include Assignment
27
24
  include Blocks
28
25
  include Conditionals
29
- include Hashes
30
26
  include Literals
31
27
  include Loops
32
28
  include MethodCalls
@@ -1,17 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RipperRubyParser
2
4
  module SexpHandlers
3
5
  # Sexp handlers for assignments
4
6
  module Assignment
5
7
  def process_assign(exp)
6
8
  _, lvalue, value = exp.shift 3
9
+ if extra_compatible && value.sexp_type == :rescue_mod
10
+ if [:command, :command_call].include? value[1].sexp_type
11
+ return process s(:rescue_mod, s(:assign, lvalue, value[1]), value[2])
12
+ end
13
+ end
14
+
7
15
  lvalue = process(lvalue)
8
16
  value = process(value)
9
17
 
10
18
  case value.sexp_type
11
19
  when :mrhs
12
20
  value.sexp_type = :svalue
13
- when :fake_array
21
+ when :args
14
22
  value = s(:svalue, s(:array, *value.sexp_body))
23
+ else
24
+ value = unwrap_begin(value)
15
25
  end
16
26
 
17
27
  with_line_number(lvalue.line,
@@ -21,30 +31,26 @@ module RipperRubyParser
21
31
  def process_massign(exp)
22
32
  _, left, right = exp.shift 3
23
33
 
24
- left = process left
25
-
26
- left = left[1] if left.sexp_type == :masgn
27
- left = create_multiple_assignment_sub_types left.sexp_body
28
-
34
+ left = process(left).last
29
35
  right = process(right)
30
36
 
31
37
  case right.sexp_type
32
- when :fake_array
33
- right[0] = :array
38
+ when :args
39
+ right.sexp_type = :array
34
40
  when :mrhs
35
- right = right[1]
41
+ _, right = right
36
42
  else
37
43
  right = s(:to_ary, right)
38
44
  end
39
45
 
40
- s(:masgn, s(:array, *left), right)
46
+ s(:masgn, left, right)
41
47
  end
42
48
 
43
49
  def process_mrhs_new_from_args(exp)
44
50
  _, inner, last = exp.shift 3
45
- inner = map_process_sexp_body_compact(inner)
46
- inner.push process(last) if last
47
- s(:fake_array, *inner)
51
+ process(inner).tap do |result|
52
+ result.push process(last) if last
53
+ end
48
54
  end
49
55
 
50
56
  def process_mrhs_add_star(exp)
@@ -52,34 +58,47 @@ module RipperRubyParser
52
58
  end
53
59
 
54
60
  def process_mlhs_add_star(exp)
55
- _, args, splatarg = exp.shift 3
56
- items = process args
57
- items << s(:splat, process(splatarg))
61
+ _, base, splatarg = exp.shift 3
62
+ masgn = process base
63
+
64
+ splat = process(splatarg)
65
+ splat_item = if splat.nil?
66
+ s(:splat)
67
+ else
68
+ s(:splat, create_valueless_assignment_sub_type(splat))
69
+ end
70
+
71
+ masgn.last << splat_item
72
+ masgn
58
73
  end
59
74
 
60
75
  def process_mlhs_add_post(exp)
61
76
  _, base, rest = exp.shift 3
62
- process(base).push(*process(rest).sexp_body)
77
+ base = process(base)
78
+ rest = process(rest)
79
+ base.last.push(*rest.last.sexp_body)
80
+ base
63
81
  end
64
82
 
65
83
  def process_mlhs_paren(exp)
66
84
  _, contents = exp.shift 2
67
85
 
68
- items = process(contents)
86
+ process(contents)
87
+ end
69
88
 
70
- if items.sexp_type == :mlhs
71
- s(:masgn, s(:array, *create_multiple_assignment_sub_types(items.sexp_body)))
72
- else
73
- items
74
- end
89
+ def process_mlhs(exp)
90
+ _, *rest = shift_all exp
91
+
92
+ items = map_process_list(rest)
93
+ s(:masgn, s(:array, *create_multiple_assignment_sub_types(items)))
75
94
  end
76
95
 
77
96
  def process_opassign(exp)
78
- _, lvalue, operator, value = exp.shift 4
97
+ _, lvalue, (_, operator,), value = exp.shift 4
79
98
 
80
99
  lvalue = process(lvalue)
81
100
  value = process(value)
82
- operator = operator[1].delete('=').to_sym
101
+ operator = operator.chop.to_sym
83
102
 
84
103
  create_operator_assignment_sub_type lvalue, value, operator
85
104
  end
@@ -88,15 +107,7 @@ module RipperRubyParser
88
107
 
89
108
  def create_multiple_assignment_sub_types(sexp_list)
90
109
  sexp_list.map! do |item|
91
- if item.sexp_type == :splat
92
- if item[1].nil?
93
- s(:splat)
94
- else
95
- s(:splat, create_valueless_assignment_sub_type(item[1]))
96
- end
97
- else
98
- create_valueless_assignment_sub_type item
99
- end
110
+ create_valueless_assignment_sub_type item
100
111
  end
101
112
  end
102
113
 
@@ -116,11 +127,13 @@ module RipperRubyParser
116
127
  case lvalue.sexp_type
117
128
  when :aref_field
118
129
  _, arr, arglist = lvalue
130
+ arglist.sexp_type = :arglist
119
131
  s(:op_asgn1, arr, arglist, operator, value)
120
132
  when :field
121
133
  _, obj, _, (_, field) = lvalue
122
134
  s(:op_asgn2, obj, :"#{field}=", operator, value)
123
135
  else
136
+ value = unwrap_begin(value)
124
137
  if (mapped = OPERATOR_ASSIGNMENT_MAP[operator])
125
138
  s(mapped, lvalue, create_assignment_sub_type(lvalue, value))
126
139
  else
@@ -158,7 +171,8 @@ module RipperRubyParser
158
171
  }.freeze
159
172
 
160
173
  def create_assignment_sub_type(lvalue, value)
161
- s(map_assignment_lvalue_type(lvalue.sexp_type), lvalue[1], value)
174
+ lvalue_type, lvalue_value = lvalue
175
+ s(map_assignment_lvalue_type(lvalue_type), lvalue_value, value)
162
176
  end
163
177
 
164
178
  def map_assignment_lvalue_type(type)