parser 2.7.1.1 → 3.0.2.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/lib/parser.rb +1 -0
  3. data/lib/parser/all.rb +2 -0
  4. data/lib/parser/ast/processor.rb +5 -0
  5. data/lib/parser/base.rb +7 -5
  6. data/lib/parser/builders/default.rb +263 -23
  7. data/lib/parser/context.rb +5 -0
  8. data/lib/parser/current.rb +24 -6
  9. data/lib/parser/current_arg_stack.rb +5 -2
  10. data/lib/parser/diagnostic.rb +1 -1
  11. data/lib/parser/diagnostic/engine.rb +1 -2
  12. data/lib/parser/lexer.rb +887 -803
  13. data/lib/parser/macruby.rb +2214 -2189
  14. data/lib/parser/max_numparam_stack.rb +13 -5
  15. data/lib/parser/messages.rb +18 -0
  16. data/lib/parser/meta.rb +6 -5
  17. data/lib/parser/ruby18.rb +9 -3
  18. data/lib/parser/ruby19.rb +2297 -2289
  19. data/lib/parser/ruby20.rb +2413 -2397
  20. data/lib/parser/ruby21.rb +2419 -2411
  21. data/lib/parser/ruby22.rb +2468 -2460
  22. data/lib/parser/ruby23.rb +2452 -2452
  23. data/lib/parser/ruby24.rb +2435 -2430
  24. data/lib/parser/ruby25.rb +2220 -2214
  25. data/lib/parser/ruby26.rb +2220 -2214
  26. data/lib/parser/ruby27.rb +3715 -3615
  27. data/lib/parser/ruby28.rb +8047 -0
  28. data/lib/parser/ruby30.rb +8060 -0
  29. data/lib/parser/ruby31.rb +8226 -0
  30. data/lib/parser/rubymotion.rb +2190 -2182
  31. data/lib/parser/runner.rb +31 -2
  32. data/lib/parser/runner/ruby_rewrite.rb +2 -2
  33. data/lib/parser/source/buffer.rb +53 -28
  34. data/lib/parser/source/comment.rb +14 -1
  35. data/lib/parser/source/comment/associator.rb +31 -8
  36. data/lib/parser/source/map/method_definition.rb +25 -0
  37. data/lib/parser/source/range.rb +10 -3
  38. data/lib/parser/source/tree_rewriter.rb +100 -10
  39. data/lib/parser/source/tree_rewriter/action.rb +114 -21
  40. data/lib/parser/static_environment.rb +4 -0
  41. data/lib/parser/tree_rewriter.rb +1 -2
  42. data/lib/parser/variables_stack.rb +4 -0
  43. data/lib/parser/version.rb +1 -1
  44. data/parser.gemspec +3 -18
  45. metadata +17 -98
  46. data/.gitignore +0 -33
  47. data/.travis.yml +0 -42
  48. data/.yardopts +0 -21
  49. data/CHANGELOG.md +0 -1075
  50. data/CONTRIBUTING.md +0 -17
  51. data/Gemfile +0 -10
  52. data/README.md +0 -309
  53. data/Rakefile +0 -166
  54. data/ci/run_rubocop_specs +0 -14
  55. data/doc/AST_FORMAT.md +0 -2180
  56. data/doc/CUSTOMIZATION.md +0 -37
  57. data/doc/INTERNALS.md +0 -21
  58. data/doc/css/.gitkeep +0 -0
  59. data/doc/css/common.css +0 -68
  60. data/lib/parser/lexer.rl +0 -2536
  61. data/lib/parser/macruby.y +0 -2198
  62. data/lib/parser/ruby18.y +0 -1934
  63. data/lib/parser/ruby19.y +0 -2175
  64. data/lib/parser/ruby20.y +0 -2353
  65. data/lib/parser/ruby21.y +0 -2357
  66. data/lib/parser/ruby22.y +0 -2364
  67. data/lib/parser/ruby23.y +0 -2370
  68. data/lib/parser/ruby24.y +0 -2408
  69. data/lib/parser/ruby25.y +0 -2405
  70. data/lib/parser/ruby26.y +0 -2413
  71. data/lib/parser/ruby27.y +0 -2941
  72. data/lib/parser/rubymotion.y +0 -2182
  73. data/test/bug_163/fixtures/input.rb +0 -5
  74. data/test/bug_163/fixtures/output.rb +0 -5
  75. data/test/bug_163/rewriter.rb +0 -20
  76. data/test/helper.rb +0 -60
  77. data/test/parse_helper.rb +0 -319
  78. data/test/racc_coverage_helper.rb +0 -133
  79. data/test/test_base.rb +0 -31
  80. data/test/test_current.rb +0 -29
  81. data/test/test_diagnostic.rb +0 -96
  82. data/test/test_diagnostic_engine.rb +0 -62
  83. data/test/test_encoding.rb +0 -99
  84. data/test/test_lexer.rb +0 -3608
  85. data/test/test_lexer_stack_state.rb +0 -78
  86. data/test/test_parse_helper.rb +0 -80
  87. data/test/test_parser.rb +0 -9430
  88. data/test/test_runner_parse.rb +0 -35
  89. data/test/test_runner_rewrite.rb +0 -47
  90. data/test/test_source_buffer.rb +0 -162
  91. data/test/test_source_comment.rb +0 -36
  92. data/test/test_source_comment_associator.rb +0 -367
  93. data/test/test_source_map.rb +0 -15
  94. data/test/test_source_range.rb +0 -187
  95. data/test/test_source_rewriter.rb +0 -541
  96. data/test/test_source_rewriter_action.rb +0 -46
  97. data/test/test_source_tree_rewriter.rb +0 -253
  98. data/test/test_static_environment.rb +0 -45
  99. data/test/using_tree_rewriter/fixtures/input.rb +0 -3
  100. data/test/using_tree_rewriter/fixtures/output.rb +0 -3
  101. data/test/using_tree_rewriter/using_tree_rewriter.rb +0 -9
