parser 2.4.0.2 → 2.5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -6
  3. data/CHANGELOG.md +35 -1
  4. data/Gemfile +2 -0
  5. data/README.md +1 -2
  6. data/Rakefile +2 -1
  7. data/bin/ruby-parse +2 -1
  8. data/bin/ruby-rewrite +2 -1
  9. data/lib/gauntlet_parser.rb +2 -0
  10. data/lib/parser.rb +16 -17
  11. data/lib/parser/all.rb +2 -0
  12. data/lib/parser/ast/node.rb +2 -0
  13. data/lib/parser/ast/processor.rb +2 -0
  14. data/lib/parser/base.rb +6 -12
  15. data/lib/parser/builders/default.rb +28 -47
  16. data/lib/parser/clobbering_error.rb +2 -0
  17. data/lib/parser/context.rb +42 -0
  18. data/lib/parser/current.rb +4 -20
  19. data/lib/parser/deprecation.rb +13 -0
  20. data/lib/parser/diagnostic.rb +3 -3
  21. data/lib/parser/diagnostic/engine.rb +2 -0
  22. data/lib/parser/lexer.rl +122 -60
  23. data/lib/parser/lexer/dedenter.rb +2 -0
  24. data/lib/parser/lexer/explanation.rb +2 -0
  25. data/lib/parser/lexer/literal.rb +4 -9
  26. data/lib/parser/lexer/stack_state.rb +4 -1
  27. data/lib/parser/macruby.y +32 -17
  28. data/lib/parser/messages.rb +14 -0
  29. data/lib/parser/meta.rb +2 -0
  30. data/lib/parser/rewriter.rb +30 -44
  31. data/lib/parser/ruby18.y +20 -13
  32. data/lib/parser/ruby19.y +32 -17
  33. data/lib/parser/ruby20.y +33 -18
  34. data/lib/parser/ruby21.y +32 -17
  35. data/lib/parser/ruby22.y +32 -17
  36. data/lib/parser/ruby23.y +32 -17
  37. data/lib/parser/ruby24.y +63 -46
  38. data/lib/parser/ruby25.y +72 -48
  39. data/lib/parser/rubymotion.y +33 -18
  40. data/lib/parser/runner.rb +4 -7
  41. data/lib/parser/runner/ruby_parse.rb +10 -0
  42. data/lib/parser/runner/ruby_rewrite.rb +2 -0
  43. data/lib/parser/source/buffer.rb +19 -24
  44. data/lib/parser/source/comment.rb +2 -0
  45. data/lib/parser/source/comment/associator.rb +2 -0
  46. data/lib/parser/source/map.rb +2 -0
  47. data/lib/parser/source/map/collection.rb +2 -0
  48. data/lib/parser/source/map/condition.rb +2 -0
  49. data/lib/parser/source/map/constant.rb +2 -0
  50. data/lib/parser/source/map/definition.rb +2 -0
  51. data/lib/parser/source/map/for.rb +2 -0
  52. data/lib/parser/source/map/heredoc.rb +2 -0
  53. data/lib/parser/source/map/keyword.rb +2 -0
  54. data/lib/parser/source/map/objc_kwarg.rb +2 -0
  55. data/lib/parser/source/map/operator.rb +2 -0
  56. data/lib/parser/source/map/rescue_body.rb +2 -0
  57. data/lib/parser/source/map/send.rb +2 -0
  58. data/lib/parser/source/map/ternary.rb +2 -0
  59. data/lib/parser/source/map/variable.rb +2 -0
  60. data/lib/parser/source/range.rb +81 -13
  61. data/lib/parser/source/rewriter.rb +48 -10
  62. data/lib/parser/source/rewriter/action.rb +2 -0
  63. data/lib/parser/source/tree_rewriter.rb +301 -0
  64. data/lib/parser/source/tree_rewriter/action.rb +133 -0
  65. data/lib/parser/static_environment.rb +2 -0
  66. data/lib/parser/syntax_error.rb +2 -0
  67. data/lib/parser/tree_rewriter.rb +133 -0
  68. data/lib/parser/version.rb +3 -1
  69. data/parser.gemspec +4 -1
  70. data/test/bug_163/fixtures/input.rb +2 -0
  71. data/test/bug_163/fixtures/output.rb +2 -0
  72. data/test/bug_163/rewriter.rb +2 -0
  73. data/test/helper.rb +7 -7
  74. data/test/parse_helper.rb +57 -10
  75. data/test/racc_coverage_helper.rb +2 -0
  76. data/test/test_base.rb +2 -0
  77. data/test/test_current.rb +2 -4
  78. data/test/test_diagnostic.rb +3 -1
  79. data/test/test_diagnostic_engine.rb +2 -0
  80. data/test/test_encoding.rb +61 -49
  81. data/test/test_lexer.rb +164 -77
  82. data/test/test_lexer_stack_state.rb +2 -0
  83. data/test/test_parse_helper.rb +8 -8
  84. data/test/test_parser.rb +613 -51
  85. data/test/test_runner_rewrite.rb +47 -0
  86. data/test/test_source_buffer.rb +22 -10
  87. data/test/test_source_comment.rb +2 -0
  88. data/test/test_source_comment_associator.rb +2 -0
  89. data/test/test_source_map.rb +2 -0
  90. data/test/test_source_range.rb +92 -45
  91. data/test/test_source_rewriter.rb +3 -1
  92. data/test/test_source_rewriter_action.rb +2 -0
  93. data/test/test_source_tree_rewriter.rb +177 -0
  94. data/test/test_static_environment.rb +2 -0
  95. data/test/using_tree_rewriter/fixtures/input.rb +3 -0
  96. data/test/using_tree_rewriter/fixtures/output.rb +3 -0
  97. data/test/using_tree_rewriter/using_tree_rewriter.rb +9 -0
  98. metadata +21 -10
  99. data/lib/parser/compatibility/ruby1_8.rb +0 -20
  100. data/lib/parser/compatibility/ruby1_9.rb +0 -32
  101. data/test/bug_163/test_runner_rewrite.rb +0 -35
