ruby_parser 3.12.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +47 -0
- data/Manifest.txt +5 -4
- data/Rakefile +41 -28
- data/compare/normalize.rb +29 -2
- data/debugging.md +18 -0
- data/lib/rp_extensions.rb +0 -7
- data/lib/ruby20_parser.rb +3689 -3502
- data/lib/ruby20_parser.y +284 -201
- data/lib/ruby21_parser.rb +3755 -3570
- data/lib/ruby21_parser.y +281 -197
- data/lib/ruby22_parser.rb +3780 -3600
- data/lib/ruby22_parser.y +281 -202
- data/lib/ruby23_parser.rb +3755 -3591
- data/lib/ruby23_parser.y +282 -203
- data/lib/ruby24_parser.rb +3755 -3591
- data/lib/ruby24_parser.y +282 -203
- data/lib/ruby25_parser.rb +3754 -3591
- data/lib/ruby25_parser.y +282 -203
- data/lib/ruby26_parser.rb +6999 -0
- data/lib/{ruby19_parser.y → ruby26_parser.y} +658 -305
- data/lib/ruby_lexer.rb +116 -118
- data/lib/ruby_lexer.rex +10 -8
- data/lib/ruby_lexer.rex.rb +8 -8
- data/lib/ruby_parser.rb +5 -7
- data/lib/ruby_parser.yy +308 -218
- data/lib/ruby_parser_extras.rb +88 -106
- data/test/test_ruby_lexer.rb +68 -121
- data/test/test_ruby_parser.rb +173 -277
- data/tools/munge.rb +216 -0
- data/tools/ripper.rb +23 -0
- metadata +18 -17
- metadata.gz.sig +1 -1
- data/lib/ruby18_parser.rb +0 -5793
- data/lib/ruby18_parser.y +0 -1908
- data/lib/ruby19_parser.rb +0 -6185
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- racc -*-
|
2
2
|
|
3
|
-
class
|
3
|
+
class Ruby26Parser
|
4
4
|
|
5
5
|
token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
6
6
|
kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
|
@@ -17,8 +17,11 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
17
17
|
tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
|
18
18
|
tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
|
19
19
|
tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
|
20
|
-
tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI
|
21
|
-
|
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
|
+
tLABEL_END
|
24
|
+
tLONELY
|
22
25
|
|
23
26
|
prechigh
|
24
27
|
right tBANG tTILDE tUPLUS
|
@@ -69,21 +72,51 @@ rule
|
|
69
72
|
| error top_stmt
|
70
73
|
|
71
74
|
top_stmt: stmt
|
75
|
+
{
|
76
|
+
result = val[0]
|
77
|
+
|
78
|
+
# TODO: remove once I have more confidence this is fixed
|
79
|
+
# result.each_of_type :call_args do |s|
|
80
|
+
# debug20 666, s, result
|
81
|
+
# end
|
82
|
+
}
|
72
83
|
| klBEGIN
|
73
84
|
{
|
74
85
|
if (self.in_def || self.in_single > 0) then
|
86
|
+
debug20 1
|
75
87
|
yyerror "BEGIN in method"
|
76
88
|
end
|
77
89
|
self.env.extend
|
78
90
|
}
|
79
|
-
|
91
|
+
begin_block
|
92
|
+
{
|
93
|
+
_, _, block = val
|
94
|
+
result = block
|
95
|
+
}
|
96
|
+
|
97
|
+
begin_block: tLCURLY top_compstmt tRCURLY
|
98
|
+
{
|
99
|
+
_, stmt, _ = val
|
100
|
+
result = new_iter s(:preexe), 0, stmt
|
101
|
+
}
|
102
|
+
|
103
|
+
bodystmt: compstmt opt_rescue k_else
|
80
104
|
{
|
81
|
-
|
105
|
+
res = _values[-2]
|
106
|
+
yyerror "else without rescue is useless" unless res
|
82
107
|
}
|
108
|
+
compstmt
|
109
|
+
opt_ensure
|
110
|
+
{
|
111
|
+
body, resc, _, _, els, ens = val
|
83
112
|
|
84
|
-
|
113
|
+
result = new_body [body, resc, els, ens]
|
114
|
+
}
|
115
|
+
| compstmt opt_rescue opt_ensure
|
85
116
|
{
|
86
|
-
|
117
|
+
body, resc, ens = val
|
118
|
+
|
119
|
+
result = new_body [body, resc, nil, ens]
|
87
120
|
}
|
88
121
|
|
89
122
|
compstmt: stmts opt_terms
|
@@ -92,14 +125,30 @@ rule
|
|
92
125
|
}
|
93
126
|
|
94
127
|
stmts: none
|
95
|
-
|
|
96
|
-
| stmts terms
|
128
|
+
| stmt_or_begin # TODO: newline_node ?
|
129
|
+
| stmts terms stmt_or_begin
|
97
130
|
{
|
98
131
|
result = self.block_append val[0], val[2]
|
99
132
|
}
|
100
133
|
| error stmt
|
101
134
|
{
|
102
135
|
result = val[1]
|
136
|
+
debug20 2, val, result
|
137
|
+
}
|
138
|
+
|
139
|
+
stmt_or_begin: stmt
|
140
|
+
| klBEGIN
|
141
|
+
{
|
142
|
+
if (self.in_def || self.in_single > 0) then
|
143
|
+
debug20 1
|
144
|
+
yyerror "BEGIN in method"
|
145
|
+
end
|
146
|
+
self.env.extend
|
147
|
+
}
|
148
|
+
begin_block
|
149
|
+
{
|
150
|
+
_, _, stmt = val
|
151
|
+
result = stmt
|
103
152
|
}
|
104
153
|
|
105
154
|
stmt: kALIAS fitem
|
@@ -145,11 +194,13 @@ rule
|
|
145
194
|
}
|
146
195
|
| stmt kRESCUE_MOD stmt
|
147
196
|
{
|
148
|
-
|
197
|
+
body, _, resbody = val
|
198
|
+
result = new_rescue body, new_resbody(s(:array), resbody)
|
149
199
|
}
|
150
200
|
| klEND tLCURLY compstmt tRCURLY
|
151
201
|
{
|
152
202
|
if (self.in_def || self.in_single > 0) then
|
203
|
+
debug20 3
|
153
204
|
yyerror "END in method; use at_exit"
|
154
205
|
end
|
155
206
|
result = new_iter s(:postexe), 0, val[2]
|
@@ -159,56 +210,75 @@ rule
|
|
159
210
|
{
|
160
211
|
result = new_masgn val[0], val[2], :wrap
|
161
212
|
}
|
162
|
-
|
|
213
|
+
| lhs tEQL mrhs
|
214
|
+
{
|
215
|
+
result = new_assign val[0], s(:svalue, val[2])
|
216
|
+
}
|
217
|
+
| mlhs tEQL mrhs_arg
|
218
|
+
{
|
219
|
+
result = new_masgn val[0], val[2]
|
220
|
+
}
|
221
|
+
| expr
|
222
|
+
|
223
|
+
command_asgn: lhs tEQL command_rhs
|
224
|
+
{
|
225
|
+
result = new_assign val[0], val[2]
|
226
|
+
}
|
227
|
+
# | lhs tEQL command_asgn
|
228
|
+
# {
|
229
|
+
# result = new_assign val[0], val[2]
|
230
|
+
# }
|
231
|
+
| var_lhs tOP_ASGN command_rhs
|
163
232
|
{
|
164
233
|
result = new_op_asgn val
|
165
234
|
}
|
166
|
-
| primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN
|
235
|
+
| primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_rhs
|
167
236
|
{
|
168
237
|
result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
|
169
238
|
}
|
170
|
-
| primary_value
|
239
|
+
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
|
171
240
|
{
|
172
241
|
result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
|
242
|
+
if val[1] == '&.'
|
243
|
+
result.sexp_type = :safe_op_asgn
|
244
|
+
end
|
245
|
+
result.line = val[0].line
|
173
246
|
}
|
174
|
-
| primary_value
|
247
|
+
| primary_value call_op tCONSTANT tOP_ASGN command_rhs
|
175
248
|
{
|
176
249
|
result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
|
250
|
+
if val[1] == '&.'
|
251
|
+
result.sexp_type = :safe_op_asgn
|
252
|
+
end
|
253
|
+
result.line = val[0].line
|
177
254
|
}
|
178
|
-
| primary_value tCOLON2 tCONSTANT tOP_ASGN
|
255
|
+
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
|
179
256
|
{
|
180
257
|
result = s(:op_asgn, val[0], val[4], val[2], val[3])
|
258
|
+
debug20 4, val, result
|
181
259
|
}
|
182
|
-
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN
|
260
|
+
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
|
183
261
|
{
|
184
262
|
result = s(:op_asgn, val[0], val[4], val[2], val[3])
|
263
|
+
debug20 5, val, result
|
185
264
|
}
|
186
|
-
| backref tOP_ASGN
|
265
|
+
| backref tOP_ASGN command_rhs
|
187
266
|
{
|
188
267
|
self.backref_assign_error val[0]
|
189
268
|
}
|
190
|
-
| lhs tEQL mrhs
|
191
|
-
{
|
192
|
-
result = new_assign val[0], s(:svalue, val[2])
|
193
|
-
}
|
194
|
-
| mlhs tEQL arg_value
|
195
|
-
{
|
196
|
-
result = new_masgn val[0], val[2], :wrap
|
197
|
-
}
|
198
|
-
| mlhs tEQL mrhs
|
199
|
-
{
|
200
|
-
result = new_masgn val[0], val[2]
|
201
|
-
}
|
202
|
-
| expr
|
203
269
|
|
204
|
-
|
270
|
+
command_rhs: command_call =tOP_ASGN
|
205
271
|
{
|
206
|
-
|
272
|
+
expr, = val
|
273
|
+
result = value_expr expr
|
207
274
|
}
|
208
|
-
|
|
275
|
+
| command_call kRESCUE_MOD stmt
|
209
276
|
{
|
210
|
-
|
277
|
+
expr, _, resbody = val
|
278
|
+
expr = value_expr expr
|
279
|
+
result = new_rescue(expr, new_resbody(s(:array), resbody))
|
211
280
|
}
|
281
|
+
| command_asgn
|
212
282
|
|
213
283
|
expr: command_call
|
214
284
|
| expr kAND expr
|
@@ -234,43 +304,54 @@ rule
|
|
234
304
|
result = value_expr(val[0])
|
235
305
|
}
|
236
306
|
|
307
|
+
expr_value_do: {
|
308
|
+
lexer.cond.push true
|
309
|
+
}
|
310
|
+
expr_value do
|
311
|
+
{
|
312
|
+
lexer.cond.pop
|
313
|
+
}
|
314
|
+
{
|
315
|
+
_, expr, _, _ = val
|
316
|
+
result = expr
|
317
|
+
}
|
318
|
+
|
237
319
|
command_call: command
|
238
320
|
| block_command
|
239
321
|
|
240
322
|
block_command: block_call
|
241
|
-
| block_call
|
242
|
-
{
|
243
|
-
result = new_call val[0], val[2].to_sym, val[3]
|
244
|
-
}
|
245
|
-
| block_call tCOLON2 operation2 command_args
|
323
|
+
| block_call call_op2 operation2 command_args
|
246
324
|
{
|
247
325
|
result = new_call val[0], val[2].to_sym, val[3]
|
248
326
|
}
|
249
327
|
|
250
328
|
cmd_brace_block: tLBRACE_ARG
|
251
329
|
{
|
252
|
-
self.env.extend(:dynamic)
|
330
|
+
# self.env.extend(:dynamic)
|
253
331
|
result = self.lexer.lineno
|
254
332
|
}
|
255
|
-
|
333
|
+
brace_body tRCURLY
|
256
334
|
{
|
257
|
-
|
335
|
+
_, line, body, _ = val
|
336
|
+
|
337
|
+
result = body
|
338
|
+
result.line = line
|
339
|
+
|
340
|
+
# self.env.unextend
|
258
341
|
}
|
259
|
-
compstmt tRCURLY
|
260
|
-
{
|
261
|
-
result = new_iter nil, val[2], val[4]
|
262
|
-
result.line = val[1]
|
263
342
|
|
264
|
-
|
343
|
+
fcall: operation
|
344
|
+
{
|
345
|
+
result = new_call nil, val[0].to_sym
|
265
346
|
}
|
266
347
|
|
267
|
-
command:
|
348
|
+
command: fcall command_args =tLOWEST
|
268
349
|
{
|
269
|
-
result =
|
350
|
+
result = val[0].concat val[1].sexp_body # REFACTOR pattern
|
270
351
|
}
|
271
|
-
|
|
352
|
+
| fcall command_args cmd_brace_block
|
272
353
|
{
|
273
|
-
result =
|
354
|
+
result = val[0].concat val[1].sexp_body
|
274
355
|
if val[2] then
|
275
356
|
block_dup_check result, val[2]
|
276
357
|
|
@@ -278,14 +359,14 @@ rule
|
|
278
359
|
result.insert 1, operation
|
279
360
|
end
|
280
361
|
}
|
281
|
-
| primary_value
|
362
|
+
| primary_value call_op operation2 command_args =tLOWEST
|
282
363
|
{
|
283
|
-
result = new_call val[0], val[2].to_sym, val[3]
|
364
|
+
result = new_call val[0], val[2].to_sym, val[3], val[1]
|
284
365
|
}
|
285
|
-
| primary_value
|
366
|
+
| primary_value call_op operation2 command_args cmd_brace_block
|
286
367
|
{
|
287
368
|
recv, _, msg, args, block = val
|
288
|
-
call = new_call recv, msg.to_sym, args
|
369
|
+
call = new_call recv, msg.to_sym, args, val[1]
|
289
370
|
|
290
371
|
block_dup_check call, block
|
291
372
|
|
@@ -314,7 +395,7 @@ rule
|
|
314
395
|
{
|
315
396
|
result = new_yield val[1]
|
316
397
|
}
|
317
|
-
|
|
398
|
+
| k_return call_args
|
318
399
|
{
|
319
400
|
line = val[0].last
|
320
401
|
result = s(:return, ret_args(val[1])).line(line)
|
@@ -356,9 +437,11 @@ rule
|
|
356
437
|
}
|
357
438
|
| mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
|
358
439
|
{
|
359
|
-
|
360
|
-
|
361
|
-
result = s(:
|
440
|
+
ary1, _, splat, _, ary2 = val
|
441
|
+
|
442
|
+
result = list_append ary1, s(:splat, splat)
|
443
|
+
result.concat ary2.sexp_body
|
444
|
+
result = s(:masgn, result)
|
362
445
|
}
|
363
446
|
| mlhs_head tSTAR
|
364
447
|
{
|
@@ -386,9 +469,7 @@ rule
|
|
386
469
|
}
|
387
470
|
| tSTAR tCOMMA mlhs_post
|
388
471
|
{
|
389
|
-
|
390
|
-
ary.concat val[2].sexp_body
|
391
|
-
result = s(:masgn, ary)
|
472
|
+
result = s(:masgn, s(:array, s(:splat), *val[2].sexp_body))
|
392
473
|
}
|
393
474
|
|
394
475
|
mlhs_item: mlhs_node
|
@@ -427,21 +508,22 @@ rule
|
|
427
508
|
{
|
428
509
|
result = self.aryset val[0], val[2]
|
429
510
|
}
|
430
|
-
| primary_value
|
511
|
+
| primary_value call_op tIDENTIFIER
|
431
512
|
{
|
432
|
-
result =
|
513
|
+
result = new_attrasgn val[0], val[2], val[1]
|
433
514
|
}
|
434
515
|
| primary_value tCOLON2 tIDENTIFIER
|
435
516
|
{
|
436
517
|
result = s(:attrasgn, val[0], :"#{val[2]}=")
|
437
518
|
}
|
438
|
-
| primary_value
|
519
|
+
| primary_value call_op tCONSTANT
|
439
520
|
{
|
440
|
-
result =
|
521
|
+
result = new_attrasgn val[0], val[2], val[1]
|
441
522
|
}
|
442
523
|
| primary_value tCOLON2 tCONSTANT
|
443
524
|
{
|
444
525
|
if (self.in_def || self.in_single > 0) then
|
526
|
+
debug20 7
|
445
527
|
yyerror "dynamic constant assignment"
|
446
528
|
end
|
447
529
|
|
@@ -450,6 +532,7 @@ rule
|
|
450
532
|
| tCOLON3 tCONSTANT
|
451
533
|
{
|
452
534
|
if (self.in_def || self.in_single > 0) then
|
535
|
+
debug20 8
|
453
536
|
yyerror "dynamic constant assignment"
|
454
537
|
end
|
455
538
|
|
@@ -467,26 +550,28 @@ rule
|
|
467
550
|
| keyword_variable
|
468
551
|
{
|
469
552
|
result = self.assignable val[0]
|
553
|
+
debug20 9, val, result
|
470
554
|
}
|
471
555
|
| primary_value tLBRACK2 opt_call_args rbracket
|
472
556
|
{
|
473
557
|
result = self.aryset val[0], val[2]
|
474
558
|
}
|
475
|
-
| primary_value
|
559
|
+
| primary_value call_op tIDENTIFIER # REFACTOR
|
476
560
|
{
|
477
|
-
result =
|
561
|
+
result = new_attrasgn val[0], val[2], val[1]
|
478
562
|
}
|
479
563
|
| primary_value tCOLON2 tIDENTIFIER
|
480
564
|
{
|
481
565
|
result = s(:attrasgn, val[0], :"#{val[2]}=")
|
482
566
|
}
|
483
|
-
| primary_value
|
567
|
+
| primary_value call_op tCONSTANT # REFACTOR?
|
484
568
|
{
|
485
|
-
result =
|
569
|
+
result = new_attrasgn val[0], val[2], val[1]
|
486
570
|
}
|
487
571
|
| primary_value tCOLON2 tCONSTANT
|
488
572
|
{
|
489
573
|
if (self.in_def || self.in_single > 0) then
|
574
|
+
debug20 10
|
490
575
|
yyerror "dynamic constant assignment"
|
491
576
|
end
|
492
577
|
|
@@ -495,6 +580,7 @@ rule
|
|
495
580
|
| tCOLON3 tCONSTANT
|
496
581
|
{
|
497
582
|
if (self.in_def || self.in_single > 0) then
|
583
|
+
debug20 11
|
498
584
|
yyerror "dynamic constant assignment"
|
499
585
|
end
|
500
586
|
|
@@ -533,13 +619,17 @@ rule
|
|
533
619
|
|
534
620
|
| reswords
|
535
621
|
{
|
622
|
+
(sym, _line), = val
|
536
623
|
lexer.lex_state = :expr_end
|
537
|
-
result =
|
624
|
+
result = sym
|
538
625
|
}
|
539
626
|
|
540
627
|
fsym: fname | symbol
|
541
628
|
|
542
|
-
fitem: fsym
|
629
|
+
fitem: fsym
|
630
|
+
{
|
631
|
+
result = s(:lit, val[0].to_sym)
|
632
|
+
}
|
543
633
|
| dsym
|
544
634
|
|
545
635
|
undef_list: fitem
|
@@ -556,11 +646,12 @@ rule
|
|
556
646
|
result = new_undef val[0], val[3]
|
557
647
|
}
|
558
648
|
|
559
|
-
op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ
|
560
|
-
| tMATCH | tNMATCH | tGT | tGEQ | tLT
|
561
|
-
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS
|
562
|
-
| tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
|
649
|
+
op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
|
650
|
+
| tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
|
651
|
+
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
652
|
+
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
563
653
|
| tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
|
654
|
+
| tUBANG
|
564
655
|
|
565
656
|
reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
|
566
657
|
| kALIAS | kAND | kBEGIN | kBREAK | kCASE
|
@@ -572,51 +663,46 @@ rule
|
|
572
663
|
| kWHEN | kYIELD | kIF | kUNLESS | kWHILE
|
573
664
|
| kUNTIL
|
574
665
|
|
575
|
-
arg: lhs tEQL
|
666
|
+
arg: lhs tEQL arg_rhs
|
576
667
|
{
|
577
668
|
result = new_assign val[0], val[2]
|
578
669
|
}
|
579
|
-
|
|
580
|
-
{
|
581
|
-
result = new_assign val[0], s(:rescue, val[2], new_resbody(s(:array), val[4]))
|
582
|
-
}
|
583
|
-
| var_lhs tOP_ASGN arg
|
584
|
-
{
|
585
|
-
result = new_op_asgn val
|
586
|
-
}
|
587
|
-
| var_lhs tOP_ASGN arg kRESCUE_MOD arg
|
670
|
+
| var_lhs tOP_ASGN arg_rhs
|
588
671
|
{
|
589
672
|
result = new_op_asgn val
|
590
|
-
result = s(:rescue, result, new_resbody(s(:array), val[4]))
|
591
673
|
}
|
592
|
-
| primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN
|
674
|
+
| primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg_rhs
|
593
675
|
{
|
594
676
|
val[2].sexp_type = :arglist if val[2]
|
595
677
|
result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
|
596
678
|
}
|
597
|
-
| primary_value
|
679
|
+
| primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
|
598
680
|
{
|
599
|
-
result =
|
681
|
+
result = new_op_asgn2 val
|
600
682
|
}
|
601
|
-
| primary_value
|
683
|
+
| primary_value call_op tCONSTANT tOP_ASGN arg_rhs
|
602
684
|
{
|
603
|
-
result =
|
685
|
+
result = new_op_asgn2 val
|
604
686
|
}
|
605
|
-
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN
|
687
|
+
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
|
606
688
|
{
|
607
689
|
result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
|
608
690
|
}
|
609
|
-
| primary_value tCOLON2 tCONSTANT tOP_ASGN
|
691
|
+
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
|
610
692
|
{
|
611
|
-
|
693
|
+
# TODO: assignment
|
694
|
+
raise "not yet: %p" % [val]
|
612
695
|
}
|
613
|
-
| tCOLON3 tCONSTANT tOP_ASGN
|
696
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
|
614
697
|
{
|
615
|
-
|
698
|
+
# TODO: assignment
|
699
|
+
raise "not yet: %p" % [val]
|
616
700
|
}
|
617
|
-
| backref tOP_ASGN
|
701
|
+
| backref tOP_ASGN arg_rhs
|
618
702
|
{
|
619
|
-
|
703
|
+
# TODO: lhs = var_field val[0]
|
704
|
+
asgn = new_op_asgn val
|
705
|
+
result = self.backref_assign_error asgn
|
620
706
|
}
|
621
707
|
| arg tDOT2 arg
|
622
708
|
{
|
@@ -636,6 +722,18 @@ rule
|
|
636
722
|
result = s(:dot3, v1, v2)
|
637
723
|
end
|
638
724
|
}
|
725
|
+
| arg tDOT2
|
726
|
+
{
|
727
|
+
v1, v2 = val[0], nil
|
728
|
+
|
729
|
+
result = s(:dot2, v1, v2)
|
730
|
+
}
|
731
|
+
| arg tDOT3
|
732
|
+
{
|
733
|
+
v1, v2 = val[0], nil
|
734
|
+
|
735
|
+
result = s(:dot3, v1, v2)
|
736
|
+
}
|
639
737
|
| arg tPLUS arg
|
640
738
|
{
|
641
739
|
result = new_call val[0], :+, argl(val[2])
|
@@ -644,7 +742,7 @@ rule
|
|
644
742
|
{
|
645
743
|
result = new_call val[0], :-, argl(val[2])
|
646
744
|
}
|
647
|
-
| arg tSTAR2 arg
|
745
|
+
| arg tSTAR2 arg # TODO: rename
|
648
746
|
{
|
649
747
|
result = new_call val[0], :*, argl(val[2])
|
650
748
|
}
|
@@ -660,11 +758,7 @@ rule
|
|
660
758
|
{
|
661
759
|
result = new_call val[0], :**, argl(val[2])
|
662
760
|
}
|
663
|
-
| tUMINUS_NUM
|
664
|
-
{
|
665
|
-
result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
|
666
|
-
}
|
667
|
-
| tUMINUS_NUM tFLOAT tPOW arg
|
761
|
+
| tUMINUS_NUM simple_numeric tPOW arg
|
668
762
|
{
|
669
763
|
result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
|
670
764
|
}
|
@@ -692,22 +786,7 @@ rule
|
|
692
786
|
{
|
693
787
|
result = new_call val[0], :"<=>", argl(val[2])
|
694
788
|
}
|
695
|
-
|
|
696
|
-
{
|
697
|
-
result = new_call val[0], :">", argl(val[2])
|
698
|
-
}
|
699
|
-
| arg tGEQ arg
|
700
|
-
{
|
701
|
-
result = new_call val[0], :">=", argl(val[2])
|
702
|
-
}
|
703
|
-
| arg tLT arg
|
704
|
-
{
|
705
|
-
result = new_call val[0], :"<", argl(val[2])
|
706
|
-
}
|
707
|
-
| arg tLEQ arg
|
708
|
-
{
|
709
|
-
result = new_call val[0], :"<=", argl(val[2])
|
710
|
-
}
|
789
|
+
| rel_expr =tCMP
|
711
790
|
| arg tEQ arg
|
712
791
|
{
|
713
792
|
result = new_call val[0], :"==", argl(val[2])
|
@@ -734,8 +813,7 @@ rule
|
|
734
813
|
}
|
735
814
|
| tTILDE arg
|
736
815
|
{
|
737
|
-
|
738
|
-
result = new_call val[1], :"~"
|
816
|
+
result = new_call value_expr(val[1]), :"~"
|
739
817
|
}
|
740
818
|
| arg tLSHFT arg
|
741
819
|
{
|
@@ -767,6 +845,23 @@ rule
|
|
767
845
|
}
|
768
846
|
| primary
|
769
847
|
|
848
|
+
relop: tGT
|
849
|
+
| tLT
|
850
|
+
| tGEQ
|
851
|
+
| tLEQ
|
852
|
+
|
853
|
+
rel_expr: arg relop arg =tGT
|
854
|
+
{
|
855
|
+
lhs, op, rhs = val
|
856
|
+
result = new_call lhs, op.to_sym, argl(rhs)
|
857
|
+
}
|
858
|
+
| rel_expr relop arg =tGT
|
859
|
+
{
|
860
|
+
lhs, op, rhs = val
|
861
|
+
warn "comparison '%s' after comparison", op
|
862
|
+
result = new_call lhs, op.to_sym, argl(rhs)
|
863
|
+
}
|
864
|
+
|
770
865
|
arg_value: arg
|
771
866
|
{
|
772
867
|
result = value_expr(val[0])
|
@@ -775,15 +870,24 @@ rule
|
|
775
870
|
aref_args: none
|
776
871
|
| args trailer
|
777
872
|
{
|
778
|
-
result = val[0]
|
873
|
+
result = args [val[0]]
|
779
874
|
}
|
780
875
|
| args tCOMMA assocs trailer
|
781
876
|
{
|
782
|
-
result = val[0]
|
877
|
+
result = args [val[0], array_to_hash(val[2])]
|
783
878
|
}
|
784
879
|
| assocs trailer
|
785
880
|
{
|
786
|
-
result =
|
881
|
+
result = args [array_to_hash(val[0])]
|
882
|
+
}
|
883
|
+
|
884
|
+
arg_rhs: arg =tOP_ASGN
|
885
|
+
| arg kRESCUE_MOD arg
|
886
|
+
{
|
887
|
+
body, _, resbody = val
|
888
|
+
body = value_expr body
|
889
|
+
resbody = remove_begin resbody
|
890
|
+
result = new_rescue(body, new_resbody(s(:array), resbody))
|
787
891
|
}
|
788
892
|
|
789
893
|
paren_args: tLPAREN2 opt_call_args rparen
|
@@ -804,45 +908,48 @@ rule
|
|
804
908
|
}
|
805
909
|
| args tCOMMA
|
806
910
|
{
|
807
|
-
result = val
|
911
|
+
result = args val
|
808
912
|
}
|
809
913
|
| args tCOMMA assocs tCOMMA
|
810
914
|
{
|
811
|
-
result = val[0]
|
915
|
+
result = args [val[0], array_to_hash(val[2])]
|
812
916
|
}
|
813
917
|
| assocs tCOMMA
|
814
918
|
{
|
815
|
-
result =
|
919
|
+
result = args [array_to_hash(val[0])]
|
816
920
|
}
|
817
921
|
|
818
922
|
call_args: command
|
819
923
|
{
|
820
924
|
warning "parenthesize argument(s) for future version"
|
821
|
-
result =
|
925
|
+
result = call_args val
|
822
926
|
}
|
823
927
|
| args opt_block_arg
|
824
928
|
{
|
929
|
+
result = call_args val
|
825
930
|
result = self.arg_blk_pass val[0], val[1]
|
826
931
|
}
|
827
932
|
| assocs opt_block_arg
|
828
933
|
{
|
829
|
-
result =
|
934
|
+
result = call_args [array_to_hash(val[0])]
|
830
935
|
result = self.arg_blk_pass result, val[1]
|
831
936
|
}
|
832
937
|
| args tCOMMA assocs opt_block_arg
|
833
938
|
{
|
834
|
-
result = val[0]
|
939
|
+
result = call_args [val[0], array_to_hash(val[2])]
|
835
940
|
result = self.arg_blk_pass result, val[3]
|
836
941
|
}
|
837
942
|
| block_arg
|
943
|
+
{
|
944
|
+
result = call_args val
|
945
|
+
}
|
838
946
|
|
839
947
|
command_args: {
|
840
|
-
result = lexer.cmdarg.
|
841
|
-
lexer.cmdarg.push true
|
948
|
+
result = lexer.cmdarg.store true
|
842
949
|
}
|
843
950
|
call_args
|
844
951
|
{
|
845
|
-
lexer.cmdarg.
|
952
|
+
lexer.cmdarg.restore val[0]
|
846
953
|
result = val[1]
|
847
954
|
}
|
848
955
|
|
@@ -874,6 +981,15 @@ rule
|
|
874
981
|
result = self.list_append val[0], s(:splat, val[3])
|
875
982
|
}
|
876
983
|
|
984
|
+
mrhs_arg: mrhs
|
985
|
+
{
|
986
|
+
result = new_masgn_arg val[0]
|
987
|
+
}
|
988
|
+
| arg_value
|
989
|
+
{
|
990
|
+
result = new_masgn_arg val[0], :wrap
|
991
|
+
}
|
992
|
+
|
877
993
|
mrhs: args tCOMMA arg_value
|
878
994
|
{
|
879
995
|
result = val[0] << val[2]
|
@@ -893,18 +1009,24 @@ rule
|
|
893
1009
|
| regexp
|
894
1010
|
| words
|
895
1011
|
| qwords
|
1012
|
+
| symbols
|
1013
|
+
| qsymbols
|
896
1014
|
| var_ref
|
897
1015
|
| backref
|
898
1016
|
| tFID
|
899
1017
|
{
|
900
1018
|
result = new_call nil, val[0].to_sym
|
901
1019
|
}
|
902
|
-
|
|
1020
|
+
| k_begin
|
903
1021
|
{
|
904
1022
|
result = self.lexer.lineno
|
1023
|
+
# TODO:
|
1024
|
+
# $<val>1 = cmdarg_stack;
|
1025
|
+
# CMDARG_SET(0);
|
905
1026
|
}
|
906
|
-
bodystmt
|
1027
|
+
bodystmt k_end
|
907
1028
|
{
|
1029
|
+
# TODO: CMDARG_SET($<val>1);
|
908
1030
|
unless val[2] then
|
909
1031
|
result = s(:nil)
|
910
1032
|
else
|
@@ -913,14 +1035,27 @@ rule
|
|
913
1035
|
|
914
1036
|
result.line = val[1]
|
915
1037
|
}
|
916
|
-
| tLPAREN_ARG
|
1038
|
+
| tLPAREN_ARG rparen
|
1039
|
+
{
|
1040
|
+
# TODO: lex_state = :expr_endarg in between
|
1041
|
+
debug20 13, val, result
|
1042
|
+
}
|
1043
|
+
| tLPAREN_ARG
|
1044
|
+
{
|
1045
|
+
result = lexer.cmdarg.store false
|
1046
|
+
# result = self.lexer.cmdarg.stack.dup
|
1047
|
+
# lexer.cmdarg.stack.replace [false] # TODO add api for these
|
1048
|
+
}
|
1049
|
+
stmt
|
917
1050
|
{
|
918
1051
|
lexer.lex_state = :expr_endarg
|
919
1052
|
}
|
920
1053
|
rparen
|
921
1054
|
{
|
1055
|
+
_, cmdarg, stmt, _, _, = val
|
922
1056
|
warning "(...) interpreted as grouped expression"
|
923
|
-
|
1057
|
+
lexer.cmdarg.restore cmdarg
|
1058
|
+
result = stmt
|
924
1059
|
}
|
925
1060
|
| tLPAREN compstmt tRPAREN
|
926
1061
|
{
|
@@ -938,6 +1073,7 @@ rule
|
|
938
1073
|
| tLBRACK aref_args tRBRACK
|
939
1074
|
{
|
940
1075
|
result = val[1] || s(:array)
|
1076
|
+
result.sexp_type = :array # aref_args is :args
|
941
1077
|
}
|
942
1078
|
| tLBRACE
|
943
1079
|
{
|
@@ -947,7 +1083,7 @@ rule
|
|
947
1083
|
{
|
948
1084
|
result = new_hash val
|
949
1085
|
}
|
950
|
-
|
|
1086
|
+
| k_return
|
951
1087
|
{
|
952
1088
|
result = s(:return)
|
953
1089
|
}
|
@@ -973,12 +1109,12 @@ rule
|
|
973
1109
|
}
|
974
1110
|
| kNOT tLPAREN2 rparen
|
975
1111
|
{
|
976
|
-
|
1112
|
+
debug20 14, val, result
|
977
1113
|
}
|
978
|
-
|
|
1114
|
+
| fcall brace_block
|
979
1115
|
{
|
980
1116
|
oper, iter = val[0], val[1]
|
981
|
-
call =
|
1117
|
+
call = oper # FIX
|
982
1118
|
iter.insert 1, call
|
983
1119
|
result = iter
|
984
1120
|
call.line = iter.line
|
@@ -995,61 +1131,42 @@ rule
|
|
995
1131
|
{
|
996
1132
|
result = val[1] # TODO: fix lineno
|
997
1133
|
}
|
998
|
-
|
|
999
|
-
{
|
1000
|
-
result = new_if val[1], val[3], val[4]
|
1001
|
-
}
|
1002
|
-
| kUNLESS expr_value then compstmt opt_else kEND
|
1134
|
+
| k_if expr_value then compstmt if_tail k_end
|
1003
1135
|
{
|
1004
|
-
|
1136
|
+
_, c, _, t, f, _ = val
|
1137
|
+
result = new_if c, t, f
|
1005
1138
|
}
|
1006
|
-
|
|
1007
|
-
{
|
1008
|
-
lexer.cond.push true
|
1009
|
-
}
|
1010
|
-
expr_value do
|
1011
|
-
{
|
1012
|
-
lexer.cond.pop
|
1013
|
-
}
|
1014
|
-
compstmt kEND
|
1015
|
-
{
|
1016
|
-
result = new_while val[5], val[2], true
|
1017
|
-
}
|
1018
|
-
| kUNTIL
|
1139
|
+
| k_unless expr_value then compstmt opt_else k_end
|
1019
1140
|
{
|
1020
|
-
|
1141
|
+
_, c, _, t, f, _ = val
|
1142
|
+
result = new_if c, f, t
|
1021
1143
|
}
|
1022
|
-
|
1144
|
+
| k_while expr_value_do compstmt k_end
|
1023
1145
|
{
|
1024
|
-
|
1146
|
+
_, cond, body, _ = val
|
1147
|
+
result = new_while body, cond, true
|
1025
1148
|
}
|
1026
|
-
|
1149
|
+
| k_until expr_value_do compstmt k_end
|
1027
1150
|
{
|
1028
|
-
|
1151
|
+
_, cond, body, _ = val
|
1152
|
+
result = new_until body, cond, true
|
1029
1153
|
}
|
1030
|
-
|
|
1154
|
+
| k_case expr_value opt_terms case_body k_end
|
1031
1155
|
{
|
1032
1156
|
(_, line), expr, _, body, _ = val
|
1033
1157
|
result = new_case expr, body, line
|
1034
1158
|
}
|
1035
|
-
|
|
1159
|
+
| k_case opt_terms case_body k_end
|
1036
1160
|
{
|
1037
1161
|
(_, line), _, body, _ = val
|
1038
1162
|
result = new_case nil, body, line
|
1039
1163
|
}
|
1040
|
-
|
|
1164
|
+
| k_for for_var kIN expr_value_do compstmt k_end
|
1041
1165
|
{
|
1042
|
-
|
1166
|
+
_, var, _, iter, body, _ = val
|
1167
|
+
result = new_for iter, var, body
|
1043
1168
|
}
|
1044
|
-
|
1045
|
-
{
|
1046
|
-
lexer.cond.pop
|
1047
|
-
}
|
1048
|
-
compstmt kEND
|
1049
|
-
{
|
1050
|
-
result = new_for val[4], val[1], val[7]
|
1051
|
-
}
|
1052
|
-
| kCLASS
|
1169
|
+
| k_class
|
1053
1170
|
{
|
1054
1171
|
result = self.lexer.lineno
|
1055
1172
|
}
|
@@ -1061,13 +1178,13 @@ rule
|
|
1061
1178
|
end
|
1062
1179
|
self.env.extend
|
1063
1180
|
}
|
1064
|
-
bodystmt
|
1181
|
+
bodystmt k_end
|
1065
1182
|
{
|
1066
1183
|
result = new_class val
|
1067
1184
|
self.env.unextend
|
1068
1185
|
self.lexer.comments # we don't care about comments in the body
|
1069
1186
|
}
|
1070
|
-
|
|
1187
|
+
| k_class tLSHFT
|
1071
1188
|
{
|
1072
1189
|
result = self.lexer.lineno
|
1073
1190
|
}
|
@@ -1082,13 +1199,13 @@ rule
|
|
1082
1199
|
self.in_single = 0
|
1083
1200
|
self.env.extend
|
1084
1201
|
}
|
1085
|
-
bodystmt
|
1202
|
+
bodystmt k_end
|
1086
1203
|
{
|
1087
1204
|
result = new_sclass val
|
1088
1205
|
self.env.unextend
|
1089
1206
|
self.lexer.comments # we don't care about comments in the body
|
1090
1207
|
}
|
1091
|
-
|
|
1208
|
+
| k_module
|
1092
1209
|
{
|
1093
1210
|
result = self.lexer.lineno
|
1094
1211
|
}
|
@@ -1100,22 +1217,24 @@ rule
|
|
1100
1217
|
|
1101
1218
|
self.env.extend
|
1102
1219
|
}
|
1103
|
-
bodystmt
|
1220
|
+
bodystmt k_end
|
1104
1221
|
{
|
1105
1222
|
result = new_module val
|
1106
1223
|
self.env.unextend
|
1107
1224
|
self.lexer.comments # we don't care about comments in the body
|
1108
1225
|
}
|
1109
|
-
|
|
1226
|
+
| k_def fname
|
1110
1227
|
{
|
1111
1228
|
result = [self.in_def, self.lexer.cmdarg.stack.dup]
|
1112
1229
|
|
1113
1230
|
self.comments.push self.lexer.comments
|
1114
1231
|
self.in_def = true
|
1115
1232
|
self.env.extend
|
1233
|
+
# TODO: local->cmdargs = cmdarg_stack;
|
1234
|
+
# TODO: port local_push_gen and local_pop_gen
|
1116
1235
|
lexer.cmdarg.stack.replace [false]
|
1117
1236
|
}
|
1118
|
-
f_arglist bodystmt
|
1237
|
+
f_arglist bodystmt k_end
|
1119
1238
|
{
|
1120
1239
|
in_def, cmdarg = val[2]
|
1121
1240
|
|
@@ -1126,7 +1245,7 @@ rule
|
|
1126
1245
|
self.in_def = in_def
|
1127
1246
|
self.lexer.comments # we don't care about comments in the body
|
1128
1247
|
}
|
1129
|
-
|
|
1248
|
+
| k_def singleton dot_or_colon
|
1130
1249
|
{
|
1131
1250
|
self.comments.push self.lexer.comments
|
1132
1251
|
lexer.lex_state = :expr_fname
|
@@ -1135,17 +1254,18 @@ rule
|
|
1135
1254
|
{
|
1136
1255
|
self.in_single += 1
|
1137
1256
|
self.env.extend
|
1138
|
-
lexer.lex_state = :
|
1257
|
+
lexer.lex_state = :expr_endfn # force for args
|
1139
1258
|
result = [lexer.lineno, self.lexer.cmdarg.stack.dup]
|
1140
1259
|
lexer.cmdarg.stack.replace [false]
|
1141
1260
|
}
|
1142
|
-
f_arglist bodystmt
|
1261
|
+
f_arglist bodystmt k_end
|
1143
1262
|
{
|
1144
1263
|
line, cmdarg = val[5]
|
1145
1264
|
result = new_defs val
|
1146
1265
|
result[3].line line
|
1147
1266
|
|
1148
1267
|
lexer.cmdarg.stack.replace cmdarg
|
1268
|
+
|
1149
1269
|
self.env.unextend
|
1150
1270
|
self.in_single -= 1
|
1151
1271
|
self.lexer.comments # we don't care about comments in the body
|
@@ -1183,7 +1303,15 @@ rule
|
|
1183
1303
|
k_class: kCLASS
|
1184
1304
|
k_module: kMODULE
|
1185
1305
|
k_def: kDEF
|
1306
|
+
k_do: kDO
|
1307
|
+
k_do_block: kDO_BLOCK
|
1308
|
+
k_rescue: kRESCUE
|
1309
|
+
k_ensure: kENSURE
|
1310
|
+
k_when: kWHEN
|
1311
|
+
k_else: kELSE
|
1312
|
+
k_elsif: kELSIF
|
1186
1313
|
k_end: kEND
|
1314
|
+
k_return: kRETURN
|
1187
1315
|
|
1188
1316
|
then: term
|
1189
1317
|
| kTHEN
|
@@ -1193,7 +1321,7 @@ rule
|
|
1193
1321
|
| kDO_COND
|
1194
1322
|
|
1195
1323
|
if_tail: opt_else
|
1196
|
-
|
|
1324
|
+
| k_elsif expr_value then compstmt if_tail
|
1197
1325
|
{
|
1198
1326
|
result = s(:if, val[1], val[3], val[4])
|
1199
1327
|
}
|
@@ -1278,23 +1406,46 @@ rule
|
|
1278
1406
|
result = block_var :*, args
|
1279
1407
|
}
|
1280
1408
|
|
1281
|
-
|
1409
|
+
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
1410
|
+
{
|
1411
|
+
result = call_args val
|
1412
|
+
}
|
1413
|
+
| f_block_kwarg opt_f_block_arg
|
1414
|
+
{
|
1415
|
+
result = call_args val
|
1416
|
+
}
|
1417
|
+
| f_kwrest opt_f_block_arg
|
1418
|
+
{
|
1419
|
+
result = call_args val
|
1420
|
+
}
|
1421
|
+
| f_block_arg
|
1422
|
+
{
|
1423
|
+
result = call_args val
|
1424
|
+
}
|
1425
|
+
|
1426
|
+
opt_block_args_tail: tCOMMA block_args_tail
|
1282
1427
|
{
|
1283
1428
|
result = args val
|
1284
1429
|
}
|
1285
|
-
|
|
1430
|
+
| none
|
1431
|
+
|
1432
|
+
block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
|
1433
|
+
{
|
1434
|
+
result = args val
|
1435
|
+
}
|
1436
|
+
| f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1286
1437
|
{
|
1287
1438
|
result = args val
|
1288
1439
|
}
|
1289
|
-
| f_arg tCOMMA f_block_optarg
|
1440
|
+
| f_arg tCOMMA f_block_optarg opt_block_args_tail
|
1290
1441
|
{
|
1291
1442
|
result = args val
|
1292
1443
|
}
|
1293
|
-
| f_arg tCOMMA f_block_optarg tCOMMA f_arg
|
1444
|
+
| f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
|
1294
1445
|
{
|
1295
1446
|
result = args val
|
1296
1447
|
}
|
1297
|
-
| f_arg tCOMMA f_rest_arg
|
1448
|
+
| f_arg tCOMMA f_rest_arg opt_block_args_tail
|
1298
1449
|
{
|
1299
1450
|
result = args val
|
1300
1451
|
}
|
@@ -1302,64 +1453,68 @@ rule
|
|
1302
1453
|
{
|
1303
1454
|
result = args val
|
1304
1455
|
}
|
1305
|
-
| f_arg tCOMMA f_rest_arg tCOMMA f_arg
|
1456
|
+
| f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1306
1457
|
{
|
1307
1458
|
result = args val
|
1308
1459
|
}
|
1309
|
-
| f_arg
|
1460
|
+
| f_arg opt_block_args_tail
|
1310
1461
|
{
|
1311
1462
|
result = args val
|
1312
1463
|
}
|
1313
|
-
| f_block_optarg tCOMMA f_rest_arg
|
1464
|
+
| f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
|
1314
1465
|
{
|
1315
1466
|
result = args val
|
1316
1467
|
}
|
1317
|
-
| f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg
|
1468
|
+
| f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1318
1469
|
{
|
1319
1470
|
result = args val
|
1320
1471
|
}
|
1321
|
-
| f_block_optarg
|
1472
|
+
| f_block_optarg opt_block_args_tail
|
1322
1473
|
{
|
1323
1474
|
result = args val
|
1324
1475
|
}
|
1325
|
-
| f_block_optarg tCOMMA f_arg
|
1476
|
+
| f_block_optarg tCOMMA f_arg opt_block_args_tail
|
1326
1477
|
{
|
1327
1478
|
result = args val
|
1328
1479
|
}
|
1329
|
-
| f_rest_arg
|
1480
|
+
| f_rest_arg opt_block_args_tail
|
1330
1481
|
{
|
1331
1482
|
result = args val
|
1332
1483
|
}
|
1333
|
-
| f_rest_arg tCOMMA f_arg
|
1484
|
+
| f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1334
1485
|
{
|
1335
1486
|
result = args val
|
1336
1487
|
}
|
1337
|
-
|
|
1488
|
+
| block_args_tail
|
1338
1489
|
{
|
1339
1490
|
result = args val
|
1340
1491
|
}
|
1341
1492
|
|
1342
1493
|
opt_block_param: none { result = 0 }
|
1343
1494
|
| block_param_def
|
1495
|
+
{
|
1496
|
+
self.lexer.command_start = true
|
1497
|
+
}
|
1344
1498
|
|
1345
1499
|
block_param_def: tPIPE opt_bv_decl tPIPE
|
1346
1500
|
{
|
1501
|
+
# TODO: current_arg = 0
|
1347
1502
|
result = args val
|
1348
1503
|
}
|
1349
1504
|
| tOROP
|
1350
1505
|
{
|
1351
1506
|
result = s(:args)
|
1352
|
-
self.lexer.command_start = true
|
1353
1507
|
}
|
1354
1508
|
| tPIPE block_param opt_bv_decl tPIPE
|
1355
1509
|
{
|
1510
|
+
# TODO: current_arg = 0
|
1356
1511
|
result = args val
|
1357
1512
|
}
|
1358
1513
|
|
1359
|
-
opt_bv_decl:
|
1360
|
-
| tSEMI bv_decls
|
1514
|
+
opt_bv_decl: opt_nl
|
1515
|
+
| opt_nl tSEMI bv_decls opt_nl
|
1361
1516
|
{
|
1362
|
-
result = val
|
1517
|
+
result = args val
|
1363
1518
|
}
|
1364
1519
|
|
1365
1520
|
bv_decls: bvar
|
@@ -1378,18 +1533,29 @@ rule
|
|
1378
1533
|
| f_bad_arg
|
1379
1534
|
|
1380
1535
|
lambda: {
|
1381
|
-
|
1536
|
+
self.env.extend :dynamic
|
1537
|
+
result = self.lexer.lineno
|
1538
|
+
|
1382
1539
|
result = lexer.lpar_beg
|
1383
1540
|
lexer.paren_nest += 1
|
1384
1541
|
lexer.lpar_beg = lexer.paren_nest
|
1385
1542
|
}
|
1386
|
-
f_larglist
|
1543
|
+
f_larglist
|
1544
|
+
{
|
1545
|
+
result = [lexer.cmdarg.store(false), self.lexer.lineno]
|
1546
|
+
}
|
1547
|
+
lambda_body
|
1387
1548
|
{
|
1388
|
-
lpar, args, body = val
|
1549
|
+
lpar, args, (cmdarg, lineno), body = val
|
1389
1550
|
lexer.lpar_beg = lpar
|
1390
1551
|
|
1552
|
+
lexer.cmdarg.restore cmdarg
|
1553
|
+
lexer.cmdarg.lexpop
|
1554
|
+
|
1391
1555
|
call = new_call nil, :lambda
|
1392
1556
|
result = new_iter call, args, body
|
1557
|
+
result.line = lineno
|
1558
|
+
self.env.unextend
|
1393
1559
|
}
|
1394
1560
|
|
1395
1561
|
f_larglist: tLPAREN2 f_args opt_bv_decl rparen
|
@@ -1406,35 +1572,22 @@ rule
|
|
1406
1572
|
{
|
1407
1573
|
result = val[1]
|
1408
1574
|
}
|
1409
|
-
| kDO_LAMBDA
|
1575
|
+
| kDO_LAMBDA bodystmt kEND
|
1410
1576
|
{
|
1411
1577
|
result = val[1]
|
1412
1578
|
}
|
1413
1579
|
|
1414
|
-
do_block:
|
1415
|
-
{
|
1416
|
-
self.env.extend :dynamic
|
1417
|
-
result = self.lexer.lineno
|
1418
|
-
}
|
1419
|
-
opt_block_param
|
1580
|
+
do_block: k_do_block do_body kEND
|
1420
1581
|
{
|
1421
|
-
|
1422
|
-
|
1423
|
-
compstmt kEND
|
1424
|
-
{
|
1425
|
-
args = val[2]
|
1426
|
-
body = val[4]
|
1427
|
-
result = new_iter nil, args, body
|
1428
|
-
result.line = val[1]
|
1429
|
-
|
1430
|
-
self.env.unextend
|
1582
|
+
# TODO: maybe fix lineno to kDO's lineno?
|
1583
|
+
result = val[1]
|
1431
1584
|
}
|
1432
1585
|
|
1433
1586
|
block_call: command do_block
|
1434
1587
|
{
|
1435
1588
|
# TODO:
|
1436
|
-
|
1437
|
-
|
1589
|
+
## if (nd_type($1) == NODE_YIELD) {
|
1590
|
+
## compile_error(PARSER_ARG "block given to yield");
|
1438
1591
|
|
1439
1592
|
syntax_error "Both block arg and actual block given." if
|
1440
1593
|
val[0].block_pass?
|
@@ -1444,26 +1597,41 @@ rule
|
|
1444
1597
|
result = val[1]
|
1445
1598
|
result.insert 1, val[0]
|
1446
1599
|
}
|
1447
|
-
| block_call
|
1600
|
+
| block_call call_op2 operation2 opt_paren_args
|
1448
1601
|
{
|
1449
1602
|
result = new_call val[0], val[2].to_sym, val[3]
|
1450
1603
|
}
|
1451
|
-
| block_call
|
1604
|
+
| block_call call_op2 operation2 opt_paren_args brace_block
|
1452
1605
|
{
|
1453
|
-
|
1606
|
+
iter1, _, name, args, iter2 = val
|
1607
|
+
|
1608
|
+
call = new_call iter1, name.to_sym, args
|
1609
|
+
iter2.insert 1, call
|
1610
|
+
|
1611
|
+
result = iter2
|
1612
|
+
}
|
1613
|
+
| block_call call_op2 operation2 command_args do_block
|
1614
|
+
{
|
1615
|
+
iter1, _, name, args, iter2 = val
|
1616
|
+
|
1617
|
+
call = new_call iter1, name.to_sym, args
|
1618
|
+
iter2.insert 1, call
|
1619
|
+
|
1620
|
+
result = iter2
|
1454
1621
|
}
|
1455
1622
|
|
1456
|
-
method_call:
|
1623
|
+
method_call: fcall
|
1457
1624
|
{
|
1458
1625
|
result = self.lexer.lineno
|
1459
1626
|
}
|
1460
1627
|
paren_args
|
1461
1628
|
{
|
1462
|
-
|
1629
|
+
args = self.call_args val[2..-1]
|
1630
|
+
result = val[0].concat args.sexp_body
|
1463
1631
|
}
|
1464
|
-
| primary_value
|
1632
|
+
| primary_value call_op operation2 opt_paren_args
|
1465
1633
|
{
|
1466
|
-
result = new_call val[0], val[2].to_sym, val[3]
|
1634
|
+
result = new_call val[0], val[2].to_sym, val[3], val[1]
|
1467
1635
|
}
|
1468
1636
|
| primary_value tCOLON2 operation2 paren_args
|
1469
1637
|
{
|
@@ -1473,9 +1641,9 @@ rule
|
|
1473
1641
|
{
|
1474
1642
|
result = new_call val[0], val[2].to_sym
|
1475
1643
|
}
|
1476
|
-
| primary_value
|
1644
|
+
| primary_value call_op paren_args
|
1477
1645
|
{
|
1478
|
-
result = new_call val[0], :call, val[2]
|
1646
|
+
result = new_call val[0], :call, val[2], val[1]
|
1479
1647
|
}
|
1480
1648
|
| primary_value tCOLON2 paren_args
|
1481
1649
|
{
|
@@ -1499,39 +1667,55 @@ rule
|
|
1499
1667
|
self.env.extend :dynamic
|
1500
1668
|
result = self.lexer.lineno
|
1501
1669
|
}
|
1502
|
-
|
1503
|
-
{
|
1504
|
-
result = nil # self.env.dynamic.keys
|
1505
|
-
}
|
1506
|
-
compstmt tRCURLY
|
1670
|
+
brace_body tRCURLY
|
1507
1671
|
{
|
1508
|
-
_, line,
|
1672
|
+
_, line, body, _ = val
|
1509
1673
|
|
1510
|
-
result =
|
1674
|
+
result = body
|
1511
1675
|
result.line = line
|
1512
1676
|
|
1513
1677
|
self.env.unextend
|
1514
1678
|
}
|
1515
|
-
|
|
1679
|
+
| k_do
|
1516
1680
|
{
|
1517
1681
|
self.env.extend :dynamic
|
1518
1682
|
result = self.lexer.lineno
|
1519
1683
|
}
|
1520
|
-
|
1684
|
+
do_body kEND
|
1521
1685
|
{
|
1522
|
-
|
1686
|
+
_, line, body, _ = val
|
1687
|
+
|
1688
|
+
result = body
|
1689
|
+
result.line = line
|
1690
|
+
|
1691
|
+
self.env.unextend
|
1523
1692
|
}
|
1524
|
-
|
1693
|
+
|
1694
|
+
brace_body: { self.env.extend :dynamic; result = self.lexer.lineno }
|
1695
|
+
{ result = lexer.cmdarg.store(false) }
|
1696
|
+
opt_block_param compstmt
|
1525
1697
|
{
|
1526
|
-
|
1698
|
+
line, cmdarg, param, cmpstmt = val
|
1527
1699
|
|
1528
|
-
result =
|
1529
|
-
|
1700
|
+
result = new_brace_body param, cmpstmt, line
|
1701
|
+
self.env.unextend
|
1702
|
+
lexer.cmdarg.restore cmdarg
|
1703
|
+
lexer.cmdarg.pop # because of: cmdarg_stack >> 1 ?
|
1704
|
+
}
|
1705
|
+
|
1706
|
+
do_body: { self.env.extend :dynamic; result = self.lexer.lineno }
|
1707
|
+
{ result = lexer.cmdarg.store(false) }
|
1708
|
+
opt_block_param
|
1709
|
+
bodystmt
|
1710
|
+
{
|
1711
|
+
line, cmdarg, param, cmpstmt = val
|
1530
1712
|
|
1713
|
+
result = new_do_body param, cmpstmt, line
|
1531
1714
|
self.env.unextend
|
1715
|
+
lexer.cmdarg.restore cmdarg
|
1532
1716
|
}
|
1533
1717
|
|
1534
|
-
case_body:
|
1718
|
+
case_body: k_when
|
1535
1719
|
{
|
1536
1720
|
result = self.lexer.lineno
|
1537
1721
|
}
|
@@ -1544,7 +1728,7 @@ rule
|
|
1544
1728
|
|
1545
1729
|
cases: opt_else | case_body
|
1546
1730
|
|
1547
|
-
opt_rescue:
|
1731
|
+
opt_rescue: k_rescue exc_list exc_var then compstmt opt_rescue
|
1548
1732
|
{
|
1549
1733
|
(_, line), klasses, var, _, body, rest = val
|
1550
1734
|
|
@@ -1573,7 +1757,7 @@ rule
|
|
1573
1757
|
}
|
1574
1758
|
| none
|
1575
1759
|
|
1576
|
-
opt_ensure:
|
1760
|
+
opt_ensure: k_ensure compstmt
|
1577
1761
|
{
|
1578
1762
|
_, body = val
|
1579
1763
|
|
@@ -1581,8 +1765,14 @@ rule
|
|
1581
1765
|
}
|
1582
1766
|
| none
|
1583
1767
|
|
1584
|
-
literal: numeric
|
1585
|
-
|
1768
|
+
literal: numeric
|
1769
|
+
{
|
1770
|
+
result = s(:lit, val[0])
|
1771
|
+
}
|
1772
|
+
| symbol
|
1773
|
+
{
|
1774
|
+
result = s(:lit, val[0])
|
1775
|
+
}
|
1586
1776
|
| dsym
|
1587
1777
|
|
1588
1778
|
strings: string
|
@@ -1591,7 +1781,11 @@ rule
|
|
1591
1781
|
result = val[0]
|
1592
1782
|
}
|
1593
1783
|
|
1594
|
-
string:
|
1784
|
+
string: tCHAR
|
1785
|
+
{
|
1786
|
+
debug20 23, val, result
|
1787
|
+
}
|
1788
|
+
| string1
|
1595
1789
|
| string string1
|
1596
1790
|
{
|
1597
1791
|
result = self.literal_concat val[0], val[1]
|
@@ -1631,7 +1825,7 @@ rule
|
|
1631
1825
|
}
|
1632
1826
|
| word_list word tSPACE
|
1633
1827
|
{
|
1634
|
-
result = val[0] << new_word_list_entry(val)
|
1828
|
+
result = val[0].dup << new_word_list_entry(val)
|
1635
1829
|
}
|
1636
1830
|
|
1637
1831
|
word: string_content
|
@@ -1640,6 +1834,24 @@ rule
|
|
1640
1834
|
result = self.literal_concat val[0], val[1]
|
1641
1835
|
}
|
1642
1836
|
|
1837
|
+
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
1838
|
+
{
|
1839
|
+
result = s(:array)
|
1840
|
+
}
|
1841
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
1842
|
+
{
|
1843
|
+
result = val[1]
|
1844
|
+
}
|
1845
|
+
|
1846
|
+
symbol_list: none
|
1847
|
+
{
|
1848
|
+
result = new_symbol_list
|
1849
|
+
}
|
1850
|
+
| symbol_list word tSPACE
|
1851
|
+
{
|
1852
|
+
result = val[0].dup << new_symbol_list_entry(val)
|
1853
|
+
}
|
1854
|
+
|
1643
1855
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
1644
1856
|
{
|
1645
1857
|
result = s(:array)
|
@@ -1649,13 +1861,31 @@ rule
|
|
1649
1861
|
result = val[1]
|
1650
1862
|
}
|
1651
1863
|
|
1864
|
+
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
1865
|
+
{
|
1866
|
+
result = s(:array)
|
1867
|
+
}
|
1868
|
+
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
1869
|
+
{
|
1870
|
+
result = val[1]
|
1871
|
+
}
|
1872
|
+
|
1652
1873
|
qword_list: none
|
1653
1874
|
{
|
1654
1875
|
result = new_qword_list
|
1655
1876
|
}
|
1656
1877
|
| qword_list tSTRING_CONTENT tSPACE
|
1657
1878
|
{
|
1658
|
-
result = val[0] << new_qword_list_entry(val)
|
1879
|
+
result = val[0].dup << new_qword_list_entry(val)
|
1880
|
+
}
|
1881
|
+
|
1882
|
+
qsym_list: none
|
1883
|
+
{
|
1884
|
+
result = new_qsym_list
|
1885
|
+
}
|
1886
|
+
| qsym_list tSTRING_CONTENT tSPACE
|
1887
|
+
{
|
1888
|
+
result = val[0].dup << new_qsym_list_entry(val)
|
1659
1889
|
}
|
1660
1890
|
|
1661
1891
|
string_contents: none
|
@@ -1707,7 +1937,9 @@ regexp_contents: none
|
|
1707
1937
|
lexer.brace_nest,
|
1708
1938
|
lexer.string_nest, # TODO: remove
|
1709
1939
|
lexer.cond.store,
|
1710
|
-
lexer.cmdarg.store
|
1940
|
+
lexer.cmdarg.store,
|
1941
|
+
lexer.lex_state,
|
1942
|
+
]
|
1711
1943
|
|
1712
1944
|
lexer.lex_strterm = nil
|
1713
1945
|
lexer.brace_nest = 0
|
@@ -1715,11 +1947,12 @@ regexp_contents: none
|
|
1715
1947
|
|
1716
1948
|
lexer.lex_state = :expr_beg
|
1717
1949
|
}
|
1718
|
-
compstmt
|
1950
|
+
compstmt
|
1951
|
+
tSTRING_DEND
|
1719
1952
|
{
|
1720
1953
|
_, memo, stmt, _ = val
|
1721
1954
|
|
1722
|
-
lex_strterm, brace_nest, string_nest, oldcond, oldcmdarg = memo
|
1955
|
+
lex_strterm, brace_nest, string_nest, oldcond, oldcmdarg, oldlex_state = memo
|
1723
1956
|
|
1724
1957
|
lexer.lex_strterm = lex_strterm
|
1725
1958
|
lexer.brace_nest = brace_nest
|
@@ -1728,6 +1961,8 @@ regexp_contents: none
|
|
1728
1961
|
lexer.cond.restore oldcond
|
1729
1962
|
lexer.cmdarg.restore oldcmdarg
|
1730
1963
|
|
1964
|
+
lexer.lex_state = oldlex_state
|
1965
|
+
|
1731
1966
|
case stmt
|
1732
1967
|
when Sexp then
|
1733
1968
|
case stmt.sexp_type
|
@@ -1739,6 +1974,7 @@ regexp_contents: none
|
|
1739
1974
|
when nil then
|
1740
1975
|
result = s(:evstr)
|
1741
1976
|
else
|
1977
|
+
debug20 25
|
1742
1978
|
raise "unknown string body: #{stmt.inspect}"
|
1743
1979
|
end
|
1744
1980
|
}
|
@@ -1771,23 +2007,25 @@ regexp_contents: none
|
|
1771
2007
|
when :dstr then
|
1772
2008
|
result.sexp_type = :dsym
|
1773
2009
|
when :str then
|
1774
|
-
result = s(:lit, result.last.
|
1775
|
-
|
2010
|
+
result = s(:lit, result.last.to_sym)
|
2011
|
+
when :evstr then
|
1776
2012
|
result = s(:dsym, "", result)
|
2013
|
+
else
|
2014
|
+
debug20 26, val, result
|
1777
2015
|
end
|
1778
2016
|
}
|
1779
2017
|
|
1780
|
-
numeric:
|
1781
|
-
|
|
1782
|
-
| tUMINUS_NUM tINTEGER =tLOWEST
|
1783
|
-
{
|
1784
|
-
result = -val[1] # TODO: pt_testcase
|
1785
|
-
}
|
1786
|
-
| tUMINUS_NUM tFLOAT =tLOWEST
|
2018
|
+
numeric: simple_numeric
|
2019
|
+
| tUMINUS_NUM simple_numeric
|
1787
2020
|
{
|
1788
2021
|
result = -val[1] # TODO: pt_testcase
|
1789
2022
|
}
|
1790
2023
|
|
2024
|
+
simple_numeric: tINTEGER
|
2025
|
+
| tFLOAT
|
2026
|
+
| tRATIONAL
|
2027
|
+
| tIMAGINARY
|
2028
|
+
|
1791
2029
|
user_variable: tIDENTIFIER
|
1792
2030
|
| tIVAR
|
1793
2031
|
| tGVAR
|
@@ -1828,93 +2066,123 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
1828
2066
|
| keyword_variable
|
1829
2067
|
{
|
1830
2068
|
result = self.assignable val[0]
|
2069
|
+
debug20 29, val, result
|
1831
2070
|
}
|
1832
2071
|
|
1833
2072
|
backref: tNTH_REF { result = s(:nth_ref, val[0]) }
|
1834
2073
|
| tBACK_REF { result = s(:back_ref, val[0]) }
|
1835
2074
|
|
1836
|
-
superclass:
|
1837
|
-
{
|
1838
|
-
result = nil
|
1839
|
-
}
|
1840
|
-
| tLT
|
2075
|
+
superclass: tLT
|
1841
2076
|
{
|
1842
2077
|
lexer.lex_state = :expr_beg
|
2078
|
+
lexer.command_start = true
|
1843
2079
|
}
|
1844
2080
|
expr_value term
|
1845
2081
|
{
|
1846
2082
|
result = val[2]
|
1847
2083
|
}
|
1848
|
-
|
|
2084
|
+
| none
|
1849
2085
|
{
|
1850
|
-
yyerrok
|
1851
2086
|
result = nil
|
1852
2087
|
}
|
1853
2088
|
|
1854
2089
|
f_arglist: tLPAREN2 f_args rparen
|
1855
2090
|
{
|
1856
2091
|
result = val[1]
|
1857
|
-
lexer.lex_state = :expr_beg
|
2092
|
+
self.lexer.lex_state = :expr_beg
|
1858
2093
|
self.lexer.command_start = true
|
1859
2094
|
}
|
1860
|
-
|
|
2095
|
+
| {
|
2096
|
+
result = self.in_kwarg
|
2097
|
+
self.in_kwarg = true
|
2098
|
+
# TODO: self.lexer.lex_state |= :expr_label
|
2099
|
+
}
|
2100
|
+
f_args term
|
1861
2101
|
{
|
1862
|
-
|
2102
|
+
kwarg, args, _ = val
|
2103
|
+
|
2104
|
+
self.in_kwarg = kwarg
|
2105
|
+
result = args
|
2106
|
+
lexer.lex_state = :expr_beg
|
2107
|
+
lexer.command_start = true
|
2108
|
+
}
|
2109
|
+
|
2110
|
+
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
2111
|
+
{
|
2112
|
+
result = args val
|
2113
|
+
}
|
2114
|
+
| f_kwarg opt_f_block_arg
|
2115
|
+
{
|
2116
|
+
result = args val
|
1863
2117
|
}
|
2118
|
+
| f_kwrest opt_f_block_arg
|
2119
|
+
{
|
2120
|
+
result = args val
|
2121
|
+
}
|
2122
|
+
| f_block_arg
|
1864
2123
|
|
1865
|
-
|
2124
|
+
opt_args_tail: tCOMMA args_tail
|
2125
|
+
{
|
2126
|
+
result = val[1]
|
2127
|
+
}
|
2128
|
+
|
|
2129
|
+
{
|
2130
|
+
result = nil
|
2131
|
+
}
|
2132
|
+
|
2133
|
+
f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
|
1866
2134
|
{
|
1867
2135
|
result = args val
|
1868
2136
|
}
|
1869
|
-
| f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg
|
2137
|
+
| f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
|
1870
2138
|
{
|
1871
2139
|
result = args val
|
1872
2140
|
}
|
1873
|
-
| f_arg tCOMMA f_optarg
|
2141
|
+
| f_arg tCOMMA f_optarg opt_args_tail
|
1874
2142
|
{
|
1875
2143
|
result = args val
|
1876
2144
|
}
|
1877
|
-
| f_arg tCOMMA f_optarg tCOMMA f_arg
|
2145
|
+
| f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
|
1878
2146
|
{
|
1879
2147
|
result = args val
|
1880
2148
|
}
|
1881
|
-
| f_arg tCOMMA f_rest_arg
|
2149
|
+
| f_arg tCOMMA f_rest_arg opt_args_tail
|
1882
2150
|
{
|
1883
2151
|
result = args val
|
1884
2152
|
}
|
1885
|
-
| f_arg tCOMMA f_rest_arg tCOMMA f_arg
|
2153
|
+
| f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
|
1886
2154
|
{
|
1887
2155
|
result = args val
|
1888
2156
|
}
|
1889
|
-
| f_arg
|
2157
|
+
| f_arg opt_args_tail
|
1890
2158
|
{
|
1891
2159
|
result = args val
|
1892
2160
|
}
|
1893
|
-
| f_optarg tCOMMA f_rest_arg
|
2161
|
+
| f_optarg tCOMMA f_rest_arg opt_args_tail
|
1894
2162
|
{
|
1895
2163
|
result = args val
|
1896
2164
|
}
|
1897
|
-
| f_optarg tCOMMA f_rest_arg tCOMMA f_arg
|
2165
|
+
| f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
|
1898
2166
|
{
|
1899
2167
|
result = args val
|
1900
2168
|
}
|
1901
|
-
| f_optarg
|
2169
|
+
| f_optarg opt_args_tail
|
1902
2170
|
{
|
1903
2171
|
result = args val
|
1904
2172
|
}
|
1905
|
-
| f_optarg tCOMMA f_arg
|
2173
|
+
| f_optarg tCOMMA f_arg opt_args_tail
|
1906
2174
|
{
|
1907
2175
|
result = args val
|
1908
2176
|
}
|
1909
|
-
| f_rest_arg
|
2177
|
+
| f_rest_arg opt_args_tail
|
1910
2178
|
{
|
1911
2179
|
result = args val
|
1912
2180
|
}
|
1913
|
-
| f_rest_arg tCOMMA f_arg
|
2181
|
+
| f_rest_arg tCOMMA f_arg opt_args_tail
|
1914
2182
|
{
|
1915
2183
|
result = args val
|
1916
2184
|
}
|
1917
|
-
|
|
2185
|
+
| args_tail
|
1918
2186
|
{
|
1919
2187
|
result = args val
|
1920
2188
|
}
|
@@ -1949,7 +2217,9 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
1949
2217
|
result = identifier
|
1950
2218
|
}
|
1951
2219
|
|
1952
|
-
|
2220
|
+
f_arg_asgn: f_norm_arg
|
2221
|
+
|
2222
|
+
f_arg_item: f_arg_asgn
|
1953
2223
|
| tLPAREN f_margs rparen
|
1954
2224
|
{
|
1955
2225
|
result = val[1]
|
@@ -1964,6 +2234,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
1964
2234
|
when Sexp then
|
1965
2235
|
result = val[0]
|
1966
2236
|
else
|
2237
|
+
debug20 32
|
1967
2238
|
raise "Unknown f_arg type: #{val.inspect}"
|
1968
2239
|
end
|
1969
2240
|
}
|
@@ -1980,13 +2251,78 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
1980
2251
|
result << item
|
1981
2252
|
}
|
1982
2253
|
|
1983
|
-
|
2254
|
+
f_label: tLABEL
|
2255
|
+
|
2256
|
+
f_kw: f_label arg_value
|
2257
|
+
{
|
2258
|
+
# TODO: call_args
|
2259
|
+
label, _ = val[0] # TODO: fix lineno?
|
2260
|
+
identifier = label.to_sym
|
2261
|
+
self.env[identifier] = :lvar
|
2262
|
+
|
2263
|
+
result = s(:array, s(:kwarg, identifier, val[1]))
|
2264
|
+
}
|
2265
|
+
| f_label
|
2266
|
+
{
|
2267
|
+
label, _ = val[0] # TODO: fix lineno?
|
2268
|
+
identifier = label.to_sym
|
2269
|
+
self.env[identifier] = :lvar
|
2270
|
+
|
2271
|
+
result = s(:array, s(:kwarg, identifier))
|
2272
|
+
}
|
2273
|
+
|
2274
|
+
f_block_kw: f_label primary_value
|
2275
|
+
{
|
2276
|
+
# TODO: call_args
|
2277
|
+
label, _ = val[0] # TODO: fix lineno?
|
2278
|
+
identifier = label.to_sym
|
2279
|
+
self.env[identifier] = :lvar
|
2280
|
+
|
2281
|
+
result = s(:array, s(:kwarg, identifier, val[1]))
|
2282
|
+
}
|
2283
|
+
| f_label
|
2284
|
+
{
|
2285
|
+
label, _ = val[0] # TODO: fix lineno?
|
2286
|
+
identifier = label.to_sym
|
2287
|
+
self.env[identifier] = :lvar
|
2288
|
+
|
2289
|
+
result = s(:array, s(:kwarg, identifier))
|
2290
|
+
}
|
2291
|
+
|
2292
|
+
f_block_kwarg: f_block_kw
|
2293
|
+
| f_block_kwarg tCOMMA f_block_kw
|
2294
|
+
{
|
2295
|
+
list, _, item = val
|
2296
|
+
result = list << item.last
|
2297
|
+
}
|
2298
|
+
|
2299
|
+
f_kwarg: f_kw
|
2300
|
+
| f_kwarg tCOMMA f_kw
|
2301
|
+
{
|
2302
|
+
result = args val
|
2303
|
+
}
|
2304
|
+
|
2305
|
+
kwrest_mark: tPOW
|
2306
|
+
| tDSTAR
|
2307
|
+
|
2308
|
+
f_kwrest: kwrest_mark tIDENTIFIER
|
2309
|
+
{
|
2310
|
+
name = val[1].to_sym
|
2311
|
+
self.assignable name
|
2312
|
+
result = :"**#{name}"
|
2313
|
+
}
|
2314
|
+
| kwrest_mark
|
2315
|
+
{
|
2316
|
+
result = :"**"
|
2317
|
+
}
|
2318
|
+
|
2319
|
+
f_opt: f_arg_asgn tEQL arg_value
|
1984
2320
|
{
|
1985
2321
|
result = self.assignable val[0], val[2]
|
1986
2322
|
# TODO: detect duplicate names
|
1987
2323
|
}
|
1988
2324
|
|
1989
|
-
f_block_opt:
|
2325
|
+
f_block_opt: f_arg_asgn tEQL primary_value
|
1990
2326
|
{
|
1991
2327
|
result = self.assignable val[0], val[2]
|
1992
2328
|
}
|
@@ -2073,22 +2409,39 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2073
2409
|
more = val[2].sexp_body
|
2074
2410
|
list.push(*more) unless more.empty?
|
2075
2411
|
result = list
|
2412
|
+
result.sexp_type = :hash
|
2076
2413
|
}
|
2077
2414
|
|
2078
2415
|
assoc: arg_value tASSOC arg_value
|
2079
2416
|
{
|
2080
2417
|
result = s(:array, val[0], val[2])
|
2081
2418
|
}
|
2082
|
-
| tLABEL
|
2419
|
+
| tLABEL arg_value
|
2083
2420
|
{
|
2084
|
-
label, _ = val
|
2085
|
-
result = s(:array, s(:lit, label.to_sym),
|
2421
|
+
(label, _), arg = val
|
2422
|
+
result = s(:array, s(:lit, label.to_sym), arg)
|
2423
|
+
}
|
2424
|
+
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2425
|
+
{
|
2426
|
+
_, sym, _, value = val
|
2427
|
+
sym.sexp_type = :dsym
|
2428
|
+
result = s(:array, sym, value)
|
2429
|
+
}
|
2430
|
+
| tDSTAR arg_value
|
2431
|
+
{
|
2432
|
+
result = s(:array, s(:kwsplat, val[1]))
|
2086
2433
|
}
|
2087
2434
|
|
2088
2435
|
operation: tIDENTIFIER | tCONSTANT | tFID
|
2089
2436
|
operation2: tIDENTIFIER | tCONSTANT | tFID | op
|
2090
2437
|
operation3: tIDENTIFIER | tFID | op
|
2091
2438
|
dot_or_colon: tDOT | tCOLON2
|
2439
|
+
call_op: tDOT
|
2440
|
+
| tLONELY # TODO: rename tANDDOT?
|
2441
|
+
|
2442
|
+
call_op2: call_op
|
2443
|
+
| tCOLON2
|
2444
|
+
|
2092
2445
|
opt_terms: | terms
|
2093
2446
|
opt_nl: | tNL
|
2094
2447
|
rparen: opt_nl tRPAREN
|
@@ -2101,7 +2454,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2101
2454
|
terms: term
|
2102
2455
|
| terms tSEMI { yyerrok }
|
2103
2456
|
|
2104
|
-
none: { result = nil }
|
2457
|
+
none: { result = nil; }
|
2105
2458
|
end
|
2106
2459
|
|
2107
2460
|
---- inner
|