data/lib/parser/ruby23.y DELETED
@@ -1,2370 +0,0 @@
1
- class Parser::Ruby23
2
-
3
- token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
4
- kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
5
- kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
6
- kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
7
- kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
- k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
- tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
- tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
- tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
- tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
14
- tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
15
- tDSTAR tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
16
- tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
17
- tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
18
- tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
19
- tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
20
- tRATIONAL tIMAGINARY tLABEL_END tANDDOT
21
-
22
- prechigh
23
- right tBANG tTILDE tUPLUS
24
- right tPOW
25
- right tUNARY_NUM tUMINUS
26
- left tSTAR2 tDIVIDE tPERCENT
27
- left tPLUS tMINUS
28
- left tLSHFT tRSHFT
29
- left tAMPER2
30
- left tPIPE tCARET
31
- left tGT tGEQ tLT tLEQ
32
- nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
33
- left tANDOP
34
- left tOROP
35
- nonassoc tDOT2 tDOT3
36
- right tEH tCOLON
37
- left kRESCUE_MOD
38
- right tEQL tOP_ASGN
39
- nonassoc kDEFINED
40
- right kNOT
41
- left kOR kAND
42
- nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
43
- nonassoc tLBRACE_ARG
44
- nonassoc tLOWEST
45
- preclow
46
-
47
- rule
48
-
49
- program: top_compstmt
50
-
51
- top_compstmt: top_stmts opt_terms
52
- {
53
- result = @builder.compstmt(val[0])
54
- }
55
-
56
- top_stmts: # nothing
57
- {
58
- result = []
59
- }
60
- | top_stmt
61
- {
62
- result = [ val[0] ]
63
- }
64
- | top_stmts terms top_stmt
65
- {
66
- result = val[0] << val[2]
67
- }
68
- | error top_stmt
69
- {
70
- result = [ val[1] ]
71
- }
72
-
73
- top_stmt: stmt
74
- | klBEGIN tLCURLY top_compstmt tRCURLY
75
- {
76
- result = @builder.preexe(val[0], val[1], val[2], val[3])
77
- }
78
-
79
- bodystmt: compstmt opt_rescue opt_else opt_ensure
80
- {
81
- rescue_bodies = val[1]
82
- else_t, else_ = val[2]
83
- ensure_t, ensure_ = val[3]
84
-
85
- if rescue_bodies.empty? && !else_t.nil?
86
- diagnostic :warning, :useless_else, nil, else_t
87
- end
88
-
89
- result = @builder.begin_body(val[0],
90
- rescue_bodies,
91
- else_t, else_,
92
- ensure_t, ensure_)
93
- }
94
-
95
- compstmt: stmts opt_terms
96
- {
97
- result = @builder.compstmt(val[0])
98
- }
99
-
100
- stmts: # nothing
101
- {
102
- result = []
103
- }
104
- | stmt_or_begin
105
- {
106
- result = [ val[0] ]
107
- }
108
- | stmts terms stmt_or_begin
109
- {
110
- result = val[0] << val[2]
111
- }
112
- | error stmt
113
- {
114
- result = [ val[1] ]
115
- }
116
-
117
- stmt_or_begin: stmt
118
- | klBEGIN tLCURLY top_compstmt tRCURLY
119
- {
120
- diagnostic :error, :begin_in_method, nil, val[0]
121
- }
122
-
123
- stmt: kALIAS fitem
124
- {
125
- @lexer.state = :expr_fname
126
- }
127
- fitem
128
- {
129
- result = @builder.alias(val[0], val[1], val[3])
130
- }
131
- | kALIAS tGVAR tGVAR
132
- {
133
- result = @builder.alias(val[0],
134
- @builder.gvar(val[1]),
135
- @builder.gvar(val[2]))
136
- }
137
- | kALIAS tGVAR tBACK_REF
138
- {
139
- result = @builder.alias(val[0],
140
- @builder.gvar(val[1]),
141
- @builder.back_ref(val[2]))
142
- }
143
- | kALIAS tGVAR tNTH_REF
144
- {
145
- diagnostic :error, :nth_ref_alias, nil, val[2]
146
- }
147
- | kUNDEF undef_list
148
- {
149
- result = @builder.undef_method(val[0], val[1])
150
- }
151
- | stmt kIF_MOD expr_value
152
- {
153
- result = @builder.condition_mod(val[0], nil,
154
- val[1], val[2])
155
- }
156
- | stmt kUNLESS_MOD expr_value
157
- {
158
- result = @builder.condition_mod(nil, val[0],
159
- val[1], val[2])
160
- }
161
- | stmt kWHILE_MOD expr_value
162
- {
163
- result = @builder.loop_mod(:while, val[0], val[1], val[2])
164
- }
165
- | stmt kUNTIL_MOD expr_value
166
- {
167
- result = @builder.loop_mod(:until, val[0], val[1], val[2])
168
- }
169
- | stmt kRESCUE_MOD stmt
170
- {
171
- rescue_body = @builder.rescue_body(val[1],
172
- nil, nil, nil,
173
- nil, val[2])
174
-
175
- result = @builder.begin_body(val[0], [ rescue_body ])
176
- }
177
- | klEND tLCURLY compstmt tRCURLY
178
- {
179
- result = @builder.postexe(val[0], val[1], val[2], val[3])
180
- }
181
- | command_asgn
182
- | mlhs tEQL command_call
183
- {
184
- result = @builder.multi_assign(val[0], val[1], val[2])
185
- }
186
- | var_lhs tOP_ASGN command_call
187
- {
188
- result = @builder.op_assign(val[0], val[1], val[2])
189
- }
190
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
191
- {
192
- result = @builder.op_assign(
193
- @builder.index(
194
- val[0], val[1], val[2], val[3]),
195
- val[4], val[5])
196
- }
197
- | primary_value call_op tIDENTIFIER tOP_ASGN command_call
198
- {
199
- result = @builder.op_assign(
200
- @builder.call_method(
201
- val[0], val[1], val[2]),
202
- val[3], val[4])
203
- }
204
- | primary_value call_op tCONSTANT tOP_ASGN command_call
205
- {
206
- result = @builder.op_assign(
207
- @builder.call_method(
208
- val[0], val[1], val[2]),
209
- val[3], val[4])
210
- }
211
- | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
212
- {
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])
216
- }
217
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
218
- {
219
- result = @builder.op_assign(
220
- @builder.call_method(
221
- val[0], val[1], val[2]),
222
- val[3], val[4])
223
- }
224
- | backref tOP_ASGN command_call
225
- {
226
- @builder.op_assign(val[0], val[1], val[2])
227
- }
228
- | lhs tEQL mrhs
229
- {
230
- result = @builder.assign(val[0], val[1],
231
- @builder.array(nil, val[2], nil))
232
- }
233
- | mlhs tEQL mrhs_arg
234
- {
235
- result = @builder.multi_assign(val[0], val[1], val[2])
236
- }
237
- | expr
238
-
239
- command_asgn: lhs tEQL command_call
240
- {
241
- result = @builder.assign(val[0], val[1], val[2])
242
- }
243
- | lhs tEQL command_asgn
244
- {
245
- result = @builder.assign(val[0], val[1], val[2])
246
- }
247
-
248
- expr: command_call
249
- | expr kAND expr
250
- {
251
- result = @builder.logical_op(:and, val[0], val[1], val[2])
252
- }
253
- | expr kOR expr
254
- {
255
- result = @builder.logical_op(:or, val[0], val[1], val[2])
256
- }
257
- | kNOT opt_nl expr
258
- {
259
- result = @builder.not_op(val[0], nil, val[2], nil)
260
- }
261
- | tBANG command_call
262
- {
263
- result = @builder.not_op(val[0], nil, val[1], nil)
264
- }
265
- | arg
266
-
267
- expr_value: expr
268
-
269
- command_call: command
270
- | block_command
271
-
272
- block_command: block_call
273
- | block_call dot_or_colon operation2 command_args
274
- {
275
- result = @builder.call_method(val[0], val[1], val[2],
276
- nil, val[3], nil)
277
- }
278
-
279
- cmd_brace_block: tLBRACE_ARG
280
- {
281
- @static_env.extend_dynamic
282
- @context.push(:block)
283
- }
284
- opt_block_param compstmt tRCURLY
285
- {
286
- result = [ val[0], val[2], val[3], val[4] ]
287
-
288
- @static_env.unextend
289
- @context.pop
290
- }
291
-
292
- fcall: operation
293
-
294
- command: fcall command_args =tLOWEST
295
- {
296
- result = @builder.call_method(nil, nil, val[0],
297
- nil, val[1], nil)
298
- }
299
- | fcall command_args cmd_brace_block
300
- {
301
- method_call = @builder.call_method(nil, nil, val[0],
302
- nil, val[1], nil)
303
-
304
- begin_t, args, body, end_t = val[2]
305
- result = @builder.block(method_call,
306
- begin_t, args, body, end_t)
307
- }
308
- | primary_value call_op operation2 command_args =tLOWEST
309
- {
310
- result = @builder.call_method(val[0], val[1], val[2],
311
- nil, val[3], nil)
312
- }
313
- | primary_value call_op operation2 command_args cmd_brace_block
314
- {
315
- method_call = @builder.call_method(val[0], val[1], val[2],
316
- nil, val[3], nil)
317
-
318
- begin_t, args, body, end_t = val[4]
319
- result = @builder.block(method_call,
320
- begin_t, args, body, end_t)
321
- }
322
- | primary_value tCOLON2 operation2 command_args =tLOWEST
323
- {
324
- result = @builder.call_method(val[0], val[1], val[2],
325
- nil, val[3], nil)
326
- }
327
- | primary_value tCOLON2 operation2 command_args cmd_brace_block
328
- {
329
- method_call = @builder.call_method(val[0], val[1], val[2],
330
- nil, val[3], nil)
331
-
332
- begin_t, args, body, end_t = val[4]
333
- result = @builder.block(method_call,
334
- begin_t, args, body, end_t)
335
- }
336
- | kSUPER command_args
337
- {
338
- result = @builder.keyword_cmd(:super, val[0],
339
- nil, val[1], nil)
340
- }
341
- | kYIELD command_args
342
- {
343
- result = @builder.keyword_cmd(:yield, val[0],
344
- nil, val[1], nil)
345
- }
346
- | kRETURN call_args
347
- {
348
- result = @builder.keyword_cmd(:return, val[0],
349
- nil, val[1], nil)
350
- }
351
- | kBREAK call_args
352
- {
353
- result = @builder.keyword_cmd(:break, val[0],
354
- nil, val[1], nil)
355
- }
356
- | kNEXT call_args
357
- {
358
- result = @builder.keyword_cmd(:next, val[0],
359
- nil, val[1], nil)
360
- }
361
-
362
- mlhs: mlhs_basic
363
- {
364
- result = @builder.multi_lhs(nil, val[0], nil)
365
- }
366
- | tLPAREN mlhs_inner rparen
367
- {
368
- result = @builder.begin(val[0], val[1], val[2])
369
- }
370
-
371
- mlhs_inner: mlhs_basic
372
- {
373
- result = @builder.multi_lhs(nil, val[0], nil)
374
- }
375
- | tLPAREN mlhs_inner rparen
376
- {
377
- result = @builder.multi_lhs(val[0], val[1], val[2])
378
- }
379
-
380
- mlhs_basic: mlhs_head
381
- | mlhs_head mlhs_item
382
- {
383
- result = val[0].
384
- push(val[1])
385
- }
386
- | mlhs_head tSTAR mlhs_node
387
- {
388
- result = val[0].
389
- push(@builder.splat(val[1], val[2]))
390
- }
391
- | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
392
- {
393
- result = val[0].
394
- push(@builder.splat(val[1], val[2])).
395
- concat(val[4])
396
- }
397
- | mlhs_head tSTAR
398
- {
399
- result = val[0].
400
- push(@builder.splat(val[1]))
401
- }
402
- | mlhs_head tSTAR tCOMMA mlhs_post
403
- {
404
- result = val[0].
405
- push(@builder.splat(val[1])).
406
- concat(val[3])
407
- }
408
- | tSTAR mlhs_node
409
- {
410
- result = [ @builder.splat(val[0], val[1]) ]
411
- }
412
- | tSTAR mlhs_node tCOMMA mlhs_post
413
- {
414
- result = [ @builder.splat(val[0], val[1]),
415
- *val[3] ]
416
- }
417
- | tSTAR
418
- {
419
- result = [ @builder.splat(val[0]) ]
420
- }
421
- | tSTAR tCOMMA mlhs_post
422
- {
423
- result = [ @builder.splat(val[0]),
424
- *val[2] ]
425
- }
426
-
427
- mlhs_item: mlhs_node
428
- | tLPAREN mlhs_inner rparen
429
- {
430
- result = @builder.begin(val[0], val[1], val[2])
431
- }
432
-
433
- mlhs_head: mlhs_item tCOMMA
434
- {
435
- result = [ val[0] ]
436
- }
437
- | mlhs_head mlhs_item tCOMMA
438
- {
439
- result = val[0] << val[1]
440
- }
441
-
442
- mlhs_post: mlhs_item
443
- {
444
- result = [ val[0] ]
445
- }
446
- | mlhs_post tCOMMA mlhs_item
447
- {
448
- result = val[0] << val[2]
449
- }
450
-
451
- mlhs_node: user_variable
452
- {
453
- result = @builder.assignable(val[0])
454
- }
455
- | keyword_variable
456
- {
457
- result = @builder.assignable(val[0])
458
- }
459
- | primary_value tLBRACK2 opt_call_args rbracket
460
- {
461
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
462
- }
463
- | primary_value call_op tIDENTIFIER
464
- {
465
- result = @builder.attr_asgn(val[0], val[1], val[2])
466
- }
467
- | primary_value tCOLON2 tIDENTIFIER
468
- {
469
- result = @builder.attr_asgn(val[0], val[1], val[2])
470
- }
471
- | primary_value call_op tCONSTANT
472
- {
473
- result = @builder.attr_asgn(val[0], val[1], val[2])
474
- }
475
- | primary_value tCOLON2 tCONSTANT
476
- {
477
- result = @builder.assignable(
478
- @builder.const_fetch(val[0], val[1], val[2]))
479
- }
480
- | tCOLON3 tCONSTANT
481
- {
482
- result = @builder.assignable(
483
- @builder.const_global(val[0], val[1]))
484
- }
485
- | backref
486
- {
487
- result = @builder.assignable(val[0])
488
- }
489
-
490
- lhs: user_variable
491
- {
492
- result = @builder.assignable(val[0])
493
- }
494
- | keyword_variable
495
- {
496
- result = @builder.assignable(val[0])
497
- }
498
- | primary_value tLBRACK2 opt_call_args rbracket
499
- {
500
- result = @builder.index_asgn(val[0], val[1], val[2], val[3])
501
- }
502
- | primary_value call_op tIDENTIFIER
503
- {
504
- result = @builder.attr_asgn(val[0], val[1], val[2])
505
- }
506
- | primary_value tCOLON2 tIDENTIFIER
507
- {
508
- result = @builder.attr_asgn(val[0], val[1], val[2])
509
- }
510
- | primary_value call_op tCONSTANT
511
- {
512
- result = @builder.attr_asgn(val[0], val[1], val[2])
513
- }
514
- | primary_value tCOLON2 tCONSTANT
515
- {
516
- result = @builder.assignable(
517
- @builder.const_fetch(val[0], val[1], val[2]))
518
- }
519
- | tCOLON3 tCONSTANT
520
- {
521
- result = @builder.assignable(
522
- @builder.const_global(val[0], val[1]))
523
- }
524
- | backref
525
- {
526
- result = @builder.assignable(val[0])
527
- }
528
-
529
- cname: tIDENTIFIER
530
- {
531
- diagnostic :error, :module_name_const, nil, val[0]
532
- }
533
- | tCONSTANT
534
-
535
- cpath: tCOLON3 cname
536
- {
537
- result = @builder.const_global(val[0], val[1])
538
- }
539
- | cname
540
- {
541
- result = @builder.const(val[0])
542
- }
543
- | primary_value tCOLON2 cname
544
- {
545
- result = @builder.const_fetch(val[0], val[1], val[2])
546
- }
547
-
548
- fname: tIDENTIFIER | tCONSTANT | tFID
549
- | op
550
- | reswords
551
-
552
- fsym: fname
553
- {
554
- result = @builder.symbol(val[0])
555
- }
556
- | symbol
557
-
558
- fitem: fsym
559
- | dsym
560
-
561
- undef_list: fitem
562
- {
563
- result = [ val[0] ]
564
- }
565
- | undef_list tCOMMA
566
- {
567
- @lexer.state = :expr_fname
568
- }
569
- fitem
570
- {
571
- result = val[0] << val[3]
572
- }
573
-
574
- op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
575
- | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
576
- | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
577
- | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
578
- | tUPLUS | tUMINUS | tAREF | tASET | tDSTAR | tBACK_REF2
579
-
580
- reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
581
- | kALIAS | kAND | kBEGIN | kBREAK | kCASE
582
- | kCLASS | kDEF | kDEFINED | kDO | kELSE
583
- | kELSIF | kEND | kENSURE | kFALSE | kFOR
584
- | kIN | kMODULE | kNEXT | kNIL | kNOT
585
- | kOR | kREDO | kRESCUE | kRETRY | kRETURN
586
- | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
587
- | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
588
- | kUNTIL
589
-
590
- arg: lhs tEQL arg
591
- {
592
- result = @builder.assign(val[0], val[1], val[2])
593
- }
594
- | lhs tEQL arg kRESCUE_MOD arg
595
- {
596
- rescue_body = @builder.rescue_body(val[3],
597
- nil, nil, nil,
598
- nil, val[4])
599
-
600
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
601
-
602
- result = @builder.assign(val[0], val[1], rescue_)
603
- }
604
- | var_lhs tOP_ASGN arg
605
- {
606
- result = @builder.op_assign(val[0], val[1], val[2])
607
- }
608
- | var_lhs tOP_ASGN arg kRESCUE_MOD arg
609
- {
610
- rescue_body = @builder.rescue_body(val[3],
611
- nil, nil, nil,
612
- nil, val[4])
613
-
614
- rescue_ = @builder.begin_body(val[2], [ rescue_body ])
615
-
616
- result = @builder.op_assign(val[0], val[1], rescue_)
617
- }
618
- | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
619
- {
620
- result = @builder.op_assign(
621
- @builder.index(
622
- val[0], val[1], val[2], val[3]),
623
- val[4], val[5])
624
- }
625
- | primary_value call_op tIDENTIFIER tOP_ASGN arg
626
- {
627
- result = @builder.op_assign(
628
- @builder.call_method(
629
- val[0], val[1], val[2]),
630
- val[3], val[4])
631
- }
632
- | primary_value call_op tCONSTANT tOP_ASGN arg
633
- {
634
- result = @builder.op_assign(
635
- @builder.call_method(
636
- val[0], val[1], val[2]),
637
- val[3], val[4])
638
- }
639
- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
640
- {
641
- result = @builder.op_assign(
642
- @builder.call_method(
643
- val[0], val[1], val[2]),
644
- val[3], val[4])
645
- }
646
- | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
647
- {
648
- const = @builder.const_op_assignable(
649
- @builder.const_fetch(val[0], val[1], val[2]))
650
- result = @builder.op_assign(const, val[3], val[4])
651
- }
652
- | tCOLON3 tCONSTANT tOP_ASGN arg
653
- {
654
- const = @builder.const_op_assignable(
655
- @builder.const_global(val[0], val[1]))
656
- result = @builder.op_assign(const, val[2], val[3])
657
- }
658
- | backref tOP_ASGN arg
659
- {
660
- result = @builder.op_assign(val[0], val[1], val[2])
661
- }
662
- | arg tDOT2 arg
663
- {
664
- result = @builder.range_inclusive(val[0], val[1], val[2])
665
- }
666
- | arg tDOT3 arg
667
- {
668
- result = @builder.range_exclusive(val[0], val[1], val[2])
669
- }
670
- | arg tPLUS arg
671
- {
672
- result = @builder.binary_op(val[0], val[1], val[2])
673
- }
674
- | arg tMINUS arg
675
- {
676
- result = @builder.binary_op(val[0], val[1], val[2])
677
- }
678
- | arg tSTAR2 arg
679
- {
680
- result = @builder.binary_op(val[0], val[1], val[2])
681
- }
682
- | arg tDIVIDE arg
683
- {
684
- result = @builder.binary_op(val[0], val[1], val[2])
685
- }
686
- | arg tPERCENT arg
687
- {
688
- result = @builder.binary_op(val[0], val[1], val[2])
689
- }
690
- | arg tPOW arg
691
- {
692
- result = @builder.binary_op(val[0], val[1], val[2])
693
- }
694
- | tUNARY_NUM simple_numeric tPOW arg
695
- {
696
- result = @builder.unary_op(val[0],
697
- @builder.binary_op(
698
- val[1], val[2], val[3]))
699
- }
700
- | tUPLUS arg
701
- {
702
- result = @builder.unary_op(val[0], val[1])
703
- }
704
- | tUMINUS arg
705
- {
706
- result = @builder.unary_op(val[0], val[1])
707
- }
708
- | arg tPIPE arg
709
- {
710
- result = @builder.binary_op(val[0], val[1], val[2])
711
- }
712
- | arg tCARET arg
713
- {
714
- result = @builder.binary_op(val[0], val[1], val[2])
715
- }
716
- | arg tAMPER2 arg
717
- {
718
- result = @builder.binary_op(val[0], val[1], val[2])
719
- }
720
- | arg tCMP arg
721
- {
722
- result = @builder.binary_op(val[0], val[1], val[2])
723
- }
724
- | arg tGT arg
725
- {
726
- result = @builder.binary_op(val[0], val[1], val[2])
727
- }
728
- | arg tGEQ arg
729
- {
730
- result = @builder.binary_op(val[0], val[1], val[2])
731
- }
732
- | arg tLT arg
733
- {
734
- result = @builder.binary_op(val[0], val[1], val[2])
735
- }
736
- | arg tLEQ arg
737
- {
738
- result = @builder.binary_op(val[0], val[1], val[2])
739
- }
740
- | arg tEQ arg
741
- {
742
- result = @builder.binary_op(val[0], val[1], val[2])
743
- }
744
- | arg tEQQ arg
745
- {
746
- result = @builder.binary_op(val[0], val[1], val[2])
747
- }
748
- | arg tNEQ arg
749
- {
750
- result = @builder.binary_op(val[0], val[1], val[2])
751
- }
752
- | arg tMATCH arg
753
- {
754
- result = @builder.match_op(val[0], val[1], val[2])
755
- }
756
- | arg tNMATCH arg
757
- {
758
- result = @builder.binary_op(val[0], val[1], val[2])
759
- }
760
- | tBANG arg
761
- {
762
- result = @builder.not_op(val[0], nil, val[1], nil)
763
- }
764
- | tTILDE arg
765
- {
766
- result = @builder.unary_op(val[0], val[1])
767
- }
768
- | arg tLSHFT arg
769
- {
770
- result = @builder.binary_op(val[0], val[1], val[2])
771
- }
772
- | arg tRSHFT arg
773
- {
774
- result = @builder.binary_op(val[0], val[1], val[2])
775
- }
776
- | arg tANDOP arg
777
- {
778
- result = @builder.logical_op(:and, val[0], val[1], val[2])
779
- }
780
- | arg tOROP arg
781
- {
782
- result = @builder.logical_op(:or, val[0], val[1], val[2])
783
- }
784
- | kDEFINED opt_nl arg
785
- {
786
- result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
787
- }
788
- | arg tEH arg opt_nl tCOLON arg
789
- {
790
- result = @builder.ternary(val[0], val[1],
791
- val[2], val[4], val[5])
792
- }
793
- | primary
794
-
795
- arg_value: arg
796
-
797
- aref_args: none
798
- | args trailer
799
- | args tCOMMA assocs trailer
800
- {
801
- result = val[0] << @builder.associate(nil, val[2], nil)
802
- }
803
- | assocs trailer
804
- {
805
- result = [ @builder.associate(nil, val[0], nil) ]
806
- }
807
-
808
- paren_args: tLPAREN2 opt_call_args rparen
809
- {
810
- result = val
811
- }
812
-
813
- opt_paren_args: # nothing
814
- {
815
- result = [ nil, [], nil ]
816
- }
817
- | paren_args
818
-
819
- opt_call_args: # nothing
820
- {
821
- result = []
822
- }
823
- | call_args
824
- | args tCOMMA
825
- | args tCOMMA assocs tCOMMA
826
- {
827
- result = val[0] << @builder.associate(nil, val[2], nil)
828
- }
829
- | assocs tCOMMA
830
- {
831
- result = [ @builder.associate(nil, val[0], nil) ]
832
- }
833
-
834
- call_args: command
835
- {
836
- result = [ val[0] ]
837
- }
838
- | args opt_block_arg
839
- {
840
- result = val[0].concat(val[1])
841
- }
842
- | assocs opt_block_arg
843
- {
844
- result = [ @builder.associate(nil, val[0], nil) ]
845
- result.concat(val[1])
846
- }
847
- | args tCOMMA assocs opt_block_arg
848
- {
849
- assocs = @builder.associate(nil, val[2], nil)
850
- result = val[0] << assocs
851
- result.concat(val[3])
852
- }
853
- | block_arg
854
- {
855
- result = [ val[0] ]
856
- }
857
-
858
- command_args: {
859
- result = @lexer.cmdarg.dup
860
- @lexer.cmdarg.push(true)
861
- }
862
- call_args
863
- {
864
- @lexer.cmdarg = val[0]
865
-
866
- result = val[1]
867
- }
868
-
869
- block_arg: tAMPER arg_value
870
- {
871
- result = @builder.block_pass(val[0], val[1])
872
- }
873
-
874
- opt_block_arg: tCOMMA block_arg
875
- {
876
- result = [ val[1] ]
877
- }
878
- | # nothing
879
- {
880
- result = []
881
- }
882
-
883
- args: arg_value
884
- {
885
- result = [ val[0] ]
886
- }
887
- | tSTAR arg_value
888
- {
889
- result = [ @builder.splat(val[0], val[1]) ]
890
- }
891
- | args tCOMMA arg_value
892
- {
893
- result = val[0] << val[2]
894
- }
895
- | args tCOMMA tSTAR arg_value
896
- {
897
- result = val[0] << @builder.splat(val[2], val[3])
898
- }
899
-
900
- mrhs_arg: mrhs
901
- {
902
- result = @builder.array(nil, val[0], nil)
903
- }
904
- | arg_value
905
-
906
- mrhs: args tCOMMA arg_value
907
- {
908
- result = val[0] << val[2]
909
- }
910
- | args tCOMMA tSTAR arg_value
911
- {
912
- result = val[0] << @builder.splat(val[2], val[3])
913
- }
914
- | tSTAR arg_value
915
- {
916
- result = [ @builder.splat(val[0], val[1]) ]
917
- }
918
-
919
- primary: literal
920
- | strings
921
- | xstring
922
- | regexp
923
- | words
924
- | qwords
925
- | symbols
926
- | qsymbols
927
- | var_ref
928
- | backref
929
- | tFID
930
- {
931
- result = @builder.call_method(nil, nil, val[0])
932
- }
933
- | kBEGIN
934
- {
935
- result = @lexer.cmdarg.dup
936
- @lexer.cmdarg.clear
937
- }
938
- bodystmt kEND
939
- {
940
- @lexer.cmdarg = val[1]
941
-
942
- result = @builder.begin_keyword(val[0], val[2], val[3])
943
- }
944
- | tLPAREN_ARG
945
- {
946
- result = @lexer.cmdarg.dup
947
- @lexer.cmdarg.clear
948
- }
949
- expr
950
- {
951
- @lexer.state = :expr_endarg
952
- }
953
- opt_nl tRPAREN
954
- {
955
- @lexer.cmdarg = val[1]
956
-
957
- result = @builder.begin(val[0], val[2], val[5])
958
- }
959
- | tLPAREN_ARG
960
- {
961
- @lexer.state = :expr_endarg
962
- }
963
- opt_nl tRPAREN
964
- {
965
- result = @builder.begin(val[0], nil, val[3])
966
- }
967
- | tLPAREN compstmt tRPAREN
968
- {
969
- result = @builder.begin(val[0], val[1], val[2])
970
- }
971
- | primary_value tCOLON2 tCONSTANT
972
- {
973
- result = @builder.const_fetch(val[0], val[1], val[2])
974
- }
975
- | tCOLON3 tCONSTANT
976
- {
977
- result = @builder.const_global(val[0], val[1])
978
- }
979
- | tLBRACK aref_args tRBRACK
980
- {
981
- result = @builder.array(val[0], val[1], val[2])
982
- }
983
- | tLBRACE assoc_list tRCURLY
984
- {
985
- result = @builder.associate(val[0], val[1], val[2])
986
- }
987
- | kRETURN
988
- {
989
- result = @builder.keyword_cmd(:return, val[0])
990
- }
991
- | kYIELD tLPAREN2 call_args rparen
992
- {
993
- result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
994
- }
995
- | kYIELD tLPAREN2 rparen
996
- {
997
- result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
998
- }
999
- | kYIELD
1000
- {
1001
- result = @builder.keyword_cmd(:yield, val[0])
1002
- }
1003
- | kDEFINED opt_nl tLPAREN2 expr rparen
1004
- {
1005
- result = @builder.keyword_cmd(:defined?, val[0],
1006
- val[2], [ val[3] ], val[4])
1007
- }
1008
- | kNOT tLPAREN2 expr rparen
1009
- {
1010
- result = @builder.not_op(val[0], val[1], val[2], val[3])
1011
- }
1012
- | kNOT tLPAREN2 rparen
1013
- {
1014
- result = @builder.not_op(val[0], val[1], nil, val[2])
1015
- }
1016
- | fcall brace_block
1017
- {
1018
- method_call = @builder.call_method(nil, nil, val[0])
1019
-
1020
- begin_t, args, body, end_t = val[1]
1021
- result = @builder.block(method_call,
1022
- begin_t, args, body, end_t)
1023
- }
1024
- | method_call
1025
- | method_call brace_block
1026
- {
1027
- begin_t, args, body, end_t = val[1]
1028
- result = @builder.block(val[0],
1029
- begin_t, args, body, end_t)
1030
- }
1031
- | tLAMBDA lambda
1032
- {
1033
- lambda_call = @builder.call_lambda(val[0])
1034
-
1035
- args, (begin_t, body, end_t) = val[1]
1036
- result = @builder.block(lambda_call,
1037
- begin_t, args, body, end_t)
1038
- }
1039
- | kIF expr_value then compstmt if_tail kEND
1040
- {
1041
- else_t, else_ = val[4]
1042
- result = @builder.condition(val[0], val[1], val[2],
1043
- val[3], else_t,
1044
- else_, val[5])
1045
- }
1046
- | kUNLESS expr_value then compstmt opt_else kEND
1047
- {
1048
- else_t, else_ = val[4]
1049
- result = @builder.condition(val[0], val[1], val[2],
1050
- else_, else_t,
1051
- val[3], val[5])
1052
- }
1053
- | kWHILE
1054
- {
1055
- @lexer.cond.push(true)
1056
- }
1057
- expr_value do
1058
- {
1059
- @lexer.cond.pop
1060
- }
1061
- compstmt kEND
1062
- {
1063
- result = @builder.loop(:while, val[0], val[2], val[3],
1064
- val[5], val[6])
1065
- }
1066
- | kUNTIL
1067
- {
1068
- @lexer.cond.push(true)
1069
- }
1070
- expr_value do
1071
- {
1072
- @lexer.cond.pop
1073
- }
1074
- compstmt kEND
1075
- {
1076
- result = @builder.loop(:until, val[0], val[2], val[3],
1077
- val[5], val[6])
1078
- }
1079
- | kCASE expr_value opt_terms case_body kEND
1080
- {
1081
- *when_bodies, (else_t, else_body) = *val[3]
1082
-
1083
- result = @builder.case(val[0], val[1],
1084
- when_bodies, else_t, else_body,
1085
- val[4])
1086
- }
1087
- | kCASE opt_terms case_body kEND
1088
- {
1089
- *when_bodies, (else_t, else_body) = *val[2]
1090
-
1091
- result = @builder.case(val[0], nil,
1092
- when_bodies, else_t, else_body,
1093
- val[3])
1094
- }
1095
- | kFOR for_var kIN
1096
- {
1097
- @lexer.cond.push(true)
1098
- }
1099
- expr_value do
1100
- {
1101
- @lexer.cond.pop
1102
- }
1103
- compstmt kEND
1104
- {
1105
- result = @builder.for(val[0], val[1],
1106
- val[2], val[4],
1107
- val[5], val[7], val[8])
1108
- }
1109
- | kCLASS cpath superclass
1110
- {
1111
- @static_env.extend_static
1112
- @lexer.push_cmdarg
1113
- @context.push(:class)
1114
- }
1115
- bodystmt kEND
1116
- {
1117
- unless @context.class_definition_allowed?
1118
- diagnostic :error, :class_in_def, nil, val[0]
1119
- end
1120
-
1121
- lt_t, superclass = val[2]
1122
- result = @builder.def_class(val[0], val[1],
1123
- lt_t, superclass,
1124
- val[4], val[5])
1125
-
1126
- @lexer.pop_cmdarg
1127
- @static_env.unextend
1128
- @context.pop
1129
- }
1130
- | kCLASS tLSHFT expr term
1131
- {
1132
- @static_env.extend_static
1133
- @lexer.push_cmdarg
1134
- @context.push(:sclass)
1135
- }
1136
- bodystmt kEND
1137
- {
1138
- result = @builder.def_sclass(val[0], val[1], val[2],
1139
- val[5], val[6])
1140
-
1141
- @lexer.pop_cmdarg
1142
- @static_env.unextend
1143
- @context.pop
1144
- }
1145
- | kMODULE cpath
1146
- {
1147
- @static_env.extend_static
1148
- @lexer.push_cmdarg
1149
- }
1150
- bodystmt kEND
1151
- {
1152
- unless @context.module_definition_allowed?
1153
- diagnostic :error, :module_in_def, nil, val[0]
1154
- end
1155
-
1156
- result = @builder.def_module(val[0], val[1],
1157
- val[3], val[4])
1158
-
1159
- @lexer.pop_cmdarg
1160
- @static_env.unextend
1161
- }
1162
- | kDEF fname
1163
- {
1164
- @static_env.extend_static
1165
- @lexer.push_cmdarg
1166
- @context.push(:def)
1167
- }
1168
- f_arglist bodystmt kEND
1169
- {
1170
- result = @builder.def_method(val[0], val[1],
1171
- val[3], val[4], val[5])
1172
-
1173
- @lexer.pop_cmdarg
1174
- @static_env.unextend
1175
- @context.pop
1176
- }
1177
- | kDEF singleton dot_or_colon
1178
- {
1179
- @lexer.state = :expr_fname
1180
- }
1181
- fname
1182
- {
1183
- @static_env.extend_static
1184
- @lexer.push_cmdarg
1185
- @context.push(:defs)
1186
- }
1187
- f_arglist bodystmt kEND
1188
- {
1189
- result = @builder.def_singleton(val[0], val[1], val[2],
1190
- val[4], val[6], val[7], val[8])
1191
-
1192
- @lexer.pop_cmdarg
1193
- @static_env.unextend
1194
- @context.pop
1195
- }
1196
- | kBREAK
1197
- {
1198
- result = @builder.keyword_cmd(:break, val[0])
1199
- }
1200
- | kNEXT
1201
- {
1202
- result = @builder.keyword_cmd(:next, val[0])
1203
- }
1204
- | kREDO
1205
- {
1206
- result = @builder.keyword_cmd(:redo, val[0])
1207
- }
1208
- | kRETRY
1209
- {
1210
- result = @builder.keyword_cmd(:retry, val[0])
1211
- }
1212
-
1213
- primary_value: primary
1214
-
1215
- then: term
1216
- | kTHEN
1217
- | term kTHEN
1218
- {
1219
- result = val[1]
1220
- }
1221
-
1222
- do: term
1223
- | kDO_COND
1224
-
1225
- if_tail: opt_else
1226
- | kELSIF expr_value then compstmt if_tail
1227
- {
1228
- else_t, else_ = val[4]
1229
- result = [ val[0],
1230
- @builder.condition(val[0], val[1], val[2],
1231
- val[3], else_t,
1232
- else_, nil),
1233
- ]
1234
- }
1235
-
1236
- opt_else: none
1237
- | kELSE compstmt
1238
- {
1239
- result = val
1240
- }
1241
-
1242
- for_var: lhs
1243
- | mlhs
1244
-
1245
- f_marg: f_norm_arg
1246
- {
1247
- result = @builder.arg(val[0])
1248
- }
1249
- | tLPAREN f_margs rparen
1250
- {
1251
- result = @builder.multi_lhs(val[0], val[1], val[2])
1252
- }
1253
-
1254
- f_marg_list: f_marg
1255
- {
1256
- result = [ val[0] ]
1257
- }
1258
- | f_marg_list tCOMMA f_marg
1259
- {
1260
- result = val[0] << val[2]
1261
- }
1262
-
1263
- f_margs: f_marg_list
1264
- | f_marg_list tCOMMA tSTAR f_norm_arg
1265
- {
1266
- result = val[0].
1267
- push(@builder.restarg(val[2], val[3]))
1268
- }
1269
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1270
- {
1271
- result = val[0].
1272
- push(@builder.restarg(val[2], val[3])).
1273
- concat(val[5])
1274
- }
1275
- | f_marg_list tCOMMA tSTAR
1276
- {
1277
- result = val[0].
1278
- push(@builder.restarg(val[2]))
1279
- }
1280
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1281
- {
1282
- result = val[0].
1283
- push(@builder.restarg(val[2])).
1284
- concat(val[4])
1285
- }
1286
- | tSTAR f_norm_arg
1287
- {
1288
- result = [ @builder.restarg(val[0], val[1]) ]
1289
- }
1290
- | tSTAR f_norm_arg tCOMMA f_marg_list
1291
- {
1292
- result = [ @builder.restarg(val[0], val[1]),
1293
- *val[3] ]
1294
- }
1295
- | tSTAR
1296
- {
1297
- result = [ @builder.restarg(val[0]) ]
1298
- }
1299
- | tSTAR tCOMMA f_marg_list
1300
- {
1301
- result = [ @builder.restarg(val[0]),
1302
- *val[2] ]
1303
- }
1304
-
1305
- block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
1306
- {
1307
- result = val[0].concat(val[2]).concat(val[3])
1308
- }
1309
- | f_block_kwarg opt_f_block_arg
1310
- {
1311
- result = val[0].concat(val[1])
1312
- }
1313
- | f_kwrest opt_f_block_arg
1314
- {
1315
- result = val[0].concat(val[1])
1316
- }
1317
- | f_block_arg
1318
- {
1319
- result = [ val[0] ]
1320
- }
1321
-
1322
- opt_block_args_tail:
1323
- tCOMMA block_args_tail
1324
- {
1325
- result = val[1]
1326
- }
1327
- | # nothing
1328
- {
1329
- result = []
1330
- }
1331
-
1332
- block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1333
- {
1334
- result = val[0].
1335
- concat(val[2]).
1336
- concat(val[4]).
1337
- concat(val[5])
1338
- }
1339
- | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1340
- {
1341
- result = val[0].
1342
- concat(val[2]).
1343
- concat(val[4]).
1344
- concat(val[6]).
1345
- concat(val[7])
1346
- }
1347
- | f_arg tCOMMA f_block_optarg opt_block_args_tail
1348
- {
1349
- result = val[0].
1350
- concat(val[2]).
1351
- concat(val[3])
1352
- }
1353
- | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
1354
- {
1355
- result = val[0].
1356
- concat(val[2]).
1357
- concat(val[4]).
1358
- concat(val[5])
1359
- }
1360
- | f_arg tCOMMA f_rest_arg opt_block_args_tail
1361
- {
1362
- result = val[0].
1363
- concat(val[2]).
1364
- concat(val[3])
1365
- }
1366
- | f_arg tCOMMA
1367
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1368
- {
1369
- result = val[0].
1370
- concat(val[2]).
1371
- concat(val[4]).
1372
- concat(val[5])
1373
- }
1374
- | f_arg opt_block_args_tail
1375
- {
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
- }
1382
- | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1383
- {
1384
- result = val[0].
1385
- concat(val[2]).
1386
- concat(val[3])
1387
- }
1388
- | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1389
- {
1390
- result = val[0].
1391
- concat(val[2]).
1392
- concat(val[4]).
1393
- concat(val[5])
1394
- }
1395
- | f_block_optarg opt_block_args_tail
1396
- {
1397
- result = val[0].
1398
- concat(val[1])
1399
- }
1400
- | f_block_optarg tCOMMA f_arg opt_block_args_tail
1401
- {
1402
- result = val[0].
1403
- concat(val[2]).
1404
- concat(val[3])
1405
- }
1406
- | f_rest_arg opt_block_args_tail
1407
- {
1408
- result = val[0].
1409
- concat(val[1])
1410
- }
1411
- | f_rest_arg tCOMMA f_arg opt_block_args_tail
1412
- {
1413
- result = val[0].
1414
- concat(val[2]).
1415
- concat(val[3])
1416
- }
1417
- | block_args_tail
1418
-
1419
- opt_block_param: # nothing
1420
- {
1421
- result = @builder.args(nil, [], nil)
1422
- }
1423
- | block_param_def
1424
- {
1425
- @lexer.state = :expr_value
1426
- }
1427
-
1428
- block_param_def: tPIPE opt_bv_decl tPIPE
1429
- {
1430
- result = @builder.args(val[0], val[1], val[2])
1431
- }
1432
- | tOROP
1433
- {
1434
- result = @builder.args(val[0], [], val[0])
1435
- }
1436
- | tPIPE block_param opt_bv_decl tPIPE
1437
- {
1438
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
1439
- }
1440
-
1441
- opt_bv_decl: opt_nl
1442
- {
1443
- result = []
1444
- }
1445
- | opt_nl tSEMI bv_decls opt_nl
1446
- {
1447
- result = val[2]
1448
- }
1449
-
1450
- bv_decls: bvar
1451
- {
1452
- result = [ val[0] ]
1453
- }
1454
- | bv_decls tCOMMA bvar
1455
- {
1456
- result = val[0] << val[2]
1457
- }
1458
-
1459
- bvar: tIDENTIFIER
1460
- {
1461
- @static_env.declare val[0][0]
1462
- result = @builder.shadowarg(val[0])
1463
- }
1464
- | f_bad_arg
1465
-
1466
- lambda: {
1467
- @static_env.extend_dynamic
1468
- }
1469
- f_larglist
1470
- {
1471
- result = @lexer.cmdarg.dup
1472
- @lexer.cmdarg.clear
1473
- }
1474
- lambda_body
1475
- {
1476
- @lexer.cmdarg = val[2]
1477
- @lexer.cmdarg.lexpop
1478
-
1479
- result = [ val[1], val[3] ]
1480
-
1481
- @static_env.unextend
1482
- }
1483
-
1484
- f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
1485
- {
1486
- result = @builder.args(val[0], val[1].concat(val[2]), val[3])
1487
- }
1488
- | f_args
1489
- {
1490
- result = @builder.args(nil, val[0], nil)
1491
- }
1492
-
1493
- lambda_body: tLAMBEG
1494
- {
1495
- @context.push(:lambda)
1496
- }
1497
- compstmt tRCURLY
1498
- {
1499
- result = [ val[0], val[2], val[3] ]
1500
- @context.pop
1501
- }
1502
- | kDO_LAMBDA
1503
- {
1504
- @context.push(:lambda)
1505
- }
1506
- compstmt kEND
1507
- {
1508
- result = [ val[0], val[2], val[3] ]
1509
- @context.pop
1510
- }
1511
-
1512
- do_block: kDO_BLOCK
1513
- {
1514
- @static_env.extend_dynamic
1515
- @context.push(:block)
1516
- }
1517
- opt_block_param compstmt kEND
1518
- {
1519
- result = [ val[0], val[2], val[3], val[4] ]
1520
-
1521
- @static_env.unextend
1522
- @context.pop
1523
- }
1524
-
1525
- block_call: command do_block
1526
- {
1527
- begin_t, block_args, body, end_t = val[1]
1528
- result = @builder.block(val[0],
1529
- begin_t, block_args, body, end_t)
1530
- }
1531
- | block_call dot_or_colon operation2 opt_paren_args
1532
- {
1533
- lparen_t, args, rparen_t = val[3]
1534
- result = @builder.call_method(val[0], val[1], val[2],
1535
- lparen_t, args, rparen_t)
1536
- }
1537
- | block_call dot_or_colon operation2 opt_paren_args brace_block
1538
- {
1539
- lparen_t, args, rparen_t = val[3]
1540
- method_call = @builder.call_method(val[0], val[1], val[2],
1541
- lparen_t, args, rparen_t)
1542
-
1543
- begin_t, args, body, end_t = val[4]
1544
- result = @builder.block(method_call,
1545
- begin_t, args, body, end_t)
1546
- }
1547
- | block_call dot_or_colon operation2 command_args do_block
1548
- {
1549
- method_call = @builder.call_method(val[0], val[1], val[2],
1550
- nil, val[3], nil)
1551
-
1552
- begin_t, args, body, end_t = val[4]
1553
- result = @builder.block(method_call,
1554
- begin_t, args, body, end_t)
1555
- }
1556
-
1557
- method_call: fcall paren_args
1558
- {
1559
- lparen_t, args, rparen_t = val[1]
1560
- result = @builder.call_method(nil, nil, val[0],
1561
- lparen_t, args, rparen_t)
1562
- }
1563
- | primary_value call_op operation2 opt_paren_args
1564
- {
1565
- lparen_t, args, rparen_t = val[3]
1566
- result = @builder.call_method(val[0], val[1], val[2],
1567
- lparen_t, args, rparen_t)
1568
- }
1569
- | primary_value tCOLON2 operation2 paren_args
1570
- {
1571
- lparen_t, args, rparen_t = val[3]
1572
- result = @builder.call_method(val[0], val[1], val[2],
1573
- lparen_t, args, rparen_t)
1574
- }
1575
- | primary_value tCOLON2 operation3
1576
- {
1577
- result = @builder.call_method(val[0], val[1], val[2])
1578
- }
1579
- | primary_value call_op paren_args
1580
- {
1581
- lparen_t, args, rparen_t = val[2]
1582
- result = @builder.call_method(val[0], val[1], nil,
1583
- lparen_t, args, rparen_t)
1584
- }
1585
- | primary_value tCOLON2 paren_args
1586
- {
1587
- lparen_t, args, rparen_t = val[2]
1588
- result = @builder.call_method(val[0], val[1], nil,
1589
- lparen_t, args, rparen_t)
1590
- }
1591
- | kSUPER paren_args
1592
- {
1593
- lparen_t, args, rparen_t = val[1]
1594
- result = @builder.keyword_cmd(:super, val[0],
1595
- lparen_t, args, rparen_t)
1596
- }
1597
- | kSUPER
1598
- {
1599
- result = @builder.keyword_cmd(:zsuper, val[0])
1600
- }
1601
- | primary_value tLBRACK2 opt_call_args rbracket
1602
- {
1603
- result = @builder.index(val[0], val[1], val[2], val[3])
1604
- }
1605
-
1606
- brace_block: tLCURLY
1607
- {
1608
- @static_env.extend_dynamic
1609
- @context.push(:block)
1610
- }
1611
- opt_block_param compstmt tRCURLY
1612
- {
1613
- result = [ val[0], val[2], val[3], val[4] ]
1614
-
1615
- @static_env.unextend
1616
- @context.pop
1617
- }
1618
- | kDO
1619
- {
1620
- @static_env.extend_dynamic
1621
- @context.push(:block)
1622
- }
1623
- opt_block_param compstmt kEND
1624
- {
1625
- result = [ val[0], val[2], val[3], val[4] ]
1626
-
1627
- @static_env.unextend
1628
- @context.pop
1629
- }
1630
-
1631
- case_body: kWHEN args then compstmt cases
1632
- {
1633
- result = [ @builder.when(val[0], val[1], val[2], val[3]),
1634
- *val[4] ]
1635
- }
1636
-
1637
- cases: opt_else
1638
- {
1639
- result = [ val[0] ]
1640
- }
1641
- | case_body
1642
-
1643
- opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
1644
- {
1645
- assoc_t, exc_var = val[2]
1646
-
1647
- if val[1]
1648
- exc_list = @builder.array(nil, val[1], nil)
1649
- end
1650
-
1651
- result = [ @builder.rescue_body(val[0],
1652
- exc_list, assoc_t, exc_var,
1653
- val[3], val[4]),
1654
- *val[5] ]
1655
- }
1656
- |
1657
- {
1658
- result = []
1659
- }
1660
-
1661
- exc_list: arg_value
1662
- {
1663
- result = [ val[0] ]
1664
- }
1665
- | mrhs
1666
- | none
1667
-
1668
- exc_var: tASSOC lhs
1669
- {
1670
- result = [ val[0], val[1] ]
1671
- }
1672
- | none
1673
-
1674
- opt_ensure: kENSURE compstmt
1675
- {
1676
- result = [ val[0], val[1] ]
1677
- }
1678
- | none
1679
-
1680
- literal: numeric
1681
- | symbol
1682
- | dsym
1683
-
1684
- strings: string
1685
- {
1686
- result = @builder.string_compose(nil, val[0], nil)
1687
- }
1688
-
1689
- string: string1
1690
- {
1691
- result = [ val[0] ]
1692
- }
1693
- | string string1
1694
- {
1695
- result = val[0] << val[1]
1696
- }
1697
-
1698
- string1: tSTRING_BEG string_contents tSTRING_END
1699
- {
1700
- string = @builder.string_compose(val[0], val[1], val[2])
1701
- result = @builder.dedent_string(string, @lexer.dedent_level)
1702
- }
1703
- | tSTRING
1704
- {
1705
- string = @builder.string(val[0])
1706
- result = @builder.dedent_string(string, @lexer.dedent_level)
1707
- }
1708
- | tCHARACTER
1709
- {
1710
- result = @builder.character(val[0])
1711
- }
1712
-
1713
- xstring: tXSTRING_BEG xstring_contents tSTRING_END
1714
- {
1715
- string = @builder.xstring_compose(val[0], val[1], val[2])
1716
- result = @builder.dedent_string(string, @lexer.dedent_level)
1717
- }
1718
-
1719
- regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
1720
- {
1721
- opts = @builder.regexp_options(val[3])
1722
- result = @builder.regexp_compose(val[0], val[1], val[2], opts)
1723
- }
1724
-
1725
- words: tWORDS_BEG word_list tSTRING_END
1726
- {
1727
- result = @builder.words_compose(val[0], val[1], val[2])
1728
- }
1729
-
1730
- word_list: # nothing
1731
- {
1732
- result = []
1733
- }
1734
- | word_list word tSPACE
1735
- {
1736
- result = val[0] << @builder.word(val[1])
1737
- }
1738
-
1739
- word: string_content
1740
- {
1741
- result = [ val[0] ]
1742
- }
1743
- | word string_content
1744
- {
1745
- result = val[0] << val[1]
1746
- }
1747
-
1748
- symbols: tSYMBOLS_BEG symbol_list tSTRING_END
1749
- {
1750
- result = @builder.symbols_compose(val[0], val[1], val[2])
1751
- }
1752
-
1753
- symbol_list: # nothing
1754
- {
1755
- result = []
1756
- }
1757
- | symbol_list word tSPACE
1758
- {
1759
- result = val[0] << @builder.word(val[1])
1760
- }
1761
-
1762
- qwords: tQWORDS_BEG qword_list tSTRING_END
1763
- {
1764
- result = @builder.words_compose(val[0], val[1], val[2])
1765
- }
1766
-
1767
- qsymbols: tQSYMBOLS_BEG qsym_list tSTRING_END
1768
- {
1769
- result = @builder.symbols_compose(val[0], val[1], val[2])
1770
- }
1771
-
1772
- qword_list: # nothing
1773
- {
1774
- result = []
1775
- }
1776
- | qword_list tSTRING_CONTENT tSPACE
1777
- {
1778
- result = val[0] << @builder.string_internal(val[1])
1779
- }
1780
-
1781
- qsym_list: # nothing
1782
- {
1783
- result = []
1784
- }
1785
- | qsym_list tSTRING_CONTENT tSPACE
1786
- {
1787
- result = val[0] << @builder.symbol_internal(val[1])
1788
- }
1789
-
1790
- string_contents: # nothing
1791
- {
1792
- result = []
1793
- }
1794
- | string_contents string_content
1795
- {
1796
- result = val[0] << val[1]
1797
- }
1798
-
1799
- xstring_contents: # nothing
1800
- {
1801
- result = []
1802
- }
1803
- | xstring_contents string_content
1804
- {
1805
- result = val[0] << val[1]
1806
- }
1807
-
1808
- regexp_contents: # nothing
1809
- {
1810
- result = []
1811
- }
1812
- | regexp_contents string_content
1813
- {
1814
- result = val[0] << val[1]
1815
- }
1816
-
1817
- string_content: tSTRING_CONTENT
1818
- {
1819
- result = @builder.string_internal(val[0])
1820
- }
1821
- | tSTRING_DVAR string_dvar
1822
- {
1823
- result = val[1]
1824
- }
1825
- | tSTRING_DBEG
1826
- {
1827
- @lexer.cond.push(false)
1828
- @lexer.cmdarg.push(false)
1829
- }
1830
- compstmt tSTRING_DEND
1831
- {
1832
- @lexer.cond.lexpop
1833
- @lexer.cmdarg.lexpop
1834
-
1835
- result = @builder.begin(val[0], val[2], val[3])
1836
- }
1837
-
1838
- string_dvar: tGVAR
1839
- {
1840
- result = @builder.gvar(val[0])
1841
- }
1842
- | tIVAR
1843
- {
1844
- result = @builder.ivar(val[0])
1845
- }
1846
- | tCVAR
1847
- {
1848
- result = @builder.cvar(val[0])
1849
- }
1850
- | backref
1851
-
1852
-
1853
- symbol: tSYMBOL
1854
- {
1855
- result = @builder.symbol(val[0])
1856
- }
1857
-
1858
- dsym: tSYMBEG xstring_contents tSTRING_END
1859
- {
1860
- result = @builder.symbol_compose(val[0], val[1], val[2])
1861
- }
1862
-
1863
- numeric: simple_numeric
1864
- {
1865
- result = val[0]
1866
- }
1867
- | tUNARY_NUM simple_numeric =tLOWEST
1868
- {
1869
- if @builder.respond_to? :negate
1870
- # AST builder interface compatibility
1871
- result = @builder.negate(val[0], val[1])
1872
- else
1873
- result = @builder.unary_num(val[0], val[1])
1874
- end
1875
- }
1876
-
1877
- simple_numeric: tINTEGER
1878
- {
1879
- result = @builder.integer(val[0])
1880
- }
1881
- | tFLOAT
1882
- {
1883
- result = @builder.float(val[0])
1884
- }
1885
- | tRATIONAL
1886
- {
1887
- result = @builder.rational(val[0])
1888
- }
1889
- | tIMAGINARY
1890
- {
1891
- result = @builder.complex(val[0])
1892
- }
1893
-
1894
- user_variable: tIDENTIFIER
1895
- {
1896
- result = @builder.ident(val[0])
1897
- }
1898
- | tIVAR
1899
- {
1900
- result = @builder.ivar(val[0])
1901
- }
1902
- | tGVAR
1903
- {
1904
- result = @builder.gvar(val[0])
1905
- }
1906
- | tCONSTANT
1907
- {
1908
- result = @builder.const(val[0])
1909
- }
1910
- | tCVAR
1911
- {
1912
- result = @builder.cvar(val[0])
1913
- }
1914
-
1915
- keyword_variable: kNIL
1916
- {
1917
- result = @builder.nil(val[0])
1918
- }
1919
- | kSELF
1920
- {
1921
- result = @builder.self(val[0])
1922
- }
1923
- | kTRUE
1924
- {
1925
- result = @builder.true(val[0])
1926
- }
1927
- | kFALSE
1928
- {
1929
- result = @builder.false(val[0])
1930
- }
1931
- | k__FILE__
1932
- {
1933
- result = @builder.__FILE__(val[0])
1934
- }
1935
- | k__LINE__
1936
- {
1937
- result = @builder.__LINE__(val[0])
1938
- }
1939
- | k__ENCODING__
1940
- {
1941
- result = @builder.__ENCODING__(val[0])
1942
- }
1943
-
1944
- var_ref: user_variable
1945
- {
1946
- result = @builder.accessible(val[0])
1947
- }
1948
- | keyword_variable
1949
- {
1950
- result = @builder.accessible(val[0])
1951
- }
1952
-
1953
- var_lhs: user_variable
1954
- {
1955
- result = @builder.assignable(val[0])
1956
- }
1957
- | keyword_variable
1958
- {
1959
- result = @builder.assignable(val[0])
1960
- }
1961
-
1962
- backref: tNTH_REF
1963
- {
1964
- result = @builder.nth_ref(val[0])
1965
- }
1966
- | tBACK_REF
1967
- {
1968
- result = @builder.back_ref(val[0])
1969
- }
1970
-
1971
- superclass: tLT
1972
- {
1973
- @lexer.state = :expr_value
1974
- }
1975
- expr_value term
1976
- {
1977
- result = [ val[0], val[2] ]
1978
- }
1979
- | # nothing
1980
- {
1981
- result = nil
1982
- }
1983
-
1984
- f_arglist: tLPAREN2 f_args rparen
1985
- {
1986
- result = @builder.args(val[0], val[1], val[2])
1987
-
1988
- @lexer.state = :expr_value
1989
- }
1990
- | {
1991
- result = @lexer.in_kwarg
1992
- @lexer.in_kwarg = true
1993
- }
1994
- f_args term
1995
- {
1996
- @lexer.in_kwarg = val[0]
1997
- result = @builder.args(nil, val[1], nil)
1998
- }
1999
-
2000
- args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
2001
- {
2002
- result = val[0].concat(val[2]).concat(val[3])
2003
- }
2004
- | f_kwarg opt_f_block_arg
2005
- {
2006
- result = val[0].concat(val[1])
2007
- }
2008
- | f_kwrest opt_f_block_arg
2009
- {
2010
- result = val[0].concat(val[1])
2011
- }
2012
- | f_block_arg
2013
- {
2014
- result = [ val[0] ]
2015
- }
2016
-
2017
- opt_args_tail: tCOMMA args_tail
2018
- {
2019
- result = val[1]
2020
- }
2021
- | # nothing
2022
- {
2023
- result = []
2024
- }
2025
-
2026
- f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
2027
- {
2028
- result = val[0].
2029
- concat(val[2]).
2030
- concat(val[4]).
2031
- concat(val[5])
2032
- }
2033
- | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2034
- {
2035
- result = val[0].
2036
- concat(val[2]).
2037
- concat(val[4]).
2038
- concat(val[6]).
2039
- concat(val[7])
2040
- }
2041
- | f_arg tCOMMA f_optarg opt_args_tail
2042
- {
2043
- result = val[0].
2044
- concat(val[2]).
2045
- concat(val[3])
2046
- }
2047
- | f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
2048
- {
2049
- result = val[0].
2050
- concat(val[2]).
2051
- concat(val[4]).
2052
- concat(val[5])
2053
- }
2054
- | f_arg tCOMMA f_rest_arg opt_args_tail
2055
- {
2056
- result = val[0].
2057
- concat(val[2]).
2058
- concat(val[3])
2059
- }
2060
- | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2061
- {
2062
- result = val[0].
2063
- concat(val[2]).
2064
- concat(val[4]).
2065
- concat(val[5])
2066
- }
2067
- | f_arg opt_args_tail
2068
- {
2069
- result = val[0].
2070
- concat(val[1])
2071
- }
2072
- | f_optarg tCOMMA f_rest_arg opt_args_tail
2073
- {
2074
- result = val[0].
2075
- concat(val[2]).
2076
- concat(val[3])
2077
- }
2078
- | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2079
- {
2080
- result = val[0].
2081
- concat(val[2]).
2082
- concat(val[4]).
2083
- concat(val[5])
2084
- }
2085
- | f_optarg opt_args_tail
2086
- {
2087
- result = val[0].
2088
- concat(val[1])
2089
- }
2090
- | f_optarg tCOMMA f_arg opt_args_tail
2091
- {
2092
- result = val[0].
2093
- concat(val[2]).
2094
- concat(val[3])
2095
- }
2096
- | f_rest_arg opt_args_tail
2097
- {
2098
- result = val[0].
2099
- concat(val[1])
2100
- }
2101
- | f_rest_arg tCOMMA f_arg opt_args_tail
2102
- {
2103
- result = val[0].
2104
- concat(val[2]).
2105
- concat(val[3])
2106
- }
2107
- | args_tail
2108
- {
2109
- result = val[0]
2110
- }
2111
- | # nothing
2112
- {
2113
- result = []
2114
- }
2115
-
2116
- f_bad_arg: tCONSTANT
2117
- {
2118
- diagnostic :error, :argument_const, nil, val[0]
2119
- }
2120
- | tIVAR
2121
- {
2122
- diagnostic :error, :argument_ivar, nil, val[0]
2123
- }
2124
- | tGVAR
2125
- {
2126
- diagnostic :error, :argument_gvar, nil, val[0]
2127
- }
2128
- | tCVAR
2129
- {
2130
- diagnostic :error, :argument_cvar, nil, val[0]
2131
- }
2132
-
2133
- f_norm_arg: f_bad_arg
2134
- | tIDENTIFIER
2135
- {
2136
- @static_env.declare val[0][0]
2137
-
2138
- result = val[0]
2139
- }
2140
-
2141
- f_arg_asgn: f_norm_arg
2142
- {
2143
- result = val[0]
2144
- }
2145
-
2146
- f_arg_item: f_arg_asgn
2147
- {
2148
- result = @builder.arg(val[0])
2149
- }
2150
- | tLPAREN f_margs rparen
2151
- {
2152
- result = @builder.multi_lhs(val[0], val[1], val[2])
2153
- }
2154
-
2155
- f_arg: f_arg_item
2156
- {
2157
- result = [ val[0] ]
2158
- }
2159
- | f_arg tCOMMA f_arg_item
2160
- {
2161
- result = val[0] << val[2]
2162
- }
2163
-
2164
- f_label: tLABEL
2165
- {
2166
- check_kwarg_name(val[0])
2167
-
2168
- @static_env.declare val[0][0]
2169
-
2170
- result = val[0]
2171
- }
2172
-
2173
- f_kw: f_label arg_value
2174
- {
2175
- result = @builder.kwoptarg(val[0], val[1])
2176
- }
2177
- | f_label
2178
- {
2179
- result = @builder.kwarg(val[0])
2180
- }
2181
-
2182
- f_block_kw: f_label primary_value
2183
- {
2184
- result = @builder.kwoptarg(val[0], val[1])
2185
- }
2186
- | f_label
2187
- {
2188
- result = @builder.kwarg(val[0])
2189
- }
2190
-
2191
- f_block_kwarg: f_block_kw
2192
- {
2193
- result = [ val[0] ]
2194
- }
2195
- | f_block_kwarg tCOMMA f_block_kw
2196
- {
2197
- result = val[0] << val[2]
2198
- }
2199
-
2200
- f_kwarg: f_kw
2201
- {
2202
- result = [ val[0] ]
2203
- }
2204
- | f_kwarg tCOMMA f_kw
2205
- {
2206
- result = val[0] << val[2]
2207
- }
2208
-
2209
- kwrest_mark: tPOW | tDSTAR
2210
-
2211
- f_kwrest: kwrest_mark tIDENTIFIER
2212
- {
2213
- @static_env.declare val[1][0]
2214
-
2215
- result = [ @builder.kwrestarg(val[0], val[1]) ]
2216
- }
2217
- | kwrest_mark
2218
- {
2219
- result = [ @builder.kwrestarg(val[0]) ]
2220
- }
2221
-
2222
- f_opt: f_arg_asgn tEQL arg_value
2223
- {
2224
- result = @builder.optarg(val[0], val[1], val[2])
2225
- }
2226
-
2227
- f_block_opt: f_arg_asgn tEQL primary_value
2228
- {
2229
- result = @builder.optarg(val[0], val[1], val[2])
2230
- }
2231
-
2232
- f_block_optarg: f_block_opt
2233
- {
2234
- result = [ val[0] ]
2235
- }
2236
- | f_block_optarg tCOMMA f_block_opt
2237
- {
2238
- result = val[0] << val[2]
2239
- }
2240
-
2241
- f_optarg: f_opt
2242
- {
2243
- result = [ val[0] ]
2244
- }
2245
- | f_optarg tCOMMA f_opt
2246
- {
2247
- result = val[0] << val[2]
2248
- }
2249
-
2250
- restarg_mark: tSTAR2 | tSTAR
2251
-
2252
- f_rest_arg: restarg_mark tIDENTIFIER
2253
- {
2254
- @static_env.declare val[1][0]
2255
-
2256
- result = [ @builder.restarg(val[0], val[1]) ]
2257
- }
2258
- | restarg_mark
2259
- {
2260
- result = [ @builder.restarg(val[0]) ]
2261
- }
2262
-
2263
- blkarg_mark: tAMPER2 | tAMPER
2264
-
2265
- f_block_arg: blkarg_mark tIDENTIFIER
2266
- {
2267
- @static_env.declare val[1][0]
2268
-
2269
- result = @builder.blockarg(val[0], val[1])
2270
- }
2271
-
2272
- opt_f_block_arg: tCOMMA f_block_arg
2273
- {
2274
- result = [ val[1] ]
2275
- }
2276
- |
2277
- {
2278
- result = []
2279
- }
2280
-
2281
- singleton: var_ref
2282
- | tLPAREN2 expr rparen
2283
- {
2284
- result = val[1]
2285
- }
2286
-
2287
- assoc_list: # nothing
2288
- {
2289
- result = []
2290
- }
2291
- | assocs trailer
2292
-
2293
- assocs: assoc
2294
- {
2295
- result = [ val[0] ]
2296
- }
2297
- | assocs tCOMMA assoc
2298
- {
2299
- result = val[0] << val[2]
2300
- }
2301
-
2302
- assoc: arg_value tASSOC arg_value
2303
- {
2304
- result = @builder.pair(val[0], val[1], val[2])
2305
- }
2306
- | tLABEL arg_value
2307
- {
2308
- result = @builder.pair_keyword(val[0], val[1])
2309
- }
2310
- | tSTRING_BEG string_contents tLABEL_END arg_value
2311
- {
2312
- result = @builder.pair_quoted(val[0], val[1], val[2], val[3])
2313
- }
2314
- | tDSTAR arg_value
2315
- {
2316
- result = @builder.kwsplat(val[0], val[1])
2317
- }
2318
-
2319
- operation: tIDENTIFIER | tCONSTANT | tFID
2320
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
2321
- operation3: tIDENTIFIER | tFID | op
2322
- dot_or_colon: call_op | tCOLON2
2323
- call_op: tDOT
2324
- {
2325
- result = [:dot, val[0][1]]
2326
- }
2327
- | tANDDOT
2328
- {
2329
- result = [:anddot, val[0][1]]
2330
- }
2331
- opt_terms: | terms
2332
- opt_nl: | tNL
2333
- rparen: opt_nl tRPAREN
2334
- {
2335
- result = val[1]
2336
- }
2337
- rbracket: opt_nl tRBRACK
2338
- {
2339
- result = val[1]
2340
- }
2341
- trailer: | tNL | tCOMMA
2342
-
2343
- term: tSEMI
2344
- {
2345
- yyerrok
2346
- }
2347
- | tNL
2348
-
2349
- terms: term
2350
- | terms tSEMI
2351
-
2352
- none: # nothing
2353
- {
2354
- result = nil
2355
- }
2356
- end
2357
-
2358
- ---- header
2359
-
2360
- require 'parser'
2361
-
2362
- ---- inner
2363
-
2364
- def version
2365
- 23
2366
- end
2367
-
2368
- def default_encoding
2369
- Encoding::UTF_8
2370
- end