@@ -279,12 +279,14 @@ rule
279
279
  cmd_brace_block: tLBRACE_ARG
280
280
  {
281
281
  @static_env.extend_dynamic
282
+ @context.push(:block)
282
283
  }
283
284
  opt_block_param compstmt tRCURLY
284
285
  {
285
286
  result = [ val[0], val[2], val[3], val[4] ]
286
287
 
287
288
  @static_env.unextend
289
+ @context.pop
288
290
  }
289
291
 
290
292
  fcall: operation
@@ -1108,10 +1110,11 @@ rule
1108
1110
  {
1109
1111
  @static_env.extend_static
1110
1112
  @lexer.push_cmdarg
1113
+ @context.push(:class)
1111
1114
  }
1112
1115
  bodystmt kEND
1113
1116
  {
1114
- if in_def?
1117
+ if @context.indirectly_in_def?
1115
1118
  diagnostic :error, :class_in_def, nil, val[0]
1116
1119
  end
1117
1120
 
@@ -1122,14 +1125,13 @@ rule
1122
1125
 
1123
1126
  @lexer.pop_cmdarg
1124
1127
  @static_env.unextend
1128
+ @context.pop
1125
1129
  }
1126
1130
  | kCLASS tLSHFT expr term
1127
1131
  {
1128
- result = @def_level
1129
- @def_level = 0
1130
-
1131
1132
  @static_env.extend_static
1132
1133
  @lexer.push_cmdarg
1134
+ @context.push(:sclass)
1133
1135
  }
1134
1136
  bodystmt kEND
1135
1137
  {
@@ -1138,8 +1140,7 @@ rule
1138
1140
 
1139
1141
  @lexer.pop_cmdarg
1140
1142
  @static_env.unextend
1141
-
1142
- @def_level = val[4]
1143
+ @context.pop
1143
1144
  }
1144
1145
  | kMODULE cpath
1145
1146
  {
@@ -1148,7 +1149,7 @@ rule
1148
1149
  }
1149
1150
  bodystmt kEND
1150
1151
  {
1151
- if in_def?
1152
+ if @context.indirectly_in_def?
1152
1153
  diagnostic :error, :module_in_def, nil, val[0]
1153
1154
  end
1154
1155
 
@@ -1160,9 +1161,9 @@ rule
1160
1161
  }
1161
1162
  | kDEF fname
