racc 1.5.2 → 1.6.0

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