ruby_parser 3.21.1 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +29 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +12 -0
- data/Rakefile +28 -19
- data/bin/ruby_parse +0 -8
- data/compare/normalize.rb +17 -3
- data/gauntlet.md +35 -5
- data/lib/ruby_lexer.rb +0 -2
- data/lib/ruby_parser.rb +3 -1
- data/lib/ruby_parser2.yy +12 -12
- data/lib/ruby_parser20.rb +11 -11
- data/lib/ruby_parser21.rb +11 -11
- data/lib/ruby_parser22.rb +11 -11
- data/lib/ruby_parser23.rb +11 -11
- data/lib/ruby_parser24.rb +11 -11
- data/lib/ruby_parser25.rb +11 -11
- data/lib/ruby_parser26.rb +11 -11
- data/lib/ruby_parser27.rb +13 -13
- data/lib/ruby_parser3.yy +207 -46
- data/lib/ruby_parser30.rb +3329 -3317
- data/lib/ruby_parser31.rb +3762 -3774
- data/lib/ruby_parser32.rb +6240 -6252
- data/lib/ruby_parser33.rb +7918 -7842
- data/lib/ruby_parser34.rb +13653 -0
- data/lib/ruby_parser_extras.rb +78 -47
- data/test/test_ruby_lexer.rb +2 -2
- data/test/test_ruby_parser.rb +50 -93
- data.tar.gz.sig +3 -2
- metadata +15 -20
- metadata.gz.sig +0 -0
data/lib/ruby_parser3.yy
CHANGED
|
@@ -8,6 +8,8 @@ class Ruby31Parser
|
|
|
8
8
|
class Ruby32Parser
|
|
9
9
|
#elif V == 33
|
|
10
10
|
class Ruby33Parser
|
|
11
|
+
#elif V == 34
|
|
12
|
+
class Ruby34Parser
|
|
11
13
|
#else
|
|
12
14
|
fail "version not specified or supported on code generation"
|
|
13
15
|
#endif
|
|
@@ -84,7 +86,9 @@ rule
|
|
|
84
86
|
{
|
|
85
87
|
result = self.block_append val[0], val[2]
|
|
86
88
|
}
|
|
89
|
+
#if V < 32
|
|
87
90
|
| error top_stmt
|
|
91
|
+
#endif
|
|
88
92
|
|
|
89
93
|
top_stmt: stmt
|
|
90
94
|
| klBEGIN
|
|
@@ -106,7 +110,12 @@ rule
|
|
|
106
110
|
result = iter
|
|
107
111
|
}
|
|
108
112
|
|
|
113
|
+
#if V < 33
|
|
109
114
|
begin_block: tLCURLY top_compstmt tRCURLY
|
|
115
|
+
#else
|
|
116
|
+
block_open: tLCURLY
|
|
117
|
+
begin_block: block_open top_compstmt tRCURLY
|
|
118
|
+
#endif
|
|
110
119
|
{
|
|
111
120
|
(_, line), stmt, _ = val
|
|
112
121
|
result = new_iter s(:preexe).line(line), 0, stmt
|
|
@@ -142,11 +151,13 @@ rule
|
|
|
142
151
|
{
|
|
143
152
|
result = self.block_append val[0], val[2]
|
|
144
153
|
}
|
|
154
|
+
#if V < 32
|
|
145
155
|
| error stmt
|
|
146
156
|
{
|
|
147
157
|
result = val[1]
|
|
148
158
|
debug 2
|
|
149
159
|
}
|
|
160
|
+
#endif
|
|
150
161
|
|
|
151
162
|
stmt_or_begin: stmt
|
|
152
163
|
| klBEGIN
|
|
@@ -158,6 +169,10 @@ rule
|
|
|
158
169
|
result = val[2] # wtf?
|
|
159
170
|
}
|
|
160
171
|
|
|
172
|
+
#if V >= 33
|
|
173
|
+
allow_exits: none
|
|
174
|
+
#endif
|
|
175
|
+
|
|
161
176
|
stmt: kALIAS fitem
|
|
162
177
|
{
|
|
163
178
|
lexer.lex_state = EXPR_FNAME
|
|
@@ -205,16 +220,30 @@ rule
|
|
|
205
220
|
e, _, c = val
|
|
206
221
|
result = new_until e, c, true
|
|
207
222
|
}
|
|
208
|
-
| stmt kRESCUE_MOD
|
|
223
|
+
| stmt kRESCUE_MOD
|
|
224
|
+
#if V > 32
|
|
225
|
+
after_rescue
|
|
226
|
+
#endif
|
|
227
|
+
stmt
|
|
209
228
|
{
|
|
229
|
+
#if V > 32
|
|
230
|
+
body, _, _, resbody = val
|
|
231
|
+
#else
|
|
210
232
|
body, _, resbody = val
|
|
233
|
+
#endif
|
|
211
234
|
|
|
212
235
|
resbody = new_resbody s(:array).line(resbody.line), resbody
|
|
213
236
|
result = new_rescue body, resbody
|
|
214
237
|
}
|
|
238
|
+
#if V < 33
|
|
215
239
|
| klEND tLCURLY compstmt tRCURLY
|
|
216
240
|
{
|
|
217
241
|
(_, line), _, stmt, _ = val
|
|
242
|
+
#else
|
|
243
|
+
| klEND allow_exits tLCURLY compstmt tRCURLY
|
|
244
|
+
{
|
|
245
|
+
(_, line), _, _, stmt, _ = val
|
|
246
|
+
#endif
|
|
218
247
|
|
|
219
248
|
if (self.in_def || self.in_single > 0) then
|
|
220
249
|
debug 3
|
|
@@ -234,10 +263,18 @@ rule
|
|
|
234
263
|
|
|
235
264
|
result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
|
|
236
265
|
}
|
|
266
|
+
#if V > 32
|
|
267
|
+
| mlhs tEQL mrhs_arg kRESCUE_MOD after_rescue stmt
|
|
268
|
+
#else
|
|
237
269
|
| mlhs tEQL mrhs_arg kRESCUE_MOD stmt
|
|
270
|
+
#endif
|
|
238
271
|
{
|
|
239
272
|
# unwraps s(:to_ary, rhs)
|
|
273
|
+
#if V > 32
|
|
274
|
+
lhs, _, (_, rhs), _, _, resbody = val
|
|
275
|
+
#else
|
|
240
276
|
lhs, _, (_, rhs), _, resbody = val
|
|
277
|
+
#endif
|
|
241
278
|
|
|
242
279
|
resbody = new_resbody s(:array).line(resbody.line), resbody
|
|
243
280
|
|
|
@@ -248,6 +285,9 @@ rule
|
|
|
248
285
|
result = new_masgn val[0], val[2]
|
|
249
286
|
}
|
|
250
287
|
| expr
|
|
288
|
+
#if V >= 32
|
|
289
|
+
| error
|
|
290
|
+
#endif
|
|
251
291
|
|
|
252
292
|
command_asgn: lhs tEQL command_rhs
|
|
253
293
|
{
|
|
@@ -321,9 +361,17 @@ rule
|
|
|
321
361
|
expr, = val
|
|
322
362
|
result = value_expr expr
|
|
323
363
|
}
|
|
364
|
+
#if V > 32
|
|
365
|
+
| command_call kRESCUE_MOD after_rescue stmt
|
|
366
|
+
#else
|
|
324
367
|
| command_call kRESCUE_MOD stmt
|
|
368
|
+
#endif
|
|
325
369
|
{
|
|
370
|
+
#if V > 32
|
|
371
|
+
expr, (_, line), _, resbody = val
|
|
372
|
+
#else
|
|
326
373
|
expr, (_, line), resbody = val
|
|
374
|
+
#endif
|
|
327
375
|
|
|
328
376
|
expr = value_expr expr
|
|
329
377
|
ary = s(:array).line line
|
|
@@ -364,7 +412,7 @@ rule
|
|
|
364
412
|
self.in_kwarg = true
|
|
365
413
|
self.env.extend
|
|
366
414
|
}
|
|
367
|
-
#if V
|
|
415
|
+
#if V < 31
|
|
368
416
|
p_expr
|
|
369
417
|
#else
|
|
370
418
|
p_top_expr_body
|
|
@@ -388,7 +436,7 @@ rule
|
|
|
388
436
|
self.in_kwarg = true
|
|
389
437
|
self.env.extend
|
|
390
438
|
}
|
|
391
|
-
#if V
|
|
439
|
+
#if V < 31
|
|
392
440
|
p_expr
|
|
393
441
|
#else
|
|
394
442
|
p_top_expr_body
|
|
@@ -446,6 +494,9 @@ rule
|
|
|
446
494
|
{
|
|
447
495
|
result = value_expr(val[0])
|
|
448
496
|
}
|
|
497
|
+
#if V >= 32
|
|
498
|
+
| error
|
|
499
|
+
#endif
|
|
449
500
|
|
|
450
501
|
expr_value_do: {
|
|
451
502
|
lexer.cond.push true
|
|
@@ -1072,9 +1123,17 @@ rule
|
|
|
1072
1123
|
{
|
|
1073
1124
|
result = logical_op :or, val[0], val[2]
|
|
1074
1125
|
}
|
|
1075
|
-
| kDEFINED opt_nl
|
|
1126
|
+
| kDEFINED opt_nl
|
|
1127
|
+
#if V > 32
|
|
1128
|
+
begin_defined
|
|
1129
|
+
#endif
|
|
1130
|
+
arg
|
|
1076
1131
|
{
|
|
1132
|
+
#if V > 32
|
|
1133
|
+
(_, line), _, _, arg = val
|
|
1134
|
+
#else
|
|
1077
1135
|
(_, line), _, arg = val
|
|
1136
|
+
#endif
|
|
1078
1137
|
result = s(:defined, arg).line line
|
|
1079
1138
|
}
|
|
1080
1139
|
| arg tEH arg opt_nl tCOLON arg
|
|
@@ -1117,6 +1176,12 @@ rule
|
|
|
1117
1176
|
result = new_call lhs, op.to_sym, argl(rhs)
|
|
1118
1177
|
}
|
|
1119
1178
|
|
|
1179
|
+
#if V > 32
|
|
1180
|
+
lex_ctxt: none
|
|
1181
|
+
begin_defined: lex_ctxt
|
|
1182
|
+
after_rescue: lex_ctxt
|
|
1183
|
+
#endif
|
|
1184
|
+
|
|
1120
1185
|
arg_value: arg
|
|
1121
1186
|
{
|
|
1122
1187
|
result = value_expr(val[0])
|
|
@@ -1137,9 +1202,17 @@ rule
|
|
|
1137
1202
|
}
|
|
1138
1203
|
|
|
1139
1204
|
arg_rhs: arg =tOP_ASGN
|
|
1140
|
-
| arg kRESCUE_MOD
|
|
1205
|
+
| arg kRESCUE_MOD
|
|
1206
|
+
#if V > 32
|
|
1207
|
+
after_rescue
|
|
1208
|
+
#endif
|
|
1209
|
+
arg
|
|
1141
1210
|
{
|
|
1211
|
+
#if V > 32
|
|
1212
|
+
body, (_, line), _, resbody = val
|
|
1213
|
+
#else
|
|
1142
1214
|
body, (_, line), resbody = val
|
|
1215
|
+
#endif
|
|
1143
1216
|
body = value_expr body
|
|
1144
1217
|
resbody = remove_begin resbody
|
|
1145
1218
|
|
|
@@ -1390,10 +1463,11 @@ rule
|
|
|
1390
1463
|
{
|
|
1391
1464
|
result = wrap :colon3, val[1]
|
|
1392
1465
|
}
|
|
1393
|
-
| tLBRACK aref_args
|
|
1466
|
+
| tLBRACK aref_args tRBRACK
|
|
1394
1467
|
{
|
|
1395
|
-
(_, line), args,
|
|
1468
|
+
(_, line), args, _ = val
|
|
1396
1469
|
|
|
1470
|
+
line_max = lexer.lineno
|
|
1397
1471
|
result = args || s(:array)
|
|
1398
1472
|
result.sexp_type = :array # aref_args is :args
|
|
1399
1473
|
result.line line
|
|
@@ -1521,7 +1595,11 @@ rule
|
|
|
1521
1595
|
self.env.unextend
|
|
1522
1596
|
}
|
|
1523
1597
|
| k_class tLSHFT
|
|
1598
|
+
#if V > 32
|
|
1599
|
+
expr_value
|
|
1600
|
+
#else
|
|
1524
1601
|
expr
|
|
1602
|
+
#endif
|
|
1525
1603
|
{
|
|
1526
1604
|
result = self.in_def
|
|
1527
1605
|
self.in_def = false
|
|
@@ -1604,9 +1682,18 @@ rule
|
|
|
1604
1682
|
k_if: kIF
|
|
1605
1683
|
k_unless: kUNLESS
|
|
1606
1684
|
k_while: kWHILE
|
|
1685
|
+
#if V > 32
|
|
1686
|
+
allow_exits
|
|
1687
|
+
#endif
|
|
1607
1688
|
k_until: kUNTIL
|
|
1689
|
+
#if V > 32
|
|
1690
|
+
allow_exits
|
|
1691
|
+
#endif
|
|
1608
1692
|
k_case: kCASE
|
|
1609
1693
|
k_for: kFOR
|
|
1694
|
+
#if V > 32
|
|
1695
|
+
allow_exits
|
|
1696
|
+
#endif
|
|
1610
1697
|
k_class: kCLASS
|
|
1611
1698
|
{
|
|
1612
1699
|
result << self.lexer.comment
|
|
@@ -1630,6 +1717,10 @@ rule
|
|
|
1630
1717
|
k_end: kEND
|
|
1631
1718
|
k_return: kRETURN
|
|
1632
1719
|
|
|
1720
|
+
#if V > 32
|
|
1721
|
+
k_yield: kYIELD
|
|
1722
|
+
#endif
|
|
1723
|
+
|
|
1633
1724
|
then: term
|
|
1634
1725
|
| kTHEN
|
|
1635
1726
|
| term kTHEN
|
|
@@ -1876,6 +1967,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
1876
1967
|
}
|
|
1877
1968
|
| f_bad_arg
|
|
1878
1969
|
|
|
1970
|
+
#if V > 32
|
|
1971
|
+
max_numparam: none
|
|
1972
|
+
numparam: none
|
|
1973
|
+
#endif
|
|
1974
|
+
|
|
1879
1975
|
lambda: tLAMBDA
|
|
1880
1976
|
{
|
|
1881
1977
|
self.env.extend :dynamic
|
|
@@ -1883,13 +1979,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
1883
1979
|
lexer.paren_nest += 1
|
|
1884
1980
|
lexer.lpar_beg = lexer.paren_nest
|
|
1885
1981
|
}
|
|
1982
|
+
#if V > 32
|
|
1983
|
+
max_numparam numparam allow_exits
|
|
1984
|
+
#endif
|
|
1886
1985
|
f_larglist
|
|
1887
1986
|
{
|
|
1888
1987
|
lexer.cmdarg.push false
|
|
1889
1988
|
}
|
|
1890
1989
|
lambda_body
|
|
1891
1990
|
{
|
|
1991
|
+
#if V > 32
|
|
1992
|
+
(_, line), _, _, _, lpar, args, _cmdarg, body = val
|
|
1993
|
+
#else
|
|
1892
1994
|
(_, line), lpar, args, _cmdarg, body = val
|
|
1995
|
+
#endif
|
|
1893
1996
|
lexer.lpar_beg = lpar
|
|
1894
1997
|
|
|
1895
1998
|
lexer.cmdarg.pop
|
|
@@ -2052,11 +2155,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2052
2155
|
self.env.unextend
|
|
2053
2156
|
}
|
|
2054
2157
|
|
|
2055
|
-
brace_body:
|
|
2158
|
+
brace_body:
|
|
2159
|
+
#if V > 32
|
|
2160
|
+
max_numparam numparam allow_exits
|
|
2161
|
+
#endif
|
|
2162
|
+
|
|
2163
|
+
{ self.env.extend :dynamic; result = self.lexer.lineno }
|
|
2056
2164
|
{ result = lexer.cmdarg.store(false) }
|
|
2057
2165
|
opt_block_param compstmt
|
|
2058
2166
|
{
|
|
2167
|
+
#if V > 32
|
|
2168
|
+
_, _, _, line, cmdarg, param, cmpstmt = val
|
|
2169
|
+
#else
|
|
2059
2170
|
line, cmdarg, param, cmpstmt = val
|
|
2171
|
+
#endif
|
|
2060
2172
|
|
|
2061
2173
|
result = new_brace_body param, cmpstmt, line
|
|
2062
2174
|
self.env.unextend
|
|
@@ -2064,12 +2176,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2064
2176
|
lexer.cmdarg.pop # because of: cmdarg_stack >> 1 ?
|
|
2065
2177
|
}
|
|
2066
2178
|
|
|
2067
|
-
do_body:
|
|
2179
|
+
do_body:
|
|
2180
|
+
#if V > 32
|
|
2181
|
+
max_numparam numparam allow_exits
|
|
2182
|
+
#endif
|
|
2183
|
+
{ self.env.extend :dynamic; result = self.lexer.lineno }
|
|
2068
2184
|
{ lexer.cmdarg.push false }
|
|
2069
2185
|
opt_block_param
|
|
2070
2186
|
bodystmt
|
|
2071
2187
|
{
|
|
2188
|
+
#if V > 32
|
|
2189
|
+
_, _, _, line, _cmdarg, param, cmpstmt = val
|
|
2190
|
+
#else
|
|
2072
2191
|
line, _cmdarg, param, cmpstmt = val
|
|
2192
|
+
#endif
|
|
2073
2193
|
|
|
2074
2194
|
result = new_do_body param, cmpstmt, line
|
|
2075
2195
|
lexer.cmdarg.pop
|
|
@@ -2509,7 +2629,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2509
2629
|
|
|
2510
2630
|
case lhs.sexp_type
|
|
2511
2631
|
when :lit then
|
|
2512
|
-
assignable [lhs.value, lhs.line]
|
|
2632
|
+
assignable lhs # [lhs.value, lhs.line]
|
|
2513
2633
|
else
|
|
2514
2634
|
# TODO or done?
|
|
2515
2635
|
debug 10
|
|
@@ -2536,7 +2656,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2536
2656
|
_, (id, line) = val
|
|
2537
2657
|
|
|
2538
2658
|
name = id.to_sym
|
|
2539
|
-
self.assignable [name, line]
|
|
2659
|
+
self.assignable s(:bogus, name).line line # [name, line]
|
|
2540
2660
|
result = s(:kwrest, :"**#{name}").line line
|
|
2541
2661
|
}
|
|
2542
2662
|
| kwrest_mark
|
|
@@ -2588,11 +2708,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2588
2708
|
|
|
2589
2709
|
result = s(:dot3, v1, nil).line v1.line
|
|
2590
2710
|
}
|
|
2591
|
-
#if V
|
|
2711
|
+
#if V < 31
|
|
2592
2712
|
| p_variable
|
|
2593
2713
|
#endif
|
|
2594
2714
|
| p_var_ref
|
|
2595
|
-
#if V
|
|
2715
|
+
#if V >= 31
|
|
2596
2716
|
| p_expr_ref
|
|
2597
2717
|
#endif
|
|
2598
2718
|
| p_const
|
|
@@ -2770,6 +2890,10 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2770
2890
|
result = new_regexp val
|
|
2771
2891
|
}
|
|
2772
2892
|
|
|
2893
|
+
#if V > 32
|
|
2894
|
+
words_sep: tSPACE
|
|
2895
|
+
| words_sep tSPACE
|
|
2896
|
+
#endif
|
|
2773
2897
|
words: tWORDS_BEG tSPACE tSTRING_END
|
|
2774
2898
|
{
|
|
2775
2899
|
(_, line), _, (_, line_max) = val
|
|
@@ -2789,7 +2913,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2789
2913
|
{
|
|
2790
2914
|
result = new_word_list
|
|
2791
2915
|
}
|
|
2916
|
+
#if V < 33
|
|
2792
2917
|
| word_list word tSPACE
|
|
2918
|
+
#else
|
|
2919
|
+
| word_list word words_sep
|
|
2920
|
+
#endif
|
|
2793
2921
|
{
|
|
2794
2922
|
result = val[0].dup << new_word_list_entry(val)
|
|
2795
2923
|
}
|
|
@@ -2819,7 +2947,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2819
2947
|
{
|
|
2820
2948
|
result = new_symbol_list
|
|
2821
2949
|
}
|
|
2950
|
+
#if V < 33
|
|
2822
2951
|
| symbol_list word tSPACE
|
|
2952
|
+
#else
|
|
2953
|
+
| symbol_list word words_sep
|
|
2954
|
+
#endif
|
|
2823
2955
|
{
|
|
2824
2956
|
list, * = val
|
|
2825
2957
|
result = list.dup << new_symbol_list_entry(val)
|
|
@@ -2859,7 +2991,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2859
2991
|
{
|
|
2860
2992
|
result = new_qword_list
|
|
2861
2993
|
}
|
|
2994
|
+
#if V < 33
|
|
2862
2995
|
| qword_list tSTRING_CONTENT tSPACE
|
|
2996
|
+
#else
|
|
2997
|
+
| qword_list tSTRING_CONTENT words_sep
|
|
2998
|
+
#endif
|
|
2863
2999
|
{
|
|
2864
3000
|
result = val[0].dup << new_qword_list_entry(val)
|
|
2865
3001
|
}
|
|
@@ -2868,7 +3004,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2868
3004
|
{
|
|
2869
3005
|
result = new_qsym_list
|
|
2870
3006
|
}
|
|
3007
|
+
#if V < 33
|
|
2871
3008
|
| qsym_list tSTRING_CONTENT tSPACE
|
|
3009
|
+
#else
|
|
3010
|
+
| qsym_list tSTRING_CONTENT words_sep
|
|
3011
|
+
#endif
|
|
2872
3012
|
{
|
|
2873
3013
|
result = val[0].dup << new_qsym_list_entry(val)
|
|
2874
3014
|
}
|
|
@@ -2939,7 +3079,11 @@ regexp_contents: none
|
|
|
2939
3079
|
lexer.lex_state = EXPR_BEG
|
|
2940
3080
|
}
|
|
2941
3081
|
compstmt
|
|
3082
|
+
#if V > 32
|
|
3083
|
+
string_dend
|
|
3084
|
+
#else
|
|
2942
3085
|
tSTRING_DEND
|
|
3086
|
+
#endif
|
|
2943
3087
|
{
|
|
2944
3088
|
(_, line), memo, stmt, _ = val
|
|
2945
3089
|
|
|
@@ -2971,6 +3115,12 @@ regexp_contents: none
|
|
|
2971
3115
|
end
|
|
2972
3116
|
}
|
|
2973
3117
|
|
|
3118
|
+
#if V > 32
|
|
3119
|
+
string_dend: tSTRING_DEND
|
|
3120
|
+
| "end-of-input" /* wtf? */
|
|
3121
|
+
#endif
|
|
3122
|
+
|
|
3123
|
+
#if V < 33
|
|
2974
3124
|
string_dvar: tGVAR
|
|
2975
3125
|
{
|
|
2976
3126
|
result = wrap :gvar, val[0]
|
|
@@ -2984,6 +3134,10 @@ regexp_contents: none
|
|
|
2984
3134
|
result = wrap :cvar, val[0]
|
|
2985
3135
|
}
|
|
2986
3136
|
| backref
|
|
3137
|
+
#else
|
|
3138
|
+
string_dvar: nonlocal_var
|
|
3139
|
+
| backref
|
|
3140
|
+
#endif
|
|
2987
3141
|
|
|
2988
3142
|
symbol: ssym
|
|
2989
3143
|
| dsym
|
|
@@ -2991,7 +3145,14 @@ regexp_contents: none
|
|
|
2991
3145
|
ssym: tSYMBEG sym
|
|
2992
3146
|
{
|
|
2993
3147
|
lexer.lex_state = EXPR_END
|
|
2994
|
-
|
|
3148
|
+
_, sym = val
|
|
3149
|
+
result =
|
|
3150
|
+
if sym.is_a? Sexp then
|
|
3151
|
+
sym.sexp_type = :lit
|
|
3152
|
+
sym
|
|
3153
|
+
else
|
|
3154
|
+
wrap :lit, sym
|
|
3155
|
+
end
|
|
2995
3156
|
}
|
|
2996
3157
|
| tSYMBOL
|
|
2997
3158
|
{
|
|
@@ -2999,7 +3160,11 @@ regexp_contents: none
|
|
|
2999
3160
|
result = wrap :lit, val[0]
|
|
3000
3161
|
}
|
|
3001
3162
|
|
|
3163
|
+
#if V < 31
|
|
3002
3164
|
sym: fname | tIVAR | tGVAR | tCVAR
|
|
3165
|
+
#else
|
|
3166
|
+
sym: fname | nonlocal_var
|
|
3167
|
+
#endif
|
|
3003
3168
|
|
|
3004
3169
|
dsym: tSYMBEG string_contents tSTRING_END
|
|
3005
3170
|
{
|
|
@@ -3039,11 +3204,17 @@ regexp_contents: none
|
|
|
3039
3204
|
| tCVAR { result = wrap :cvar, val[0] }
|
|
3040
3205
|
#endif
|
|
3041
3206
|
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
|
3045
|
-
|
|
|
3046
|
-
|
|
|
3207
|
+
#if V < 32
|
|
3208
|
+
user_variable: tIDENTIFIER { (var, line), = val; result = gettable(var).line line }
|
|
3209
|
+
| tIVAR { result = wrap :ivar, val[0] }
|
|
3210
|
+
| tGVAR { result = wrap :gvar, val[0] }
|
|
3211
|
+
| tCONSTANT { (var, line), = val; result = gettable(var).line line }
|
|
3212
|
+
| tCVAR { result = wrap :cvar, val[0] }
|
|
3213
|
+
#else
|
|
3214
|
+
user_variable: tIDENTIFIER { (var, line), = val; result = gettable(var).line line }
|
|
3215
|
+
| tCONSTANT { (var, line), = val; result = gettable(var).line line }
|
|
3216
|
+
| nonlocal_var
|
|
3217
|
+
#endif
|
|
3047
3218
|
|
|
3048
3219
|
keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
|
|
3049
3220
|
| kSELF { (_, line), = val; result = s(:self).line line }
|
|
@@ -3063,18 +3234,7 @@ keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
|
|
|
3063
3234
|
}
|
|
3064
3235
|
|
|
3065
3236
|
var_ref: user_variable
|
|
3066
|
-
{
|
|
3067
|
-
raise "NO: #{val.inspect}" if Sexp === val.first
|
|
3068
|
-
(var, line), = val
|
|
3069
|
-
result = Sexp === var ? var : self.gettable(var)
|
|
3070
|
-
|
|
3071
|
-
result.line line
|
|
3072
|
-
}
|
|
3073
3237
|
| keyword_variable
|
|
3074
|
-
{
|
|
3075
|
-
var = val[0]
|
|
3076
|
-
result = Sexp === var ? var : self.gettable(var)
|
|
3077
|
-
}
|
|
3078
3238
|
|
|
3079
3239
|
var_lhs: user_variable
|
|
3080
3240
|
{
|
|
@@ -3123,7 +3283,7 @@ f_opt_paren_args: f_paren_args
|
|
|
3123
3283
|
self.in_argdef = false
|
|
3124
3284
|
result = end_args val
|
|
3125
3285
|
}
|
|
3126
|
-
#if V
|
|
3286
|
+
#if V < 31
|
|
3127
3287
|
| tLPAREN2 f_arg tCOMMA args_forward rparen
|
|
3128
3288
|
{
|
|
3129
3289
|
result = end_args val
|
|
@@ -3264,6 +3424,7 @@ f_opt_paren_args: f_paren_args
|
|
|
3264
3424
|
identifier = id.to_sym
|
|
3265
3425
|
self.env[identifier] = :lvar
|
|
3266
3426
|
|
|
3427
|
+
# TODO: result = s(:args, identifier).line line
|
|
3267
3428
|
result = [identifier, line]
|
|
3268
3429
|
}
|
|
3269
3430
|
|
|
@@ -3371,10 +3532,10 @@ f_opt_paren_args: f_paren_args
|
|
|
3371
3532
|
kwrest_mark: tPOW
|
|
3372
3533
|
| tDSTAR
|
|
3373
3534
|
|
|
3374
|
-
f_no_kwarg:
|
|
3535
|
+
f_no_kwarg: p_kwnorest
|
|
3375
3536
|
{
|
|
3376
|
-
|
|
3377
|
-
result = [:"**nil", line]
|
|
3537
|
+
sexp, _ = val
|
|
3538
|
+
result = [:"**nil", sexp.line] # HACK!
|
|
3378
3539
|
}
|
|
3379
3540
|
|
|
3380
3541
|
f_kwrest: kwrest_mark tIDENTIFIER
|
|
@@ -3382,7 +3543,7 @@ f_opt_paren_args: f_paren_args
|
|
|
3382
3543
|
_, (id, line) = val
|
|
3383
3544
|
|
|
3384
3545
|
name = id.to_sym
|
|
3385
|
-
self.assignable [name, line]
|
|
3546
|
+
self.assignable s(:bogus, name).line line # [name, line]
|
|
3386
3547
|
result = [:"**#{name}", line]
|
|
3387
3548
|
}
|
|
3388
3549
|
| kwrest_mark
|
|
@@ -3394,31 +3555,31 @@ f_opt_paren_args: f_paren_args
|
|
|
3394
3555
|
}
|
|
3395
3556
|
|
|
3396
3557
|
f_opt: f_arg_asgn
|
|
3397
|
-
#if V
|
|
3398
|
-
f_eq
|
|
3399
|
-
#else
|
|
3558
|
+
#if V < 31
|
|
3400
3559
|
tEQL
|
|
3560
|
+
#else
|
|
3561
|
+
f_eq
|
|
3401
3562
|
#endif
|
|
3402
3563
|
arg_value
|
|
3403
3564
|
{
|
|
3404
3565
|
lhs, _, rhs = val
|
|
3405
3566
|
self.in_argdef = true
|
|
3406
|
-
result = self.
|
|
3567
|
+
result = self.old_assignable lhs, rhs
|
|
3407
3568
|
# TODO: detect duplicate names
|
|
3408
3569
|
# TODO? p->cur_arg = 0;
|
|
3409
3570
|
}
|
|
3410
3571
|
|
|
3411
3572
|
f_block_opt: f_arg_asgn
|
|
3412
|
-
#if V
|
|
3413
|
-
f_eq
|
|
3414
|
-
#else
|
|
3573
|
+
#if V < 31
|
|
3415
3574
|
tEQL
|
|
3575
|
+
#else
|
|
3576
|
+
f_eq
|
|
3416
3577
|
#endif
|
|
3417
3578
|
primary_value
|
|
3418
3579
|
{
|
|
3419
3580
|
lhs, _, rhs = val
|
|
3420
3581
|
self.in_argdef = true
|
|
3421
|
-
result = self.
|
|
3582
|
+
result = self.old_assignable lhs, rhs
|
|
3422
3583
|
# TODO? p->cur_arg = 0;
|
|
3423
3584
|
}
|
|
3424
3585
|
|
|
@@ -3451,7 +3612,7 @@ f_opt_paren_args: f_paren_args
|
|
|
3451
3612
|
# TODO: differs from parse.y - needs tests
|
|
3452
3613
|
_, (id, line) = val
|
|
3453
3614
|
name = id.to_sym
|
|
3454
|
-
self.assignable
|
|
3615
|
+
self.assignable s(:lvar, name).line(line)
|
|
3455
3616
|
result = [:"*#{name}", line]
|
|
3456
3617
|
}
|
|
3457
3618
|
| restarg_mark
|
|
@@ -3559,7 +3720,7 @@ f_opt_paren_args: f_paren_args
|
|
|
3559
3720
|
#endif
|
|
3560
3721
|
|
|
3561
3722
|
operation: tIDENTIFIER | tCONSTANT | tFID
|
|
3562
|
-
operation2:
|
|
3723
|
+
operation2: operation | op
|
|
3563
3724
|
operation3: tIDENTIFIER | tFID | op
|
|
3564
3725
|
dot_or_colon: tDOT | tCOLON2
|
|
3565
3726
|
call_op: tDOT
|
|
@@ -3585,7 +3746,7 @@ f_opt_paren_args: f_paren_args
|
|
|
3585
3746
|
_, close = val
|
|
3586
3747
|
result = [close, lexer.lineno]
|
|
3587
3748
|
}
|
|
3588
|
-
trailer:
|
|
3749
|
+
trailer: opt_nl | tCOMMA
|
|
3589
3750
|
|
|
3590
3751
|
term: tSEMI { yyerrok }
|
|
3591
3752
|
| tNL
|