1162
1163
  {
1163
- @def_level += 1
1164
1164
  @static_env.extend_static
1165
1165
  @lexer.push_cmdarg
1166
+ @context.push(:def)
1166
1167
  }
1167
1168
  f_arglist bodystmt kEND
1168
1169
  {
@@ -1171,7 +1172,7 @@ rule
1171
1172
 
1172
1173
  @lexer.pop_cmdarg
1173
1174
  @static_env.unextend
1174
- @def_level -= 1
1175
+ @context.pop
1175
1176
  }
1176
1177
  | kDEF singleton dot_or_colon
1177
1178
  {
@@ -1179,9 +1180,9 @@ rule
1179
1180
  }
1180
1181
  fname
1181
1182
  {
1182
- @def_level += 1
1183
1183
  @static_env.extend_static
1184
1184
  @lexer.push_cmdarg
1185
+ @context.push(:defs)
1185
1186
  }
1186
1187
  f_arglist bodystmt kEND
1187
1188
  {
@@ -1190,7 +1191,7 @@ rule
1190
1191
 
1191
1192
  @lexer.pop_cmdarg
1192
1193
  @static_env.unextend
1193
- @def_level -= 1
1194
+ @context.pop
1194
1195
  }
1195
1196
  | kBREAK
1196
1197
  {
@@ -1489,24 +1490,36 @@ opt_block_args_tail:
1489
1490
  result = @builder.args(nil, val[0], nil)
1490
1491
  }
1491
1492
 
1492
- lambda_body: tLAMBEG compstmt tRCURLY
1493
+ lambda_body: tLAMBEG
1494
+ {
1495
+ @context.push(:lambda)
1496
+ }
1497
+ compstmt tRCURLY
1493
1498
  {
1494
- result = [ val[0], val[1], val[2] ]
1499
+ result = [ val[0], val[2], val[3] ]
1500
+ @context.pop
1495
1501
  }
1496
- | kDO_LAMBDA compstmt kEND
1502
+ | kDO_LAMBDA
1497
1503
  {
1498
- result = [ val[0], val[1], val[2] ]
1504
+ @context.push(:lambda)
1505
+ }
1506
+ compstmt kEND
1507
+ {
1508
+ result = [ val[0], val[2], val[3] ]
1509
+ @context.pop
1499
1510
  }
1500
1511
 
1501
1512
  do_block: kDO_BLOCK
1502
1513
  {
1503
1514
  @static_env.extend_dynamic
1515
+ @context.push(:block)
1504
1516
  }
1505
1517
  opt_block_param compstmt kEND
1506
1518
  {
1507
1519
  result = [ val[0], val[2], val[3], val[4] ]
1508
1520
 
1509
1521
  @static_env.unextend
1522
+ @context.pop
1510
1523
  }
1511
1524
 
1512
1525
  block_call: command do_block
@@ -1593,22 +1606,26 @@ opt_block_args_tail:
1593
1606
  brace_block: tLCURLY
1594
1607
  {
1595
1608
  @static_env.extend_dynamic
1609
+ @context.push(:block)
1596
1610
  }
1597
1611
  opt_block_param compstmt tRCURLY
1598
1612
  {
1599
1613
  result = [ val[0], val[2], val[3], val[4] ]
1600
1614
 
1601
1615
  @static_env.unextend
1616
+ @context.pop
1602
1617
  }
1603
1618
  | kDO
1604
1619
  {
1605
1620
  @static_env.extend_dynamic
1621
+ @context.push(:block)
1606
1622
  }
1607
1623
  opt_block_param compstmt kEND
1608
1624
  {
1609
1625
  result = [ val[0], val[2], val[3], val[4] ]
1610
1626
 
1611
1627
  @static_env.unextend
1628
+ @context.pop
1612
1629
  }
1613
1630
 
1614
1631
  case_body: kWHEN args then compstmt cases
@@ -2336,8 +2353,6 @@ end
2336
2353
 
2337
2354
  require 'parser'
2338
2355
 
2339
- Parser.check_for_encoding_support
2340
-
2341
2356
  ---- inner
2342
2357
 
2343
2358
  def version
@@ -279,12 +279,14 @@ rule
279
279
  cmd_brace_block: tLBRACE_ARG
