parser 2.7.1.3 → 3.0.1.0

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