| 126 |
126 |
static int command_start = Qtrue;
|
| 127 |
127 |
|
| 128 |
128 |
static NODE *deferred_nodes;
|
|
129 |
static NODE *NEW_POSTARG();
|
|
130 |
|
|
131 |
static NODE *new_args();
|
| 129 |
132 |
|
| 130 |
133 |
static NODE *cond();
|
| 131 |
134 |
static NODE *logop();
|
| ... | ... | |
| 144 |
147 |
static NODE *block_append();
|
| 145 |
148 |
static NODE *list_append();
|
| 146 |
149 |
static NODE *list_concat();
|
|
150 |
static NODE *arg_append();
|
| 147 |
151 |
static NODE *arg_concat();
|
| 148 |
152 |
static NODE *arg_prepend();
|
| 149 |
153 |
static NODE *literal_concat();
|
| 150 |
154 |
static NODE *new_evstr();
|
| 151 |
155 |
static NODE *evstr2dstr();
|
|
156 |
static NODE *splat_array();
|
| 152 |
157 |
static NODE *call_op();
|
| 153 |
158 |
static int in_defined = 0;
|
| 154 |
159 |
|
| ... | ... | |
| 280 |
285 |
%type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
|
| 281 |
286 |
%type <node> expr_value arg_value primary_value
|
| 282 |
287 |
%type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
|
| 283 |
|
%type <node> args when_args call_args call_args2 open_args paren_args opt_paren_args
|
|
288 |
%type <node> args args2 call_args call_args2 opt_call_args
|
|
289 |
%type <node> open_args paren_args opt_paren_args
|
| 284 |
290 |
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
|
| 285 |
291 |
%type <node> mrhs superclass block_call block_command
|
| 286 |
292 |
%type <node> f_arglist f_args f_optarg f_opt f_rest_arg f_block_arg opt_f_block_arg
|
| 287 |
293 |
%type <node> assoc_list assocs assoc undef_list backref string_dvar
|
| 288 |
294 |
%type <node> for_var block_var opt_block_var block_par
|
| 289 |
295 |
%type <node> brace_block cmd_brace_block do_block lhs none fitem
|
| 290 |
|
%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
|
|
296 |
%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node mlhs_post
|
| 291 |
297 |
%type <id> fsym variable sym symbol operation operation2 operation3
|
| 292 |
298 |
%type <id> cname fname op
|
| 293 |
299 |
%type <num> f_norm_arg f_arg
|
| ... | ... | |
| 547 |
553 |
$$ = 0;
|
| 548 |
554 |
}
|
| 549 |
555 |
}
|
| 550 |
|
| primary_value '[' aref_args ']' tOP_ASGN command_call
|
|
556 |
| primary_value '[' opt_call_args ']' tOP_ASGN command_call
|
| 551 |
557 |
{
|
| 552 |
|
NODE *args;
|
|
558 |
NODE *args = $3;
|
| 553 |
559 |
|
| 554 |
560 |
value_expr($6);
|
| 555 |
|
if (!$3) $3 = NEW_ZARRAY();
|
| 556 |
561 |
args = arg_concat($6, $3);
|
| 557 |
562 |
if ($5 == tOROP) {
|
| 558 |
563 |
$5 = 0;
|
| ... | ... | |
| 769 |
774 |
|
| 770 |
775 |
mlhs_basic : mlhs_head
|
| 771 |
776 |
{
|
|
777 |
/*%%%*/
|
| 772 |
778 |
$$ = NEW_MASGN($1, 0);
|
|
779 |
/*%
|
|
780 |
$$ = $1;
|
|
781 |
%*/
|
| 773 |
782 |
}
|
| 774 |
783 |
| mlhs_head mlhs_item
|
| 775 |
784 |
{
|
|
785 |
/*%%%*/
|
| 776 |
786 |
$$ = NEW_MASGN(list_append($1,$2), 0);
|
|
787 |
/*%
|
|
788 |
$$ = mlhs_add($1, $2);
|
|
789 |
%*/
|
| 777 |
790 |
}
|
| 778 |
791 |
| mlhs_head tSTAR mlhs_node
|
| 779 |
792 |
{
|
|
793 |
/*%%%*/
|
| 780 |
794 |
$$ = NEW_MASGN($1, $3);
|
|
795 |
/*%
|
|
796 |
$$ = mlhs_add_star($1, $3);
|
|
797 |
%*/
|
|
798 |
}
|
|
799 |
| mlhs_head tSTAR mlhs_node ',' mlhs_post
|
|
800 |
{
|
|
801 |
/*%%%*/
|
|
802 |
$$ = NEW_MASGN($1, NEW_POSTARG($3,$5));
|
|
803 |
/*%
|
|
804 |
$$ = mlhs_add_star($1, $3);
|
|
805 |
%*/
|
| 781 |
806 |
}
|
| 782 |
807 |
| mlhs_head tSTAR
|
| 783 |
808 |
{
|
|
809 |
/*%%%*/
|
| 784 |
810 |
$$ = NEW_MASGN($1, -1);
|
|
811 |
/*%
|
|
812 |
$$ = mlhs_add_star($1, Qnil);
|
|
813 |
%*/
|
|
814 |
}
|
|
815 |
| mlhs_head tSTAR ',' mlhs_post
|
|
816 |
{
|
|
817 |
/*%%%*/
|
|
818 |
$$ = NEW_MASGN($1, NEW_POSTARG(-1, $4));
|
|
819 |
/*%
|
|
820 |
$$ = mlhs_add_star($1, Qnil);
|
|
821 |
%*/
|
| 785 |
822 |
}
|
| 786 |
823 |
| tSTAR mlhs_node
|
| 787 |
824 |
{
|
|
825 |
/*%%%*/
|
| 788 |
826 |
$$ = NEW_MASGN(0, $2);
|
|
827 |
/*%
|
|
828 |
$$ = mlhs_add_star(mlhs_new(), $2);
|
|
829 |
%*/
|
|
830 |
}
|
|
831 |
| tSTAR mlhs_node ',' mlhs_post
|
|
832 |
{
|
|
833 |
/*%%%*/
|
|
834 |
$$ = NEW_MASGN(0, NEW_POSTARG($2,$4));
|
|
835 |
/*%
|
|
836 |
$$ = mlhs_add_star(mlhs_new(), $2);
|
|
837 |
%*/
|
| 789 |
838 |
}
|
| 790 |
839 |
| tSTAR
|
| 791 |
840 |
{
|
|
841 |
/*%%%*/
|
| 792 |
842 |
$$ = NEW_MASGN(0, -1);
|
|
843 |
/*%
|
|
844 |
$$ = mlhs_add_star(mlhs_new(), Qnil);
|
|
845 |
%*/
|
|
846 |
}
|
|
847 |
| tSTAR ',' mlhs_post
|
|
848 |
{
|
|
849 |
/*%%%*/
|
|
850 |
$$ = NEW_MASGN(0, NEW_POSTARG(-1, $3));
|
|
851 |
/*%
|
|
852 |
$$ = mlhs_add_star(mlhs_new(), Qnil);
|
|
853 |
%*/
|
| 793 |
854 |
}
|
| 794 |
855 |
;
|
| 795 |
856 |
|
| ... | ... | |
| 810 |
871 |
}
|
| 811 |
872 |
;
|
| 812 |
873 |
|
|
874 |
mlhs_post : mlhs_item
|
|
875 |
{
|
|
876 |
/*%%%*/
|
|
877 |
$$ = NEW_LIST($1);
|
|
878 |
/*%
|
|
879 |
$$ = mlhs_add(mlhs_new(), $1);
|
|
880 |
%*/
|
|
881 |
}
|
|
882 |
| mlhs_post ',' mlhs_item
|
|
883 |
{
|
|
884 |
/*%%%*/
|
|
885 |
$$ = list_append($1, $3);
|
|
886 |
/*%
|
|
887 |
$$ = mlhs_add($1, $3);
|
|
888 |
%*/
|
|
889 |
}
|
|
890 |
;
|
|
891 |
|
| 813 |
892 |
mlhs_node : variable
|
| 814 |
893 |
{
|
| 815 |
894 |
$$ = assignable($1, 0);
|
| 816 |
895 |
}
|
| 817 |
|
| primary_value '[' aref_args ']'
|
|
896 |
| primary_value '[' opt_call_args ']'
|
| 818 |
897 |
{
|
| 819 |
898 |
$$ = aryset($1, $3);
|
| 820 |
899 |
}
|
| ... | ... | |
| 853 |
932 |
{
|
| 854 |
933 |
$$ = assignable($1, 0);
|
| 855 |
934 |
}
|
| 856 |
|
| primary_value '[' aref_args ']'
|
|
935 |
| primary_value '[' opt_call_args ']'
|
| 857 |
936 |
{
|
| 858 |
937 |
$$ = aryset($1, $3);
|
| 859 |
938 |
}
|
| ... | ... | |
| 1015 |
1094 |
$$ = 0;
|
| 1016 |
1095 |
}
|
| 1017 |
1096 |
}
|
| 1018 |
|
| primary_value '[' aref_args ']' tOP_ASGN arg
|
|
1097 |
| primary_value '[' opt_call_args ']' tOP_ASGN arg
|
| 1019 |
1098 |
{
|
| 1020 |
1099 |
NODE *args;
|
| 1021 |
1100 |
|
| ... | ... | |
| 1247 |
1326 |
;
|
| 1248 |
1327 |
|
| 1249 |
1328 |
aref_args : none
|
| 1250 |
|
| command opt_nl
|
| 1251 |
|
{
|
| 1252 |
|
$$ = NEW_LIST($1);
|
| 1253 |
|
}
|
| 1254 |
1329 |
| args trailer
|
| 1255 |
1330 |
{
|
| 1256 |
1331 |
$$ = $1;
|
| 1257 |
1332 |
}
|
| 1258 |
|
| args ',' tSTAR arg opt_nl
|
|
1333 |
| args ',' assocs trailer
|
| 1259 |
1334 |
{
|
| 1260 |
|
value_expr($4);
|
| 1261 |
|
$$ = arg_concat($1, $4);
|
|
1335 |
/*%%%*/
|
|
1336 |
$$ = arg_append($1, NEW_HASH($3));
|
|
1337 |
/*%
|
|
1338 |
$$ = arg_add_assocs($1, $3);
|
|
1339 |
%*/
|
| 1262 |
1340 |
}
|
| 1263 |
1341 |
| assocs trailer
|
| 1264 |
1342 |
{
|
| 1265 |
1343 |
$$ = NEW_LIST(NEW_HASH($1));
|
| 1266 |
1344 |
}
|
| 1267 |
|
| tSTAR arg opt_nl
|
| 1268 |
|
{
|
| 1269 |
|
value_expr($2);
|
| 1270 |
|
$$ = NEW_NEWLINE(NEW_SPLAT($2));
|
| 1271 |
|
}
|
| 1272 |
1345 |
;
|
| 1273 |
1346 |
|
| 1274 |
|
paren_args : '(' none ')'
|
|
1347 |
paren_args : '(' opt_call_args ')'
|
| 1275 |
1348 |
{
|
| 1276 |
1349 |
$$ = $2;
|
| 1277 |
1350 |
}
|
| 1278 |
|
| '(' call_args opt_nl ')'
|
| 1279 |
|
{
|
| 1280 |
|
$$ = $2;
|
| 1281 |
|
}
|
| 1282 |
|
| '(' block_call opt_nl ')'
|
| 1283 |
|
{
|
| 1284 |
|
$$ = NEW_LIST($2);
|
| 1285 |
|
}
|
| 1286 |
|
| '(' args ',' block_call opt_nl ')'
|
| 1287 |
|
{
|
| 1288 |
|
$$ = list_append($2, $4);
|
| 1289 |
|
}
|
| 1290 |
1351 |
;
|
| 1291 |
1352 |
|
| 1292 |
1353 |
opt_paren_args : none
|
| 1293 |
1354 |
| paren_args
|
| 1294 |
1355 |
;
|
| 1295 |
1356 |
|
|
1357 |
opt_call_args : opt_nl
|
|
1358 |
{
|
|
1359 |
$$ = 0;
|
|
1360 |
}
|
|
1361 |
| call_args opt_nl
|
|
1362 |
{
|
|
1363 |
$$ = $1;
|
|
1364 |
}
|
|
1365 |
;
|
|
1366 |
|
| 1296 |
1367 |
call_args : command
|
| 1297 |
1368 |
{
|
| 1298 |
1369 |
$$ = NEW_LIST($1);
|
| 1299 |
1370 |
}
|
| 1300 |
|
| args opt_block_arg
|
|
1371 |
| args2 opt_block_arg
|
| 1301 |
1372 |
{
|
| 1302 |
1373 |
$$ = arg_blk_pass($1, $2);
|
| 1303 |
1374 |
}
|
| 1304 |
|
| args ',' tSTAR arg_value opt_block_arg
|
| 1305 |
|
{
|
| 1306 |
|
$$ = arg_concat($1, $4);
|
| 1307 |
|
$$ = arg_blk_pass($$, $5);
|
| 1308 |
|
}
|
| 1309 |
1375 |
| assocs opt_block_arg
|
| 1310 |
1376 |
{
|
| 1311 |
1377 |
$$ = NEW_LIST(NEW_HASH($1));
|
| 1312 |
1378 |
$$ = arg_blk_pass($$, $2);
|
| 1313 |
1379 |
}
|
| 1314 |
|
| assocs ',' tSTAR arg_value opt_block_arg
|
| 1315 |
|
{
|
| 1316 |
|
$$ = arg_concat(NEW_LIST(NEW_HASH($1)), $4);
|
| 1317 |
|
$$ = arg_blk_pass($$, $5);
|
| 1318 |
|
}
|
| 1319 |
|
| args ',' assocs opt_block_arg
|
|
1380 |
| args2 ',' assocs opt_block_arg
|
| 1320 |
1381 |
{
|
| 1321 |
1382 |
$$ = list_append($1, NEW_HASH($3));
|
| 1322 |
1383 |
$$ = arg_blk_pass($$, $4);
|
| 1323 |
1384 |
}
|
| 1324 |
|
| args ',' assocs ',' tSTAR arg opt_block_arg
|
| 1325 |
|
{
|
| 1326 |
|
value_expr($6);
|
| 1327 |
|
$$ = arg_concat(list_append($1, NEW_HASH($3)), $6);
|
| 1328 |
|
$$ = arg_blk_pass($$, $7);
|
| 1329 |
|
}
|
| 1330 |
|
| tSTAR arg_value opt_block_arg
|
| 1331 |
|
{
|
| 1332 |
|
$$ = arg_blk_pass(NEW_SPLAT($2), $3);
|
| 1333 |
|
}
|
| 1334 |
1385 |
| block_arg
|
| 1335 |
1386 |
;
|
| 1336 |
1387 |
|
| ... | ... | |
| 1342 |
1393 |
{
|
| 1343 |
1394 |
$$ = arg_blk_pass($1, $3);
|
| 1344 |
1395 |
}
|
| 1345 |
|
| arg_value ',' tSTAR arg_value opt_block_arg
|
| 1346 |
|
{
|
| 1347 |
|
$$ = arg_concat(NEW_LIST($1), $4);
|
| 1348 |
|
$$ = arg_blk_pass($$, $5);
|
| 1349 |
|
}
|
| 1350 |
|
| arg_value ',' args ',' tSTAR arg_value opt_block_arg
|
| 1351 |
|
{
|
| 1352 |
|
$$ = arg_concat(list_concat(NEW_LIST($1),$3), $6);
|
| 1353 |
|
$$ = arg_blk_pass($$, $7);
|
| 1354 |
|
}
|
| 1355 |
1396 |
| assocs opt_block_arg
|
| 1356 |
1397 |
{
|
| 1357 |
1398 |
$$ = NEW_LIST(NEW_HASH($1));
|
| 1358 |
1399 |
$$ = arg_blk_pass($$, $2);
|
| 1359 |
1400 |
}
|
| 1360 |
|
| assocs ',' tSTAR arg_value opt_block_arg
|
| 1361 |
|
{
|
| 1362 |
|
$$ = arg_concat(NEW_LIST(NEW_HASH($1)), $4);
|
| 1363 |
|
$$ = arg_blk_pass($$, $5);
|
| 1364 |
|
}
|
| 1365 |
1401 |
| arg_value ',' assocs opt_block_arg
|
| 1366 |
1402 |
{
|
| 1367 |
1403 |
$$ = list_append(NEW_LIST($1), NEW_HASH($3));
|
| ... | ... | |
| 1372 |
1408 |
$$ = list_append(list_concat(NEW_LIST($1),$3), NEW_HASH($5));
|
| 1373 |
1409 |
$$ = arg_blk_pass($$, $6);
|
| 1374 |
1410 |
}
|
| 1375 |
|
| arg_value ',' assocs ',' tSTAR arg_value opt_block_arg
|
| 1376 |
|
{
|
| 1377 |
|
$$ = arg_concat(list_append(NEW_LIST($1), NEW_HASH($3)), $6);
|
| 1378 |
|
$$ = arg_blk_pass($$, $7);
|
| 1379 |
|
}
|
| 1380 |
|
| arg_value ',' args ',' assocs ',' tSTAR arg_value opt_block_arg
|
| 1381 |
|
{
|
| 1382 |
|
$$ = arg_concat(list_append(list_concat(NEW_LIST($1), $3), NEW_HASH($5)), $8);
|
| 1383 |
|
$$ = arg_blk_pass($$, $9);
|
| 1384 |
|
}
|
| 1385 |
|
| tSTAR arg_value opt_block_arg
|
| 1386 |
|
{
|
| 1387 |
|
$$ = arg_blk_pass(NEW_SPLAT($2), $3);
|
| 1388 |
|
}
|
| 1389 |
1411 |
| block_arg
|
| 1390 |
1412 |
;
|
| 1391 |
1413 |
|
| ... | ... | |
| 1427 |
1449 |
| none
|
| 1428 |
1450 |
;
|
| 1429 |
1451 |
|
| 1430 |
|
args : arg_value
|
|
1452 |
args : arg_value
|
| 1431 |
1453 |
{
|
| 1432 |
1454 |
$$ = NEW_LIST($1);
|
| 1433 |
1455 |
}
|
|
1456 |
| tSTAR arg_value
|
|
1457 |
{
|
|
1458 |
/*%%%*/
|
|
1459 |
$$ = NEW_TO_ARY($2);
|
|
1460 |
/*%
|
|
1461 |
$$ = arg_add_star(arg_new(), $2);
|
|
1462 |
%*/
|
|
1463 |
}
|
| 1434 |
1464 |
| args ',' arg_value
|
| 1435 |
1465 |
{
|
| 1436 |
1466 |
$$ = list_append($1, $3);
|
| 1437 |
1467 |
}
|
|
1468 |
| args ',' tSTAR arg_value
|
|
1469 |
{
|
|
1470 |
/*%%%*/
|
|
1471 |
NODE *n1;
|
|
1472 |
if ((nd_type($4) == NODE_ARRAY) && (n1 = splat_array($1)) != 0) {
|
|
1473 |
$$ = list_concat(n1, $4);
|
|
1474 |
}
|
|
1475 |
else {
|
|
1476 |
$$ = arg_concat($1, $4);
|
|
1477 |
}
|
|
1478 |
/*%
|
|
1479 |
$$ = arg_add_star($1, $4);
|
|
1480 |
%*/
|
|
1481 |
}
|
|
1482 |
;
|
|
1483 |
|
|
1484 |
args2 : arg_value
|
|
1485 |
{
|
|
1486 |
$$ = NEW_LIST($1);
|
|
1487 |
}
|
|
1488 |
| tSTAR arg_value
|
|
1489 |
{
|
|
1490 |
/*%%%*/
|
|
1491 |
$$ = NEW_SPLAT($2);
|
|
1492 |
/*%
|
|
1493 |
$$ = arg_add_star(arg_new(), $2);
|
|
1494 |
%*/
|
|
1495 |
}
|
|
1496 |
| args2 ',' arg_value
|
|
1497 |
{
|
|
1498 |
$$ = list_append($1, $3);
|
|
1499 |
}
|
|
1500 |
| args2 ',' tSTAR arg_value
|
|
1501 |
{
|
|
1502 |
/*%%%*/
|
|
1503 |
NODE *n1;
|
|
1504 |
if ((nd_type($4) == NODE_ARRAY) && (n1 = splat_array($1)) != 0) {
|
|
1505 |
$$ = list_concat(n1, $4);
|
|
1506 |
}
|
|
1507 |
else {
|
|
1508 |
$$ = arg_concat($1, $4);
|
|
1509 |
}
|
|
1510 |
/*%
|
|
1511 |
$$ = arg_add_star($1, $4);
|
|
1512 |
%*/
|
|
1513 |
}
|
| 1438 |
1514 |
;
|
| 1439 |
1515 |
|
| 1440 |
1516 |
mrhs : args ',' arg_value
|
| ... | ... | |
| 1494 |
1570 |
{
|
| 1495 |
1571 |
$$ = NEW_COLON3($2);
|
| 1496 |
1572 |
}
|
| 1497 |
|
| primary_value '[' aref_args ']'
|
| 1498 |
|
{
|
| 1499 |
|
if ($1 && nd_type($1) == NODE_SELF)
|
| 1500 |
|
$$ = NEW_FCALL(tAREF, $3);
|
| 1501 |
|
else
|
| 1502 |
|
$$ = NEW_CALL($1, tAREF, $3);
|
| 1503 |
|
fixpos($$, $1);
|
| 1504 |
|
}
|
| 1505 |
1573 |
| tLBRACK aref_args ']'
|
| 1506 |
1574 |
{
|
| 1507 |
1575 |
if ($2 == 0) {
|
| ... | ... | |
| 1909 |
1977 |
{
|
| 1910 |
1978 |
$$ = NEW_ZSUPER();
|
| 1911 |
1979 |
}
|
|
1980 |
| primary_value '[' opt_call_args ']'
|
|
1981 |
{
|
|
1982 |
/*%%%*/
|
|
1983 |
if ($1 && nd_type($1) == NODE_SELF)
|
|
1984 |
$$ = NEW_FCALL(tAREF, $3);
|
|
1985 |
else
|
|
1986 |
$$ = NEW_CALL($1, tAREF, $3);
|
|
1987 |
fixpos($$, $1);
|
|
1988 |
/*%
|
|
1989 |
$$ = dispatch2(aref, $1, escape_Qundef($3));
|
|
1990 |
%*/
|
|
1991 |
}
|
| 1912 |
1992 |
;
|
| 1913 |
1993 |
|
| 1914 |
1994 |
brace_block : '{'
|
| ... | ... | |
| 1937 |
2017 |
}
|
| 1938 |
2018 |
;
|
| 1939 |
2019 |
|
| 1940 |
|
case_body : kWHEN when_args then
|
|
2020 |
case_body : kWHEN args then
|
| 1941 |
2021 |
compstmt
|
| 1942 |
2022 |
cases
|
| 1943 |
2023 |
{
|
| 1944 |
2024 |
$$ = NEW_WHEN($2, $4, $5);
|
| 1945 |
2025 |
}
|
| 1946 |
2026 |
;
|
| 1947 |
|
when_args : args
|
| 1948 |
|
| args ',' tSTAR arg_value
|
| 1949 |
|
{
|
| 1950 |
|
$$ = list_append($1, NEW_WHEN($4, 0, 0));
|
| 1951 |
|
}
|
| 1952 |
|
| tSTAR arg_value
|
| 1953 |
|
{
|
| 1954 |
|
$$ = NEW_LIST(NEW_WHEN($2, 0, 0));
|
| 1955 |
|
}
|
| 1956 |
|
;
|
| 1957 |
2027 |
|
| 1958 |
2028 |
cases : opt_else
|
| 1959 |
2029 |
| case_body
|
| ... | ... | |
| 2312 |
2382 |
|
| 2313 |
2383 |
f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
|
| 2314 |
2384 |
{
|
| 2315 |
|
$$ = block_append(NEW_ARGS($1, $3, $5), $6);
|
|
2385 |
/*%%%*/
|
|
2386 |
$$ = new_args($1, $3, $5, 0, $6);
|
|
2387 |
/*%
|
|
2388 |
$$ = params_new($1, $3, $5, Qnil, escape_Qundef($6));
|
|
2389 |
%*/
|
|
2390 |
}
|
|
2391 |
| f_arg ',' f_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
|
|
2392 |
{
|
|
2393 |
/*%%%*/
|
|
2394 |
$$ = new_args($1, $3, $5, $7, $8);
|
|
2395 |
/*%
|
|
2396 |
$$ = params_new($1, $3, $5, $7, escape_Qundef($8));
|
|
2397 |
%*/
|
| 2316 |
2398 |
}
|
| 2317 |
2399 |
| f_arg ',' f_optarg opt_f_block_arg
|
| 2318 |
2400 |
{
|
| 2319 |
|
$$ = block_append(NEW_ARGS($1, $3, 0), $4);
|
|
2401 |
/*%%%*/
|
|
2402 |
$$ = new_args($1, $3, 0, 0, $4);
|
|
2403 |
/*%
|
|
2404 |
$$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4));
|
|
2405 |
%*/
|
|
2406 |
}
|
|
2407 |
| f_arg ',' f_optarg ',' f_arg opt_f_block_arg
|
|
2408 |
{
|
|
2409 |
/*%%%*/
|
|
2410 |
$$ = new_args($1, $3, 0, $5, $6);
|
|
2411 |
/*%
|
|
2412 |
$$ = params_new($1, $3, Qnil, $5, escape_Qundef($6));
|
|
2413 |
%*/
|
| 2320 |
2414 |
}
|
| 2321 |
2415 |
| f_arg ',' f_rest_arg opt_f_block_arg
|
| 2322 |
2416 |
{
|
| 2323 |
|
$$ = block_append(NEW_ARGS($1, 0, $3), $4);
|
|
2417 |
/*%%%*/
|
|
2418 |
$$ = new_args($1, 0, $3, 0, $4);
|
|
2419 |
/*%
|
|
2420 |
$$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4));
|
|
2421 |
%*/
|
|
2422 |
}
|
|
2423 |
| f_arg ',' f_rest_arg ',' f_arg opt_f_block_arg
|
|
2424 |
{
|
|
2425 |
/*%%%*/
|
|
2426 |
$$ = new_args($1, 0, $3, $5, $6);
|
|
2427 |
/*%
|
|
2428 |
$$ = params_new($1, Qnil, $3, $5, escape_Qundef($6));
|
|
2429 |
%*/
|
| 2324 |
2430 |
}
|
| 2325 |
2431 |
| f_arg opt_f_block_arg
|
| 2326 |
2432 |
{
|
| 2327 |
|
$$ = block_append(NEW_ARGS($1, 0, 0), $2);
|
|
2433 |
/*%%%*/
|
|
2434 |
$$ = new_args($1, 0, 0, 0, $2);
|
|
2435 |
/*%
|
|
2436 |
$$ = params_new($1, Qnil, Qnil, Qnil,escape_Qundef($2));
|
|
2437 |
%*/
|
| 2328 |
2438 |
}
|
| 2329 |
2439 |
| f_optarg ',' f_rest_arg opt_f_block_arg
|
| 2330 |
2440 |
{
|
| 2331 |
|
$$ = block_append(NEW_ARGS(0, $1, $3), $4);
|
|
2441 |
/*%%%*/
|
|
2442 |
$$ = new_args(0, $1, $3, 0, $4);
|
|
2443 |
/*%
|
|
2444 |
$$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4));
|
|
2445 |
%*/
|
|
2446 |
}
|
|
2447 |
| f_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
|
|
2448 |
{
|
|
2449 |
/*%%%*/
|
|
2450 |
$$ = new_args(0, $1, $3, $5, $6);
|
|
2451 |
/*%
|
|
2452 |
$$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6));
|
|
2453 |
%*/
|
| 2332 |
2454 |
}
|
| 2333 |
2455 |
| f_optarg opt_f_block_arg
|
| 2334 |
2456 |
{
|
| 2335 |
|
$$ = block_append(NEW_ARGS(0, $1, 0), $2);
|
|
2457 |
/*%%%*/
|
|
2458 |
$$ = new_args(0, $1, 0, 0, $2);
|
|
2459 |
/*%
|
|
2460 |
$$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2));
|
|
2461 |
%*/
|
|
2462 |
}
|
|
2463 |
| f_optarg ',' f_arg opt_f_block_arg
|
|
2464 |
{
|
|
2465 |
/*%%%*/
|
|
2466 |
$$ = new_args(0, $1, 0, $3, $4);
|
|
2467 |
/*%
|
|
2468 |
$$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4));
|
|
2469 |
%*/
|
| 2336 |
2470 |
}
|
| 2337 |
2471 |
| f_rest_arg opt_f_block_arg
|
| 2338 |
2472 |
{
|
| 2339 |
|
$$ = block_append(NEW_ARGS(0, 0, $1), $2);
|
|
2473 |
/*%%%*/
|
|
2474 |
$$ = new_args(0, 0, $1, 0, $2);
|
|
2475 |
/*%
|
|
2476 |
$$ = params_new(Qnil, Qnil, $1, Qnil,escape_Qundef($2));
|
|
2477 |
%*/
|
|
2478 |
}
|
|
2479 |
| f_rest_arg ',' f_arg opt_f_block_arg
|
|
2480 |
{
|
|
2481 |
/*%%%*/
|
|
2482 |
$$ = new_args(0, 0, $1, $3, $4);
|
|
2483 |
/*%
|
|
2484 |
$$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4));
|
|
2485 |
%*/
|
| 2340 |
2486 |
}
|
| 2341 |
2487 |
| f_block_arg
|
| 2342 |
2488 |
{
|
| 2343 |
|
$$ = block_append(NEW_ARGS(0, 0, 0), $1);
|
|
2489 |
/*%%%*/
|
|
2490 |
$$ = new_args(0, 0, 0, 0, $1);
|
|
2491 |
/*%
|
|
2492 |
$$ = params_new(Qnil, Qnil, Qnil, Qnil, $1);
|
|
2493 |
%*/
|
| 2344 |
2494 |
}
|
| 2345 |
2495 |
| /* none */
|
| 2346 |
2496 |
{
|
| 2347 |
|
$$ = NEW_ARGS(0, 0, 0);
|
|
2497 |
/*%%%*/
|
|
2498 |
$$ = new_args(0, 0, 0, 0, 0);
|
|
2499 |
/*%
|
|
2500 |
$$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil);
|
|
2501 |
%*/
|
| 2348 |
2502 |
}
|
| 2349 |
2503 |
;
|
| 2350 |
2504 |
|
| ... | ... | |
| 4846 |
5000 |
return head;
|
| 4847 |
5001 |
}
|
| 4848 |
5002 |
|
|
5003 |
static NODE*
|
|
5004 |
new_args(m, o, r, p, b)
|
|
5005 |
NODE *m, *o, *p, *b;
|
|
5006 |
ID r;
|
|
5007 |
{
|
|
5008 |
if (p) {
|
|
5009 |
ID i = rb_intern("raise");
|
|
5010 |
VALUE e = rb_eSyntaxError; /* or maybe a subclass of it? */
|
|
5011 |
VALUE s = rb_str_new2("Unsupported 1.9-ism: loose formal opt/rest args");
|
|
5012 |
NODE *n = NEW_FCALL(i, list_append(NEW_LIST(NEW_LIT(e)), NEW_LIT(s)));
|
|
5013 |
NODE *b = NEW_BLOCK(n);
|
|
5014 |
b->nd_end = b;
|
|
5015 |
return b;
|
|
5016 |
}
|
|
5017 |
return block_append(NEW_ARGS(m, o, r), b);
|
|
5018 |
}
|
|
5019 |
|
| 4849 |
5020 |
static NODE *
|
| 4850 |
5021 |
evstr2dstr(node)
|
| 4851 |
5022 |
NODE *node;
|
| ... | ... | |
| 4875 |
5046 |
return NEW_EVSTR(head);
|
| 4876 |
5047 |
}
|
| 4877 |
5048 |
|
|
5049 |
static VALUE
|
|
5050 |
new_postarg_internal_raise(argc, argv)
|
|
5051 |
int argc;
|
|
5052 |
VALUE *argv;
|
|
5053 |
{
|
|
5054 |
rb_raise(rb_eSyntaxError, "Unsupported 1.9-ism: loose multiple assignment (LHS)");
|
|
5055 |
return Qundef; /* NOTREACHED */
|
|
5056 |
}
|
|
5057 |
|
|
5058 |
static NODE *
|
|
5059 |
NEW_POSTARG(n1, n2)
|
|
5060 |
NODE *n1, *n2;
|
|
5061 |
{
|
|
5062 |
VALUE obj = rb_obj_alloc(rb_cObject);
|
|
5063 |
rb_define_singleton_method(obj, "raise", new_postarg_internal_raise, -1);
|
|
5064 |
return NEW_CALL(NEW_LIT(obj), rb_intern("raise"), NEW_LIST(0));
|
|
5065 |
}
|
|
5066 |
|
| 4878 |
5067 |
static NODE *
|
| 4879 |
5068 |
call_op(recv, id, narg, arg1)
|
| 4880 |
5069 |
NODE *recv;
|
| ... | ... | |
| 5089 |
5278 |
}
|
| 5090 |
5279 |
|
| 5091 |
5280 |
static NODE *
|
|
5281 |
arg_append(node1, node2)
|
|
5282 |
NODE *node1;
|
|
5283 |
NODE *node2;
|
|
5284 |
{
|
|
5285 |
if (!node1) return NEW_LIST(node2);
|
|
5286 |
return NEW_ARGSPUSH(node1, node2);
|
|
5287 |
}
|
|
5288 |
|
|
5289 |
static NODE *
|
| 5092 |
5290 |
arg_concat(node1, node2)
|
| 5093 |
5291 |
NODE *node1;
|
| 5094 |
5292 |
NODE *node2;
|
| ... | ... | |
| 5111 |
5309 |
}
|
| 5112 |
5310 |
}
|
| 5113 |
5311 |
|
|
5312 |
static NODE *
|
|
5313 |
splat_array(node)
|
|
5314 |
NODE* node;
|
|
5315 |
{
|
|
5316 |
if (nd_type(node) == NODE_SPLAT) node = node->nd_head;
|
|
5317 |
if (nd_type(node) == NODE_ARRAY) return node;
|
|
5318 |
return 0;
|
|
5319 |
}
|
|
5320 |
|
| 5114 |
5321 |
static NODE*
|
| 5115 |
5322 |
node_assign(lhs, rhs)
|
| 5116 |
5323 |
NODE *lhs, *rhs;
|