parser 2.3.1.4 → 2.3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17bdbdce7c902877c996867706727505f780def2
4
- data.tar.gz: 469882a9f9140cf06de8fd9d2c9d2eb80b9a9f55
3
+ metadata.gz: 73ca61e5ab86f82798f86bc14407c958d2b08a40
4
+ data.tar.gz: 9d88b4bc43581891ee5612e9c1c1d2288aa6fcc7
5
5
  SHA512:
6
- metadata.gz: 0ab79279d208273259b37fa4091690f70814c211f96d4dd408c38a634dc66604b52f30ea8cd504319ac1fff7ed599db85321b6d8b08945b7389fd62a564b370c
7
- data.tar.gz: 1ff67f781e7dc36b4edf4271c7c95a35f0aaa0f7b1627f8aac2079f53e420dfa8ae1ce31b60d4619205a9ea9cd5936bb04916014b0da90a428ceb4501b8b3b41
6
+ metadata.gz: c5c8232ddd5b94e0aff2dddec620201e99ad7db4bc4d7362e2feb2d5d4fb7456f861d6905750325cc4429e4f9a2946d9ff475d6ae3f5914af78c45fbe3e3a21e
7
+ data.tar.gz: 61255e34c1b006ec82b946aa173c6e2e4a48f7491db05392e0d667c3e834dfbb598e204eefd6e871a8d4bec2d254e71a1de5e65bf1db8917dfe06b76f26b34b1
@@ -1,6 +1,19 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v2.3.2.0 (2016-11-20)
5
+ ---------------------
6
+
7
+ API modifications:
8
+ * parser/current: update 2.3 branch to 2.3.2. (whitequark)
9
+ * Introduce (procarg0) node for a single required block argument. (Ilya Bylich)
10
+
11
+ Bugs fixed:
12
+ * {macruby,ruby{19,20,21,22,23,24}}.y: "x::A += m x": treat as constant assignment. (whitequark)
13
+ * ruby24.y: "x += raise y rescue nil": bind rescue tighter than tOP_ASGN. (whitequark)
14
+ * ruby24.y: "x = raise y rescue nil": bind rescue tighter than =. (whitequark)
15
+ * Builders::Default: "begin; else; 1; end": fix a crash. (whitequark)
16
+
4
17
  v2.3.1.4 (2016-09-19)
5
18
  ---------------------
6
19
 
@@ -92,7 +105,7 @@ Bugs fixed:
92
105
  * Add :csend to Parser::Meta::NODE_TYPES (Markus Schirp)
93
106
  * lexer/dedenter: "\<\<x\n y\\n z\nx": don't dedent after escaped newline. (whitequark)
94
107
 
95
- v2.3.1.4 (2016-01-16)
108
+ v2.3.2.0 (2016-01-16)
96
109
  ---------------------
97
110
 
98
111
  v2.3.0.1 (2016-01-14)
