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