ruby_parser 3.4.1 → 3.5.0

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