280
280
  {
281
281
  @static_env.extend_dynamic
282
+ @context.push(:block)
282
283
  }
283
284
  opt_block_param compstmt tRCURLY
284
285
  {
285
286
  result = [ val[0], val[2], val[3], val[4] ]
286
287
 
287
288
  @static_env.unextend
289
+ @context.pop
288
290
  }
289
291
 
290
292
  fcall: operation
@@ -1108,10 +1110,11 @@ rule
1108
1110
  {
1109
1111
  @static_env.extend_static
1110
1112
  @lexer.push_cmdarg
1113
+ @context.push(:class)
1111
1114
  }
1112
1115
  bodystmt kEND
1113
1116
  {
1114
- if in_def?
1117
+ if @context.indirectly_in_def?
1115
1118
  diagnostic :error, :class_in_def, nil, val[0]
1116
1119
  end
1117
1120
 
@@ -1122,14 +1125,13 @@ rule
1122
1125
 
1123
1126
  @lexer.pop_cmdarg
1124
1127
  @static_env.unextend
1128
+ @context.pop
1125
1129
  }
1126
1130
  | kCLASS tLSHFT expr term
1127
1131
  {
1128
- result = @def_level
1129
- @def_level = 0
1130
-
1131
1132
  @static_env.extend_static
1132
1133
  @lexer.push_cmdarg
1134
+ @context.push(:sclass)
1133
1135
  }
1134
1136
  bodystmt kEND
1135
1137
  {
@@ -1138,8 +1140,7 @@ rule
1138
1140
 
1139
1141
  @lexer.pop_cmdarg
1140
1142
  @static_env.unextend
1141
-
1142
- @def_level = val[4]
1143
+ @context.pop
1143
1144
  }
1144
1145
  | kMODULE cpath
1145
1146
  {
@@ -1148,7 +1149,7 @@ rule
1148
1149
  }
1149
1150
  bodystmt kEND
1150
1151
  {
1151
- if in_def?
1152
+ if @context.indirectly_in_def?
1152
1153
  diagnostic :error, :module_in_def, nil, val[0]
1153
1154
  end
1154
1155
 
@@ -1160,9 +1161,9 @@ rule
1160
1161
  }
1161
1162
  | kDEF fname
1162
1163
  {
1163
- @def_level += 1
1164
1164
  @static_env.extend_static
1165
1165
  @lexer.push_cmdarg
1166
+ @context.push(:def)
1166
1167
  }
1167
1168
  f_arglist bodystmt kEND
1168
1169
  {
@@ -1171,7 +1172,7 @@ rule
1171
1172
 
1172
1173
  @lexer.pop_cmdarg
1173
1174
  @static_env.unextend
1174
- @def_level -= 1
1175
+ @context.pop
1175
1176
  }
1176
1177
  | kDEF singleton dot_or_colon
1177
1178
  {
@@ -1179,9 +1180,9 @@ rule
1179
1180
  }
1180
1181
  fname
1181
1182
  {
1182
- @def_level += 1
1183
1183
  @static_env.extend_static
1184
1184
  @lexer.push_cmdarg
1185
+ @context.push(:defs)
1185
1186
  }
1186
1187
  f_arglist bodystmt kEND
1187
1188
  {
@@ -1190,7 +1191,7 @@ rule
1190
1191
 
1191
1192
  @lexer.pop_cmdarg
1192
1193
  @static_env.unextend
1193
- @def_level -= 1
1194
+ @context.pop
1194
1195
  }
1195
1196
  | kBREAK
1196
1197
  {
@@ -1489,24 +1490,36 @@ opt_block_args_tail:
1489
1490
  result = @builder.args(nil, val[0], nil)
1490
1491
  }
1491
1492
 
1492
- lambda_body: tLAMBEG compstmt tRCURLY
1493
+ lambda_body: tLAMBEG
1494
+ {
1495
+ @context.push(:lambda)
1496
+ }
1497
+ compstmt tRCURLY
1493
1498
  {
1494
- result = [ val[0], val[1], val[2] ]
1499
+ result = [ val[0], val[2], val[3] ]
1500
+ @context.pop
1495
1501
  }
