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