data/README.md CHANGED
@@ -19,10 +19,15 @@ MacRuby and RubyMotion support sponsored by [CodeClimate](http://codeclimate.com
19
19
 
20
20
  ## Usage
21
21
 
22
- Parse a chunk of code:
22
+ Load Parser (see the [backwards compatibility](#backwards-compatibility) section
23
+ below for explanation of `emit_*` calls):
23
24
 
24
25
  require 'parser/current'
25
- Parser::Builders::Default.emit_lambda = true # opt-in to most recent AST format
26
+ # opt-in to most recent AST format:
27
+ Parser::Builders::Default.emit_lambda = true
28
+ Parser::Builders::Default.emit_procarg0 = true
29
+
30
+ Parse a chunk of code:
26
31
 
27
32
  p Parser::CurrentRuby.parse("2 + 2")
28
33
  # (send
@@ -197,6 +202,23 @@ $ ruby-parse -e '(foo) while cond'
197
202
 
198
203
  (Parser also needs the `(kwbegin)` node type internally, and it is highly problematic to map it back to `(begin)`.)
199
204
 
205
+ ## Backwards compatibility
206
+
207
+ Parser does _not_ use semantic versioning. Parser versions are structured as `x.y.z.t`,
208
+ where `x.y.z` indicates the most recent supported Ruby release (support for every
209
+ Ruby release that is chronologically earlier is implied), and `t` is a monotonically
210
+ increasing number.
211
+
212
+ The public API of Parser as well as the AST format (as listed in the documentation)
213
+ are considered stable forever, although support for old Ruby versions may be removed
214
+ at some point.
215
+
216
+ Sometimes it is necessary to modify the format of AST nodes that are already being emitted
217
+ in a way that would break existing applications. To avoid such breakage, applications
218
+ must opt-in to these modifications; without explicit opt-in, Parser will continue to emit
219
+ the old AST node format. The most recent set of opt-ins is speified in
220
+ the [usage section](#usage) of this README.
221
+
200
222
  ## Compatibility with Ruby MRI
201
223
 
202
224
  Unfortunately, Ruby MRI often changes syntax in patchlevel versions. This has happened, at least, for every release since 1.9; for example, commits [c5013452](https://github.com/ruby/ruby/commit/c501345218dc5fb0fae90d56a0c6fd19d38df5bb) and [04bb9d6b](https://github.com/ruby/ruby/commit/04bb9d6b75a55d4000700769eead5a5cb942c25b) were backported all the way from HEAD to 1.9. Moreover, there is no simple way to track these changes.
@@ -912,6 +912,25 @@ Format:
912
912
 
913
913
  Begin of the `expression` points to `&`.
914
914
 
915
+ ### Auto-expanding proc argument (1.9)
916
+
917
+ In Ruby 1.9 and later, when a proc-like closure (i.e. a closure
918
+ created by capturing a block or with the `proc` method, but not
919
+ with the `->{}` syntax or the `lambda` method) has exactly one
920
+ argument, and it is called with more than one argument, the behavior
921
+ is as if the array of all arguments was instead passed as the sole
922
+ argument. This behavior can be prevented by adding a comma after
923
+ the sole argument (e.g. `|foo,|`).
924
+
925
+ Format:
926
+
927
+ ~~~
928
+ (procarg0 :foo)
929
+ "|foo|"
930
+ ~~~ expression
931
+ ~~~ name
932
+ ~~~
933
+
915
934
  ### Expression arguments
916
935
 
917
936
  Ruby 1.8 allows to use arbitrary expressions as block arguments,
@@ -121,6 +121,7 @@ module Parser
121
121
  alias on_kwarg process_argument_node
122
122
  alias on_kwoptarg process_argument_node
123
123
  alias on_kwrestarg process_argument_node
124
+ alias on_procarg0 process_argument_node
124
125
 
125
126
  alias on_arg_expr process_regular_node
126
127
  alias on_restarg_expr process_regular_node
@@ -22,11 +22,30 @@ module Parser
22
22
 
23
23
  @emit_lambda = false
24
24
 
25
+ class << self
26
+ ##
27
+ # AST compatibility attribute; block arguments of `m { |a| }` are
28
+ # not semantically equivalent to block arguments of `m { |a,| }` or `m { |a, b| }`,
29
+ # all new code should set this attribute to true.
30
+ #
31
+ # If set to false (the default), arguments of `m { |a| }` are emitted as
32
+ # `s(:args, s(:arg, :a))`
33
+ #
34
+ # If set to true, arguments of `m { |a| }` are emitted as
35
+ # `s(:args, s(:procarg0, :a))
36
+ #
37
+ # @return [Boolean]
38
+ attr_accessor :emit_procarg0
39
+ end
40
+
41
+ @emit_procarg0 = false
42
+
25
43
  class << self
26
44
  ##
27
45
  # @api private
28
46
  def modernize
29
47
  @emit_lambda = true
48
+ @emit_procarg0 = true
30
49
  end
31
50
  end
32
51
 
@@ -637,6 +656,14 @@ module Parser
637
656
  arg_prefix_map(amper_t, name_t))
638
657
  end
639
658
 
659
+ def procarg0(arg)
660
+ if self.class.emit_procarg0
661
+ arg.updated(:procarg0)
662
+ else
663
+ arg
664
+ end
665
+ end
666
+
640
667
  # Ruby 1.8 block arguments
641
668
 
642
669
  def arg_expr(expr)
@@ -984,10 +1011,12 @@ module Parser
984
1011
  end
985
1012
  elsif else_t
986
1013
  statements = []
987
- if compound_stmt.type == :begin
988
- statements += compound_stmt.children
989
- else
990
- statements.push(compound_stmt)
1014
+ if !compound_stmt.nil?
1015
+ if compound_stmt.type == :begin
1016
+ statements += compound_stmt.children
1017
+ else
1018
+ statements.push(compound_stmt)
1019
+ end
991
1020
  end
992
1021
  statements.push(
993
1022
  n(:begin, [ else_ ],
@@ -1110,7 +1139,7 @@ module Parser
1110
1139
  case this_arg.type
1111
1140
  when :arg, :optarg, :restarg, :blockarg,
1112
1141
  :kwarg, :kwoptarg, :kwrestarg,
1113
- :shadowarg
1142
+ :shadowarg, :procarg0
1114
1143
 
1115
1144
  this_name, = *this_arg
1116
1145
 
@@ -55,7 +55,7 @@ module Parser
55
55
  CurrentRuby = Ruby22
56
56
 
57
57
  when /^2\.3\./
58
- current_version = '2.3.1'
58
+ current_version = '2.3.2'
59
59
  if RUBY_VERSION != current_version
60
60
  warn_syntax_deviation 'parser/ruby23', current_version
61
61
  end
@@ -206,10 +206,7 @@ rule
206
206
  }
207
207
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
208
208
  {
209
- result = @builder.op_assign(
210
- @builder.call_method(
211
- val[0], val[1], val[2]),
212
- val[3], val[4])
209
+ diagnostic :error, :const_reassignment, nil, val[3]
213
210
  }
214
211
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
215
212
  {
@@ -1350,9 +1347,6 @@ rule
1350
1347
  concat(val[3])
1351
1348
  }
1352
1349
  | f_arg tCOMMA
1353
- {
1354
- result = [@builder.multi_lhs(nil, val[0], nil)]
1355
- }
1356
1350
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
1357
1351
  {
1358
1352
  result = val[0].
@@ -1362,7 +1356,11 @@ rule
1362
1356
  }
1363
1357
  | f_arg opt_f_block_arg
1364
1358
  {
1365
- result = val[0].concat(val[1])
1359
+ if val[1].empty? && val[0].size == 1
1360
+ result = [@builder.procarg0(val[0][0])]
1361
+ else
1362
+ result = val[0].concat(val[1])
1363
+ end
1366
1364
  }
1367
1365
  | f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
1368
1366
  {
@@ -48,6 +48,7 @@ module Parser
48
48
  :odd_hash => 'odd number of entries for a hash',
49
49
  :singleton_literal => 'cannot define a singleton method for a literal',
50
50
  :dynamic_const => 'dynamic constant assignment',
51
+ :const_reassignment => 'constant re-assignment',
51
52
  :module_in_def => 'module definition in method body',
52
53
  :class_in_def => 'class definition in method body',
53
54
  :unexpected_percent_str => '%{type}: unknown type of percent-literal',
@@ -1259,9 +1259,6 @@ rule
1259
1259
 
1260
1260
  block_var: block_par
1261
1261
  | block_par tCOMMA
1262
- {
1263
- result = [@builder.multi_lhs(nil, val[0], nil)]
1264
- }
1265
1262
  | block_par tCOMMA tAMPER lhs
1266
1263
  {
1267
1264
  result = val[0].
@@ -203,10 +203,7 @@ rule
203
203
  }
204
204
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
205
205
  {
206
- result = @builder.op_assign(
207
- @builder.call_method(
208
- val[0], val[1], val[2]),
209
- val[3], val[4])
206
+ diagnostic :error, :const_reassignment, nil, val[3]
210
207
  }
211
208
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
212
209
  {
@@ -1330,9 +1327,6 @@ rule
1330
1327
  concat(val[3])
1331
1328
  }
1332
1329
  | f_arg tCOMMA
1333
- {
1334
- result = [@builder.multi_lhs(nil, val[0], nil)]
1335
- }
1336
1330
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_f_block_arg
1337
1331
  {
1338
1332
  result = val[0].
@@ -1342,7 +1336,11 @@ rule
1342
1336
  }
1343
1337
  | f_arg opt_f_block_arg
1344
1338
  {
1345
- result = val[0].concat(val[1])
1339
+ if val[1].empty? && val[0].size == 1
1340
+ result = [@builder.procarg0(val[0][0])]
1341
+ else
1342
+ result = val[0].concat(val[1])
1343
+ end
1346
1344
  }
1347
1345
  | f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
1348
1346
  {
@@ -213,10 +213,9 @@ rule
213
213
  }
214
214
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
215
215
  {
216
- result = @builder.op_assign(
217
- @builder.call_method(
218
- val[0], val[1], val[2]),
219
- val[3], val[4])
216
+ const = @builder.const_op_assignable(
217
+ @builder.const_fetch(val[0], val[1], val[2]))
218
+ result = @builder.op_assign(const, val[3], val[4])
220
219
  }
221
220
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
222
221
  {
@@ -1385,9 +1384,6 @@ opt_block_args_tail:
1385
1384
  concat(val[3])
1386
1385
  }
1387
1386
  | f_arg tCOMMA
1388
- {
1389
- result = [@builder.multi_lhs(nil, val[0], nil)]
1390
- }
1391
1387
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1392
1388
  {
1393
1389
  result = val[0].
@@ -1397,7 +1393,11 @@ opt_block_args_tail:
1397
1393
  }
1398
1394
  | f_arg opt_block_args_tail
1399
1395
  {
1400
- result = val[0].concat(val[1])
1396
+ if val[1].empty? && val[0].size == 1
1397
+ result = [@builder.procarg0(val[0][0])]
1398
+ else
1399
+ result = val[0].concat(val[1])
1400
+ end
1401
1401
  }
1402
1402
  | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1403
1403
  {
@@ -210,10 +210,9 @@ rule
210
210
  }
211
211
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
212
212
  {
213
- result = @builder.op_assign(
214
- @builder.call_method(
215
- val[0], val[1], val[2]),
216
- val[3], val[4])
213
+ const = @builder.const_op_assignable(
214
+ @builder.const_fetch(val[0], val[1], val[2]))
215
+ result = @builder.op_assign(const, val[3], val[4])
217
216
  }
218
217
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
219
218
  {
@@ -1365,9 +1364,6 @@ opt_block_args_tail:
1365
1364
  concat(val[3])
1366
1365
  }
1367
1366
  | f_arg tCOMMA
1368
- {
1369
- result = [@builder.multi_lhs(nil, val[0], nil)]
1370
- }
1371
1367
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1372
1368
  {
1373
1369
  result = val[0].
@@ -1377,7 +1373,11 @@ opt_block_args_tail:
1377
1373
  }
1378
1374
  | f_arg opt_block_args_tail
1379
1375
  {
1380
- result = val[0].concat(val[1])
1376
+ if val[1].empty? && val[0].size == 1
1377
+ result = [@builder.procarg0(val[0][0])]
1378
+ else
1379
+ result = val[0].concat(val[1])
1380
+ end
1381
1381
  }
1382
1382
  | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1383
1383
  {
@@ -210,10 +210,9 @@ rule
210
210
  }
211
211
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
212
212
  {
213
- result = @builder.op_assign(
214
- @builder.call_method(
215
- val[0], val[1], val[2]),
216
- val[3], val[4])
213
+ const = @builder.const_op_assignable(
214
+ @builder.const_fetch(val[0], val[1], val[2]))
215
+ result = @builder.op_assign(const, val[3], val[4])
217
216
  }
218
217
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
219
218
  {
@@ -1364,9 +1363,6 @@ opt_block_args_tail:
1364
1363
  concat(val[3])
1365
1364
  }
1366
1365
  | f_arg tCOMMA
1367
- {
1368
- result = [@builder.multi_lhs(nil, val[0], nil)]
1369
- }
1370
1366
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1371
1367
  {
1372
1368
  result = val[0].
@@ -1376,7 +1372,11 @@ opt_block_args_tail:
1376
1372
  }
1377
1373
  | f_arg opt_block_args_tail
1378
1374
  {
1379
- result = val[0].concat(val[1])
1375
+ if val[1].empty? && val[0].size == 1
1376
+ result = [@builder.procarg0(val[0][0])]
1377
+ else
1378
+ result = val[0].concat(val[1])
1379
+ end
1380
1380
  }
1381
1381
  | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1382
1382
  {
@@ -210,10 +210,9 @@ rule
210
210
  }
211
211
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
212
212
  {
213
- result = @builder.op_assign(
214
- @builder.call_method(
215
- val[0], val[1], val[2]),
216
- val[3], val[4])
213
+ const = @builder.const_op_assignable(
214
+ @builder.const_fetch(val[0], val[1], val[2]))
215
+ result = @builder.op_assign(const, val[3], val[4])
217
216
  }
218
217
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
219
218
  {
@@ -1364,9 +1363,6 @@ opt_block_args_tail:
1364
1363
  concat(val[3])
1365
1364
  }
1366
1365
  | f_arg tCOMMA
1367
- {
1368
- result = [@builder.multi_lhs(nil, val[0], nil)]
1369
- }
1370
1366
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1371
1367
  {
1372
1368
  result = val[0].
@@ -1376,7 +1372,11 @@ opt_block_args_tail:
1376
1372
  }
1377
1373
  | f_arg opt_block_args_tail
1378
1374
  {
1379
- result = val[0].concat(val[1])
1375
+ if val[1].empty? && val[0].size == 1
1376
+ result = [@builder.procarg0(val[0][0])]
1377
+ else
1378
+ result = val[0].concat(val[1])
1379
+ end
1380
1380
  }
1381
1381
  | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1382
1382
  {
@@ -183,46 +183,45 @@ rule
183
183
  {
184
184
  result = @builder.multi_assign(val[0], val[1], val[2])
185
185
  }
186
- | var_lhs tOP_ASGN command_call
186
+ | var_lhs tOP_ASGN command_rhs
187
187
  {
188
188
  result = @builder.op_assign(val[0], val[1], val[2])
189
189
  }
190
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
190
+ | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_rhs
191
191
  {
192
192
  result = @builder.op_assign(
193
193
  @builder.index(
194
194
  val[0], val[1], val[2], val[3]),
195
195
  val[4], val[5])
196
196
  }
197
- | primary_value call_op tIDENTIFIER tOP_ASGN command_call
197
+ | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
198
198
  {
199
199
  result = @builder.op_assign(
200
200
  @builder.call_method(
201
201
  val[0], val[1], val[2]),
202
202
  val[3], val[4])
203
203
  }
204
- | primary_value call_op tCONSTANT tOP_ASGN command_call
204
+ | primary_value call_op tCONSTANT tOP_ASGN command_rhs
205
205
  {
206
206
  result = @builder.op_assign(
207
207
  @builder.call_method(
208
208
  val[0], val[1], val[2]),
209
209
  val[3], val[4])
210
210
  }
211
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
211
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
212
212
  {
213
- result = @builder.op_assign(
214
- @builder.call_method(
215
- val[0], val[1], val[2]),
216
- val[3], val[4])
213
+ const = @builder.const_op_assignable(
214
+ @builder.const_fetch(val[0], val[1], val[2]))
215
+ result = @builder.op_assign(const, val[3], val[4])
217
216
  }
218
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
217
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
219
218
  {
220
219
  result = @builder.op_assign(
221
220
  @builder.call_method(
222
221
  val[0], val[1], val[2]),
223
222
  val[3], val[4])
224
223
  }
225
- | backref tOP_ASGN command_call
224
+ | backref tOP_ASGN command_rhs
226
225
  {
227
226
  @builder.op_assign(val[0], val[1], val[2])
228
227
  }
@@ -237,14 +236,21 @@ rule
237
236
  }
238
237
  | expr
239
238
 
240
- command_asgn: lhs tEQL command_call
239
+ command_asgn: lhs tEQL command_rhs
241
240
  {
242
241
  result = @builder.assign(val[0], val[1], val[2])
243
242
  }
244
- | lhs tEQL command_asgn
243
+
244
+ command_rhs: command_call =tOP_ASGN
245
+ | command_call kRESCUE_MOD stmt
245
246
  {
246
- result = @builder.assign(val[0], val[1], val[2])
247
+ rescue_body = @builder.rescue_body(val[1],
248
+ nil, nil, nil,
249
+ nil, val[2])
250
+
251
+ result = @builder.begin_body(val[0], [ rescue_body ])
247
252
  }
253
+ | command_asgn
248
254
 
249
255
  expr: command_call
250
256
  | expr kAND expr
@@ -277,15 +283,9 @@ rule
277
283
  nil, val[3], nil)
278
284
  }
279
285
 
280
- cmd_brace_block: tLBRACE_ARG
286
+ cmd_brace_block: tLBRACE_ARG brace_body tRCURLY
281
287
  {
282
- @static_env.extend_dynamic
283
- }
284
- opt_block_param compstmt tRCURLY
285
- {
286
- result = [ val[0], val[2], val[3], val[4] ]
287
-
288
- @static_env.unextend
288
+ result = [ val[0], *val[1], val[2] ]
289
289
  }
290
290
 
291
291
  fcall: operation
@@ -586,75 +586,55 @@ rule
586
586
  | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
587
587
  | kUNTIL
588
588
 
589
- arg: lhs tEQL arg
589
+ arg: lhs tEQL arg_rhs
590
590
  {
591
591
  result = @builder.assign(val[0], val[1], val[2])
592
592
  }
593
- | lhs tEQL arg kRESCUE_MOD arg
594
- {
595
- rescue_body = @builder.rescue_body(val[3],
596
- nil, nil, nil,
597
- nil, val[4])
598
-
599
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
600
-
601
- result = @builder.assign(val[0], val[1], rescue_)
602
- }
603
- | var_lhs tOP_ASGN arg
593
+ | var_lhs tOP_ASGN arg_rhs
604
594
  {
605
595
  result = @builder.op_assign(val[0], val[1], val[2])
606
596
  }
607
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
608
- {
609
- rescue_body = @builder.rescue_body(val[3],
610
- nil, nil, nil,
611
- nil, val[4])
612
-
613
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
614
-
615
- result = @builder.op_assign(val[0], val[1], rescue_)
616
- }
617
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
597
+ | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg_rhs
618
598
  {
619
599
  result = @builder.op_assign(
620
600
  @builder.index(
621
601
  val[0], val[1], val[2], val[3]),
622
602
  val[4], val[5])
623
603
  }
624
- | primary_value call_op tIDENTIFIER tOP_ASGN arg
604
+ | primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
625
605
  {
626
606
  result = @builder.op_assign(
627
607
  @builder.call_method(
628
608
  val[0], val[1], val[2]),
629
609
  val[3], val[4])
630
610
  }
631
- | primary_value call_op tCONSTANT tOP_ASGN arg
611
+ | primary_value call_op tCONSTANT tOP_ASGN arg_rhs
632
612
  {
633
613
  result = @builder.op_assign(
634
614
  @builder.call_method(
635
615
  val[0], val[1], val[2]),
636
616
  val[3], val[4])
637
617
  }
638
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
618
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
639
619
  {
640
620
  result = @builder.op_assign(
641
621
  @builder.call_method(
642
622
  val[0], val[1], val[2]),
643
623
  val[3], val[4])
644
624
  }
645
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
625
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
646
626
  {
647
627
  const = @builder.const_op_assignable(
648
628
  @builder.const_fetch(val[0], val[1], val[2]))
649
629
  result = @builder.op_assign(const, val[3], val[4])
650
630
  }
651
- | tCOLON3 tCONSTANT tOP_ASGN arg
631
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
652
632
  {
653
633
  const = @builder.const_op_assignable(
654
634
  @builder.const_global(val[0], val[1]))
655
635
  result = @builder.op_assign(const, val[2], val[3])
656
636
  }
657
- | backref tOP_ASGN arg
637
+ | backref tOP_ASGN arg_rhs
658
638
  {
659
639
  result = @builder.op_assign(val[0], val[1], val[2])
660
640
  }
@@ -804,6 +784,16 @@ rule
804
784
  result = [ @builder.associate(nil, val[0], nil) ]
805
785
  }
806
786
 
787
+ arg_rhs: arg =tOP_ASGN
788
+ | arg kRESCUE_MOD arg
789
+ {
790
+ rescue_body = @builder.rescue_body(val[1],
791
+ nil, nil, nil,
792
+ nil, val[2])
793
+
794
+ result = @builder.begin_body(val[0], [ rescue_body ])
795
+ }
796
+
807
797
  paren_args: tLPAREN2 opt_call_args rparen
808
798
  {
809
799
  result = val
@@ -1364,9 +1354,6 @@ opt_block_args_tail:
1364
1354
  concat(val[3])
1365
1355
  }
1366
1356
  | f_arg tCOMMA
1367
- {
1368
- result = [@builder.multi_lhs(nil, val[0], nil)]
1369
- }
1370
1357
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1371
1358
  {
1372
1359
  result = val[0].
@@ -1376,7 +1363,11 @@ opt_block_args_tail:
1376
1363
  }
1377
1364
  | f_arg opt_block_args_tail
1378
1365
  {
1379
- result = val[0].concat(val[1])
1366
+ if val[1].empty? && val[0].size == 1
1367
+ result = [@builder.procarg0(val[0][0])]
1368
+ else
1369
+ result = val[0].concat(val[1])
1370
+ end
1380
1371
  }
1381
1372
  | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1382
1373
  {
@@ -1498,15 +1489,9 @@ opt_block_args_tail:
1498
1489
  result = [ val[0], val[1], val[2] ]
1499
1490
  }
1500
1491
 
1501
- do_block: kDO_BLOCK
1492
+ do_block: kDO_BLOCK do_body kEND
1502
1493
  {
1503
- @static_env.extend_dynamic
1504
- }
1505
- opt_block_param compstmt kEND
1506
- {
1507
- result = [ val[0], val[2], val[3], val[4] ]
1508
-
1509
- @static_env.unextend
1494
+ result = [ val[0], *val[1], val[2] ]
1510
1495
  }
1511
1496
 
1512
1497
  block_call: command do_block
@@ -1590,23 +1575,31 @@ opt_block_args_tail:
1590
1575
  result = @builder.index(val[0], val[1], val[2], val[3])
1591
1576
  }
1592
1577
 
1593
- brace_block: tLCURLY
1578
+ brace_block: tLCURLY brace_body tRCURLY
1594
1579
  {
1580
+ result = [ val[0], *val[1], val[2] ]
1581
+ }
1582
+ | kDO do_body kEND
1583
+ {
1584
+ result = [ val[0], *val[1], val[2] ]
1585
+ }
1586
+
1587
+ brace_body: {
1595
1588
  @static_env.extend_dynamic
1596
1589
  }
1597
- opt_block_param compstmt tRCURLY
1590
+ opt_block_param compstmt
1598
1591
  {
1599
- result = [ val[0], val[2], val[3], val[4] ]
1592
+ result = [ val[1], val[2] ]
1600
1593
 
1601
1594
  @static_env.unextend
1602
1595
  }
1603
- | kDO
1604
- {
1596
+
1597
+ do_body: {
1605
1598
  @static_env.extend_dynamic
1606
1599
  }
1607
- opt_block_param compstmt kEND
1600
+ opt_block_param compstmt
1608
1601
  {
1609
- result = [ val[0], val[2], val[3], val[4] ]
1602
+ result = [ val[1], val[2] ]
1610
1603
 
1611
1604
  @static_env.unextend
1612
1605
  }