1496
- | kDO_LAMBDA compstmt kEND
1502
+ | kDO_LAMBDA
1497
1503
  {
1498
- result = [ val[0], val[1], val[2] ]
1504
+ @context.push(:lambda)
1505
+ }
1506
+ compstmt kEND
1507
+ {
1508
+ result = [ val[0], val[2], val[3] ]
1509
+ @context.pop
1499
1510
  }
1500
1511
 
1501
1512
  do_block: kDO_BLOCK
1502
1513
  {
1503
1514
  @static_env.extend_dynamic
1515
+ @context.push(:block)
1504
1516
  }
1505
1517
  opt_block_param compstmt kEND
1506
1518
  {
1507
1519
  result = [ val[0], val[2], val[3], val[4] ]
1508
1520
 
1509
1521
  @static_env.unextend
1522
+ @context.pop
1510
1523
  }
1511
1524
 
1512
1525
  block_call: command do_block
@@ -1593,22 +1606,26 @@ opt_block_args_tail:
1593
1606
  brace_block: tLCURLY
1594
1607
  {
1595
1608
  @static_env.extend_dynamic
1609
+ @context.push(:block)
1596
1610
  }
1597
1611
  opt_block_param compstmt tRCURLY
1598
1612
  {
1599
1613
  result = [ val[0], val[2], val[3], val[4] ]
1600
1614
 
1601
1615
  @static_env.unextend
1616
+ @context.pop
1602
1617
  }
1603
1618
  | kDO
1604
1619
  {
1605
1620
  @static_env.extend_dynamic
1621
+ @context.push(:block)
1606
1622
  }
1607
1623
  opt_block_param compstmt kEND
1608
1624
  {
1609
1625
  result = [ val[0], val[2], val[3], val[4] ]
1610
1626
 
1611
1627
  @static_env.unextend
1628
+ @context.pop
1612
1629
  }
1613
1630
 
1614
1631
  case_body: kWHEN args then compstmt cases
@@ -2342,8 +2359,6 @@ end
2342
2359
 
2343
2360
  require 'parser'
2344
2361
 
2345
- Parser.check_for_encoding_support
2346
-
2347
2362
  ---- inner
2348
2363
 
2349
2364
  def version
@@ -283,9 +283,14 @@ rule
283
283
  nil, val[3], nil)
284
284
  }
285
285
 
286
- cmd_brace_block: tLBRACE_ARG brace_body tRCURLY
286
+ cmd_brace_block: tLBRACE_ARG
287
287
  {
288
- result = [ val[0], *val[1], val[2] ]
288
+ @context.push(:block)
289
+ }
290
+ brace_body tRCURLY
291
+ {
292
+ result = [ val[0], *val[2], val[3] ]
293
+ @context.pop
289
294
  }
290
295
 
291
296
  fcall: operation
@@ -845,12 +850,11 @@ rule
845
850
  }
846
851
 
847
852
  command_args: {
848
- result = @lexer.cmdarg.dup
849
853
  @lexer.cmdarg.push(true)
850
854
  }
851
855
  call_args
852
856
  {
853
- @lexer.cmdarg = val[0]
857
+ @lexer.cmdarg.pop
854
858
 
855
859
  result = val[1]
856
860
  }
@@ -1099,10 +1103,11 @@ rule
1099
1103
  {
1100
1104
  @static_env.extend_static
1101
1105
  @lexer.push_cmdarg
1106
+ @context.push(:class)
1102
1107
  }
1103
1108
  bodystmt kEND
1104
1109
  {
1105
- if in_def?
1110
+ if @context.indirectly_in_def?
1106
1111
  diagnostic :error, :class_in_def, nil, val[0]
1107
1112
  end
1108
1113
 
@@ -1113,14 +1118,13 @@ rule
1113
1118
 
1114
1119
  @lexer.pop_cmdarg
1115
1120
  @static_env.unextend
1121
+ @context.pop
1116
1122
  }
1117
1123
  | kCLASS tLSHFT expr term
1118
1124
  {
1119
- result = @def_level
1120
- @def_level = 0
1121
-
1122
1125
  @static_env.extend_static
1123
1126
  @lexer.push_cmdarg
1127
+ @context.push(:sclass)
1124
1128
  }
1125
1129
  bodystmt kEND
1126
1130
  {
@@ -1129,8 +1133,7 @@ rule
1129
1133
 
1130
1134
  @lexer.pop_cmdarg
1131
1135
  @static_env.unextend
1132
-
1133
- @def_level = val[4]
1136
+ @context.pop
1134
1137
  }
1135
1138
  | kMODULE cpath
1136
1139
  {
@@ -1139,7 +1142,7 @@ rule
1139
1142
  }
1140
1143
  bodystmt kEND
1141
1144
  {
1142
- if in_def?
1145
+ if @context.indirectly_in_def?
1143
1146
  diagnostic :error, :module_in_def, nil, val[0]
1144
1147
  end
1145
1148
 
@@ -1151,9 +1154,9 @@ rule
1151
1154
  }
1152
1155
  | kDEF fname
1153
1156
  {
1154
- @def_level += 1
1155
1157
  @static_env.extend_static
1156
1158
  @lexer.push_cmdarg
1159
+ @context.push(:def)
1157
1160
  }
1158
1161
  f_arglist bodystmt kEND
1159
1162
  {
@@ -1162,7 +1165,7 @@ rule
1162
1165
 
1163
1166
  @lexer.pop_cmdarg
1164
1167
  @static_env.unextend
1165
- @def_level -= 1
1168
+ @context.pop
1166
1169
  }
1167
1170
  | kDEF singleton dot_or_colon
1168
1171
  {
@@ -1170,9 +1173,9 @@ rule
1170
1173
  }
1171
1174
  fname
1172
1175
  {
1173
- @def_level += 1
1174
1176
  @static_env.extend_static
1175
1177
  @lexer.push_cmdarg
1178
+ @context.push(:defs)
1176
1179
  }
1177
1180
  f_arglist bodystmt kEND
1178
1181
  {
@@ -1181,7 +1184,7 @@ rule
1181
1184
 
1182
1185
  @lexer.pop_cmdarg
1183
1186
  @static_env.unextend
1184
- @def_level -= 1
1187
+ @context.pop
1185
1188
  }
1186
1189
  | kBREAK
1187
1190
  {
@@ -1458,13 +1461,11 @@ opt_block_args_tail:
1458
1461
  }
1459
1462
  f_larglist
1460
1463
  {
1461
- result = @lexer.cmdarg.dup
1462
- @lexer.cmdarg.clear
1464
+ @lexer.cmdarg.push(false)
1463
1465
  }
1464
1466
  lambda_body
1465
1467
  {
1466
- @lexer.cmdarg = val[2]
1467
- @lexer.cmdarg.lexpop
1468
+ @lexer.cmdarg.pop
1468
1469
 
1469
1470
  result = [ val[1], val[3] ]
1470
1471
 
@@ -1480,18 +1481,33 @@ opt_block_args_tail:
1480
1481
  result = @builder.args(nil, val[0], nil)
1481
1482
  }
1482
1483
 
1483
- lambda_body: tLAMBEG compstmt tRCURLY
1484
+ lambda_body: tLAMBEG
1485
+ {
1486
+ @context.push(:lambda)
1487
+ }
1488
+ compstmt tRCURLY
1489
+ {
1490
+ result = [ val[0], val[2], val[3] ]
1491
+ @context.pop
1492
+ }
1493
+ | kDO_LAMBDA
1484
1494
  {
1485
- result = [ val[0], val[1], val[2] ]
1495
+ @context.push(:lambda)
1486
1496
  }
1487
- | kDO_LAMBDA compstmt kEND
1497
+ compstmt kEND
1488
1498
  {
1489
- result = [ val[0], val[1], val[2] ]
1499
+ result = [ val[0], val[2], val[3] ]
1500
+ @context.pop
1490
1501
  }
1491
1502
 
1492
- do_block: kDO_BLOCK do_body kEND
1503
+ do_block: kDO_BLOCK
1493
1504
  {
1494
- result = [ val[0], *val[1], val[2] ]
1505
+ @context.push(:block)
1506
+ }
1507
+ do_body kEND
1508
+ {
1509
+ result = [ val[0], *val[2], val[3] ]
1510
+ @context.pop
1495
1511
  }
1496
1512
 
1497
1513
  block_call: command do_block
@@ -1575,29 +1591,33 @@ opt_block_args_tail:
1575
1591
  result = @builder.index(val[0], val[1], val[2], val[3])
1576
1592
  }
1577
1593
 
1578
- brace_block: tLCURLY brace_body tRCURLY
1594
+ brace_block: tLCURLY
1595
+ {
1596
+ @context.push(:block)
1597
+ }
1598
+ brace_body tRCURLY
1579
1599
  {
1580
- result = [ val[0], *val[1], val[2] ]
1600
+ result = [ val[0], *val[2], val[3] ]
1601
+ @context.pop
1581
1602
  }
1582
- | kDO do_body kEND
1603
+ | kDO
1583
1604
  {
1584
- result = [ val[0], *val[1], val[2] ]
1605
+ @context.push(:block)
1606
+ }
1607
+ do_body kEND
1608
+ {
1609
+ result = [ val[0], *val[2], val[3] ]
1610
+ @context.pop
1585
1611
  }
1586
1612
 
1587
1613
  brace_body: {
1588
1614
  @static_env.extend_dynamic
1589
1615
  }
1590
- {
1591
- result = @lexer.cmdarg.dup
1592
- @lexer.cmdarg.clear
1593
- }
1594
1616
  opt_block_param compstmt
1595
1617
  {
1596
- result = [ val[2], val[3] ]
1618
+ result = [ val[1], val[2] ]
1597
1619
 
1598
1620
  @static_env.unextend
1599
- @lexer.cmdarg = val[1]
1600
- @lexer.cmdarg.pop
1601
1621
  }
1602
1622
 
1603
1623
  do_body: {
@@ -1613,7 +1633,6 @@ opt_block_args_tail:
1613
1633
 
1614
1634
  @static_env.unextend
1615
1635
  @lexer.cmdarg = val[1]
1616
- @lexer.cmdarg.pop
1617
1636
  }
1618
1637
 
1619
1638
  case_body: kWHEN args then compstmt cases
@@ -1818,7 +1837,7 @@ regexp_contents: # nothing
1818
1837
  compstmt tSTRING_DEND
1819
1838
  {
1820
1839
  @lexer.cond.lexpop
1821
- @lexer.cmdarg.lexpop
1840
+ @lexer.cmdarg.pop
1822
1841
 
1823
1842
  result = @builder.begin(val[0], val[2], val[3])
1824
1843
  }
@@ -1840,13 +1859,13 @@ regexp_contents: # nothing
1840
1859
 
1841
1860
  symbol: tSYMBOL
1842
1861
  {
1843
- @lexer.state = :expr_endarg
1862
+ @lexer.state = :expr_end
1844
1863
  result = @builder.symbol(val[0])
1845
1864
  }
1846
1865
 
1847
1866
  dsym: tSYMBEG xstring_contents tSTRING_END
1848
1867
  {
1849
- @lexer.state = :expr_endarg
1868
+ @lexer.state = :expr_end
1850
1869
  result = @builder.symbol_compose(val[0], val[1], val[2])
1851
1870
  }
1852
1871
 
@@ -1866,22 +1885,22 @@ regexp_contents: # nothing
1866
1885
 
1867
1886
  simple_numeric: tINTEGER
1868
1887
  {
1869
- @lexer.state = :expr_endarg
1888
+ @lexer.state = :expr_end
1870
1889
  result = @builder.integer(val[0])
1871
1890
  }
1872
1891
  | tFLOAT
1873
1892
  {
1874
- @lexer.state = :expr_endarg
1893
+ @lexer.state = :expr_end
1875
1894
  result = @builder.float(val[0])
1876
1895
  }
1877
1896
  | tRATIONAL
1878
1897
  {
1879
- @lexer.state = :expr_endarg
1898
+ @lexer.state = :expr_end
1880
1899
  result = @builder.rational(val[0])
1881
1900
  }
1882
1901
  | tIMAGINARY
1883
1902
  {
1884
- @lexer.state = :expr_endarg
1903
+ @lexer.state = :expr_end
1885
1904
  result = @builder.complex(val[0])
1886
1905
  }
1887
1906
 
@@ -2353,8 +2372,6 @@ end
2353
2372
 
2354
2373
  require 'parser'
2355
2374
 
2356
- Parser.check_for_encoding_support
2357
-
2358
2375
  ---- inner
2359
2376
 
2360
2377
  def version