sydparse 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +1 -0
- data/Rakefile +1 -1
- data/bin/syd_pt_show +9 -1
- data/lib/sydparse.rb +1 -1
- data/node.h +5 -3
- data/pstate.h +76 -0
- data/runtime.c +56 -9
- data/runtime.h +1 -66
- data/sydparse.c +112 -91
- data/sydparse.y +118 -96
- metadata +3 -2
data/sydparse.y
CHANGED
@@ -377,7 +377,7 @@ program : {
|
|
377
377
|
void_expr(node->nd_head);
|
378
378
|
}
|
379
379
|
}
|
380
|
-
vps->top = block_append(vps->top, $2);
|
380
|
+
vps->top = block_append(parse_state, vps->top, $2);
|
381
381
|
//vps->top = NEW_SCOPE(block_append(vps->top, $2));
|
382
382
|
rb_funcall(vps->self, rb_intern("local_finish"), 0);
|
383
383
|
|
@@ -397,7 +397,7 @@ bodystmt : compstmt
|
|
397
397
|
}
|
398
398
|
else if ($3) {
|
399
399
|
rb_warn("else without rescue is useless");
|
400
|
-
$$ = block_append($$, $3);
|
400
|
+
$$ = block_append(parse_state, $$, $3);
|
401
401
|
}
|
402
402
|
if ($4) {
|
403
403
|
$$ = NEW_ENSURE($$, $4);
|
@@ -416,11 +416,11 @@ compstmt : stmts opt_terms
|
|
416
416
|
stmts : none
|
417
417
|
| stmt
|
418
418
|
{
|
419
|
-
$$ = newline_node($1);
|
419
|
+
$$ = newline_node(parse_state, $1);
|
420
420
|
}
|
421
421
|
| stmts terms stmt
|
422
422
|
{
|
423
|
-
$$ = block_append($1, newline_node($3));
|
423
|
+
$$ = block_append(parse_state, $1, newline_node(parse_state, $3));
|
424
424
|
}
|
425
425
|
| error stmt
|
426
426
|
{
|
@@ -565,7 +565,7 @@ stmt : kALIAS fitem {vps->lex_state = EXPR_FNAME;} fitem
|
|
565
565
|
args = NEW_LIST($6);
|
566
566
|
if ($3 && nd_type($3) != NODE_ARRAY)
|
567
567
|
$3 = NEW_LIST($3);
|
568
|
-
$3 = list_append($3, NEW_NIL());
|
568
|
+
$3 = list_append(parse_state, $3, NEW_NIL());
|
569
569
|
list_concat(args, $3);
|
570
570
|
if ($5 == tOROP) {
|
571
571
|
$5 = 0;
|
@@ -680,11 +680,11 @@ command_call : command
|
|
680
680
|
block_command : block_call
|
681
681
|
| block_call '.' operation2 command_args
|
682
682
|
{
|
683
|
-
$$ = new_call($1, $3, $4);
|
683
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
684
684
|
}
|
685
685
|
| block_call tCOLON2 operation2 command_args
|
686
686
|
{
|
687
|
-
$$ = new_call($1, $3, $4);
|
687
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
688
688
|
}
|
689
689
|
;
|
690
690
|
|
@@ -705,12 +705,12 @@ cmd_brace_block : tLBRACE_ARG
|
|
705
705
|
|
706
706
|
command : operation command_args %prec tLOWEST
|
707
707
|
{
|
708
|
-
$$ = new_fcall($1, $2);
|
708
|
+
$$ = new_fcall(parse_state, $1, $2);
|
709
709
|
fixpos($$, $2);
|
710
710
|
}
|
711
711
|
| operation command_args cmd_brace_block
|
712
712
|
{
|
713
|
-
$$ = new_fcall($1, $2);
|
713
|
+
$$ = new_fcall(parse_state, $1, $2);
|
714
714
|
if ($3) {
|
715
715
|
if (nd_type($$) == NODE_BLOCK_PASS) {
|
716
716
|
rb_compile_error("both block arg and actual block given");
|
@@ -722,12 +722,12 @@ command : operation command_args %prec tLOWEST
|
|
722
722
|
}
|
723
723
|
| primary_value '.' operation2 command_args %prec tLOWEST
|
724
724
|
{
|
725
|
-
$$ = new_call($1, $3, $4);
|
725
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
726
726
|
fixpos($$, $1);
|
727
727
|
}
|
728
728
|
| primary_value '.' operation2 command_args cmd_brace_block
|
729
729
|
{
|
730
|
-
$$ = new_call($1, $3, $4);
|
730
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
731
731
|
if ($5) {
|
732
732
|
if (nd_type($$) == NODE_BLOCK_PASS) {
|
733
733
|
rb_compile_error("both block arg and actual block given");
|
@@ -739,12 +739,12 @@ command : operation command_args %prec tLOWEST
|
|
739
739
|
}
|
740
740
|
| primary_value tCOLON2 operation2 command_args %prec tLOWEST
|
741
741
|
{
|
742
|
-
$$ = new_call($1, $3, $4);
|
742
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
743
743
|
fixpos($$, $1);
|
744
744
|
}
|
745
745
|
| primary_value tCOLON2 operation2 command_args cmd_brace_block
|
746
746
|
{
|
747
|
-
$$ = new_call($1, $3, $4);
|
747
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
748
748
|
if ($5) {
|
749
749
|
if (nd_type($$) == NODE_BLOCK_PASS) {
|
750
750
|
rb_compile_error("both block arg and actual block given");
|
@@ -756,12 +756,12 @@ command : operation command_args %prec tLOWEST
|
|
756
756
|
}
|
757
757
|
| kSUPER command_args
|
758
758
|
{
|
759
|
-
$$ = new_super($2);
|
759
|
+
$$ = new_super(parse_state, $2);
|
760
760
|
fixpos($$, $2);
|
761
761
|
}
|
762
762
|
| kYIELD command_args
|
763
763
|
{
|
764
|
-
$$ = new_yield($2);
|
764
|
+
$$ = new_yield(parse_state, $2);
|
765
765
|
fixpos($$, $2);
|
766
766
|
}
|
767
767
|
;
|
@@ -786,7 +786,7 @@ mlhs_basic : mlhs_head
|
|
786
786
|
}
|
787
787
|
| mlhs_head mlhs_item
|
788
788
|
{
|
789
|
-
$$ = NEW_MASGN(list_append($1,$2), 0);
|
789
|
+
$$ = NEW_MASGN(list_append(parse_state, $1,$2), 0);
|
790
790
|
}
|
791
791
|
| mlhs_head tSTAR mlhs_node
|
792
792
|
{
|
@@ -819,7 +819,7 @@ mlhs_head : mlhs_item ','
|
|
819
819
|
}
|
820
820
|
| mlhs_head mlhs_item ','
|
821
821
|
{
|
822
|
-
$$ = list_append($1, $2);
|
822
|
+
$$ = list_append(parse_state, $1, $2);
|
823
823
|
}
|
824
824
|
;
|
825
825
|
|
@@ -947,7 +947,7 @@ undef_list : fitem
|
|
947
947
|
}
|
948
948
|
| undef_list ',' {vps->lex_state = EXPR_FNAME;} fitem
|
949
949
|
{
|
950
|
-
$$ = block_append($1, NEW_UNDEF($4));
|
950
|
+
$$ = block_append(parse_state, $1, NEW_UNDEF($4));
|
951
951
|
}
|
952
952
|
;
|
953
953
|
|
@@ -1029,7 +1029,7 @@ arg : lhs '=' arg
|
|
1029
1029
|
args = NEW_LIST($6);
|
1030
1030
|
if ($3 && nd_type($3) != NODE_ARRAY)
|
1031
1031
|
$3 = NEW_LIST($3);
|
1032
|
-
$3 = list_append($3, NEW_NIL());
|
1032
|
+
$3 = list_append(parse_state, $3, NEW_NIL());
|
1033
1033
|
list_concat(args, $3);
|
1034
1034
|
if ($5 == tOROP) {
|
1035
1035
|
$5 = 0;
|
@@ -1261,7 +1261,7 @@ aref_args : none
|
|
1261
1261
|
| args ',' tSTAR arg opt_nl
|
1262
1262
|
{
|
1263
1263
|
value_expr($4);
|
1264
|
-
$$ = arg_concat($1, $4);
|
1264
|
+
$$ = arg_concat(parse_state, $1, $4);
|
1265
1265
|
}
|
1266
1266
|
| assocs trailer
|
1267
1267
|
{
|
@@ -1290,7 +1290,7 @@ paren_args : '(' none ')'
|
|
1290
1290
|
| '(' args ',' block_call opt_nl ')'
|
1291
1291
|
{
|
1292
1292
|
rb_warn("parenthesize argument for future version");
|
1293
|
-
$$ = list_append($2, $4);
|
1293
|
+
$$ = list_append(parse_state, $2, $4);
|
1294
1294
|
}
|
1295
1295
|
;
|
1296
1296
|
|
@@ -1309,7 +1309,7 @@ call_args : command
|
|
1309
1309
|
}
|
1310
1310
|
| args ',' tSTAR arg_value opt_block_arg
|
1311
1311
|
{
|
1312
|
-
$$ = arg_concat($1, $4);
|
1312
|
+
$$ = arg_concat(parse_state, $1, $4);
|
1313
1313
|
$$ = arg_blk_pass($$, $5);
|
1314
1314
|
}
|
1315
1315
|
| assocs opt_block_arg
|
@@ -1319,18 +1319,18 @@ call_args : command
|
|
1319
1319
|
}
|
1320
1320
|
| assocs ',' tSTAR arg_value opt_block_arg
|
1321
1321
|
{
|
1322
|
-
$$ = arg_concat(NEW_LIST(NEW_POSITIONAL($1)), $4);
|
1322
|
+
$$ = arg_concat(parse_state, NEW_LIST(NEW_POSITIONAL($1)), $4);
|
1323
1323
|
$$ = arg_blk_pass($$, $5);
|
1324
1324
|
}
|
1325
1325
|
| args ',' assocs opt_block_arg
|
1326
1326
|
{
|
1327
|
-
$$ = list_append($1, NEW_POSITIONAL($3));
|
1327
|
+
$$ = list_append(parse_state, $1, NEW_POSITIONAL($3));
|
1328
1328
|
$$ = arg_blk_pass($$, $4);
|
1329
1329
|
}
|
1330
1330
|
| args ',' assocs ',' tSTAR arg opt_block_arg
|
1331
1331
|
{
|
1332
1332
|
value_expr($6);
|
1333
|
-
$$ = arg_concat(list_append($1, NEW_POSITIONAL($3)), $6);
|
1333
|
+
$$ = arg_concat(parse_state, list_append(parse_state, $1, NEW_POSITIONAL($3)), $6);
|
1334
1334
|
$$ = arg_blk_pass($$, $7);
|
1335
1335
|
}
|
1336
1336
|
| tSTAR arg_value opt_block_arg
|
@@ -1350,12 +1350,12 @@ call_args2 : arg_value ',' args opt_block_arg
|
|
1350
1350
|
}
|
1351
1351
|
| arg_value ',' tSTAR arg_value opt_block_arg
|
1352
1352
|
{
|
1353
|
-
$$ = arg_concat(NEW_LIST($1), $4);
|
1353
|
+
$$ = arg_concat(parse_state, NEW_LIST($1), $4);
|
1354
1354
|
$$ = arg_blk_pass($$, $5);
|
1355
1355
|
}
|
1356
1356
|
| arg_value ',' args ',' tSTAR arg_value opt_block_arg
|
1357
1357
|
{
|
1358
|
-
$$ = arg_concat(list_concat(NEW_LIST($1),$3), $6);
|
1358
|
+
$$ = arg_concat(parse_state, list_concat(NEW_LIST($1),$3), $6);
|
1359
1359
|
$$ = arg_blk_pass($$, $7);
|
1360
1360
|
}
|
1361
1361
|
| assocs opt_block_arg
|
@@ -1365,27 +1365,27 @@ call_args2 : arg_value ',' args opt_block_arg
|
|
1365
1365
|
}
|
1366
1366
|
| assocs ',' tSTAR arg_value opt_block_arg
|
1367
1367
|
{
|
1368
|
-
$$ = arg_concat(NEW_LIST(NEW_POSITIONAL($1)), $4);
|
1368
|
+
$$ = arg_concat(parse_state, NEW_LIST(NEW_POSITIONAL($1)), $4);
|
1369
1369
|
$$ = arg_blk_pass($$, $5);
|
1370
1370
|
}
|
1371
1371
|
| arg_value ',' assocs opt_block_arg
|
1372
1372
|
{
|
1373
|
-
$$ = list_append(NEW_LIST($1), NEW_POSITIONAL($3));
|
1373
|
+
$$ = list_append(parse_state, NEW_LIST($1), NEW_POSITIONAL($3));
|
1374
1374
|
$$ = arg_blk_pass($$, $4);
|
1375
1375
|
}
|
1376
1376
|
| arg_value ',' args ',' assocs opt_block_arg
|
1377
1377
|
{
|
1378
|
-
$$ = list_append(list_concat(NEW_LIST($1),$3), NEW_POSITIONAL($5));
|
1378
|
+
$$ = list_append(parse_state, list_concat(NEW_LIST($1),$3), NEW_POSITIONAL($5));
|
1379
1379
|
$$ = arg_blk_pass($$, $6);
|
1380
1380
|
}
|
1381
1381
|
| arg_value ',' assocs ',' tSTAR arg_value opt_block_arg
|
1382
1382
|
{
|
1383
|
-
$$ = arg_concat(list_append(NEW_LIST($1), NEW_POSITIONAL($3)), $6);
|
1383
|
+
$$ = arg_concat(parse_state, list_append(parse_state, NEW_LIST($1), NEW_POSITIONAL($3)), $6);
|
1384
1384
|
$$ = arg_blk_pass($$, $7);
|
1385
1385
|
}
|
1386
1386
|
| arg_value ',' args ',' assocs ',' tSTAR arg_value opt_block_arg
|
1387
1387
|
{
|
1388
|
-
$$ = arg_concat(list_append(list_concat(NEW_LIST($1), $3), NEW_POSITIONAL($5)), $8);
|
1388
|
+
$$ = arg_concat(parse_state, list_append(parse_state, list_concat(NEW_LIST($1), $3), NEW_POSITIONAL($5)), $8);
|
1389
1389
|
$$ = arg_blk_pass($$, $9);
|
1390
1390
|
}
|
1391
1391
|
| tSTAR arg_value opt_block_arg
|
@@ -1439,17 +1439,17 @@ args : arg_value
|
|
1439
1439
|
}
|
1440
1440
|
| args ',' arg_value
|
1441
1441
|
{
|
1442
|
-
$$ = list_append($1, $3);
|
1442
|
+
$$ = list_append(parse_state, $1, $3);
|
1443
1443
|
}
|
1444
1444
|
;
|
1445
1445
|
|
1446
1446
|
mrhs : args ',' arg_value
|
1447
1447
|
{
|
1448
|
-
$$ = list_append($1, $3);
|
1448
|
+
$$ = list_append(parse_state, $1, $3);
|
1449
1449
|
}
|
1450
1450
|
| args ',' tSTAR arg_value
|
1451
1451
|
{
|
1452
|
-
$$ = arg_concat($1, $4);
|
1452
|
+
$$ = arg_concat(parse_state, $1, $4);
|
1453
1453
|
}
|
1454
1454
|
| tSTAR arg_value
|
1455
1455
|
{
|
@@ -1527,7 +1527,7 @@ primary : literal
|
|
1527
1527
|
}
|
1528
1528
|
| kYIELD '(' call_args ')'
|
1529
1529
|
{
|
1530
|
-
$$ = new_yield($3);
|
1530
|
+
$$ = new_yield(parse_state, $3);
|
1531
1531
|
}
|
1532
1532
|
| kYIELD '(' ')'
|
1533
1533
|
{
|
@@ -1811,32 +1811,32 @@ block_call : command do_block
|
|
1811
1811
|
}
|
1812
1812
|
| block_call '.' operation2 opt_paren_args
|
1813
1813
|
{
|
1814
|
-
$$ = new_call($1, $3, $4);
|
1814
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
1815
1815
|
}
|
1816
1816
|
| block_call tCOLON2 operation2 opt_paren_args
|
1817
1817
|
{
|
1818
|
-
$$ = new_call($1, $3, $4);
|
1818
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
1819
1819
|
}
|
1820
1820
|
;
|
1821
1821
|
|
1822
1822
|
method_call : operation paren_args
|
1823
1823
|
{
|
1824
|
-
$$ = new_fcall($1, $2);
|
1824
|
+
$$ = new_fcall(parse_state, $1, $2);
|
1825
1825
|
fixpos($$, $2);
|
1826
1826
|
}
|
1827
1827
|
| primary_value '.' operation2 opt_paren_args
|
1828
1828
|
{
|
1829
|
-
$$ = new_call($1, $3, $4);
|
1829
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
1830
1830
|
fixpos($$, $1);
|
1831
1831
|
}
|
1832
1832
|
| primary_value tCOLON2 operation2 paren_args
|
1833
1833
|
{
|
1834
|
-
$$ = new_call($1, $3, $4);
|
1834
|
+
$$ = new_call(parse_state, $1, $3, $4);
|
1835
1835
|
fixpos($$, $1);
|
1836
1836
|
}
|
1837
1837
|
| primary_value tCOLON2 operation3
|
1838
1838
|
{
|
1839
|
-
$$ = new_call($1, $3, 0);
|
1839
|
+
$$ = new_call(parse_state, $1, $3, 0);
|
1840
1840
|
}
|
1841
1841
|
| primary_value '\\' operation2
|
1842
1842
|
{
|
@@ -1848,7 +1848,7 @@ method_call : operation paren_args
|
|
1848
1848
|
}
|
1849
1849
|
| kSUPER paren_args
|
1850
1850
|
{
|
1851
|
-
$$ = new_super($2);
|
1851
|
+
$$ = new_super(parse_state, $2);
|
1852
1852
|
}
|
1853
1853
|
| kSUPER
|
1854
1854
|
{
|
@@ -1892,7 +1892,7 @@ case_body : kWHEN when_args then
|
|
1892
1892
|
when_args : args
|
1893
1893
|
| args ',' tSTAR arg_value
|
1894
1894
|
{
|
1895
|
-
$$ = list_append($1, NEW_WHEN($4, 0, 0));
|
1895
|
+
$$ = list_append(parse_state, $1, NEW_WHEN($4, 0, 0));
|
1896
1896
|
}
|
1897
1897
|
| tSTAR arg_value
|
1898
1898
|
{
|
@@ -1910,7 +1910,7 @@ opt_rescue : kRESCUE exc_list exc_var then
|
|
1910
1910
|
{
|
1911
1911
|
if ($3) {
|
1912
1912
|
$3 = node_assign($3, NEW_GVAR(rb_intern("$!")), parse_state);
|
1913
|
-
$5 = block_append($3, $5);
|
1913
|
+
$5 = block_append(parse_state, $3, $5);
|
1914
1914
|
}
|
1915
1915
|
$$ = NEW_RESBODY($2, $5, $6);
|
1916
1916
|
fixpos($$, $2?$2:$5);
|
@@ -1959,7 +1959,7 @@ strings : string
|
|
1959
1959
|
node = NEW_STR(rb_str_new(0, 0));
|
1960
1960
|
}
|
1961
1961
|
else {
|
1962
|
-
node = evstr2dstr(node);
|
1962
|
+
node = evstr2dstr(parse_state, node);
|
1963
1963
|
}
|
1964
1964
|
$$ = node;
|
1965
1965
|
}
|
@@ -1968,7 +1968,7 @@ strings : string
|
|
1968
1968
|
string : string1
|
1969
1969
|
| string string1
|
1970
1970
|
{
|
1971
|
-
$$ = literal_concat($1, $2);
|
1971
|
+
$$ = literal_concat(parse_state, $1, $2);
|
1972
1972
|
}
|
1973
1973
|
;
|
1974
1974
|
|
@@ -2056,14 +2056,14 @@ word_list : /* none */
|
|
2056
2056
|
}
|
2057
2057
|
| word_list word ' '
|
2058
2058
|
{
|
2059
|
-
$$ = list_append($1, evstr2dstr($2));
|
2059
|
+
$$ = list_append(parse_state, $1, evstr2dstr(parse_state, $2));
|
2060
2060
|
}
|
2061
2061
|
;
|
2062
2062
|
|
2063
2063
|
word : string_content
|
2064
2064
|
| word string_content
|
2065
2065
|
{
|
2066
|
-
$$ = literal_concat($1, $2);
|
2066
|
+
$$ = literal_concat(parse_state, $1, $2);
|
2067
2067
|
}
|
2068
2068
|
;
|
2069
2069
|
|
@@ -2083,7 +2083,7 @@ qword_list : /* none */
|
|
2083
2083
|
}
|
2084
2084
|
| qword_list tSTRING_CONTENT ' '
|
2085
2085
|
{
|
2086
|
-
$$ = list_append($1, $2);
|
2086
|
+
$$ = list_append(parse_state, $1, $2);
|
2087
2087
|
}
|
2088
2088
|
;
|
2089
2089
|
|
@@ -2093,7 +2093,7 @@ string_contents : /* none */
|
|
2093
2093
|
}
|
2094
2094
|
| string_contents string_content
|
2095
2095
|
{
|
2096
|
-
$$ = literal_concat($1, $2);
|
2096
|
+
$$ = literal_concat(parse_state, $1, $2);
|
2097
2097
|
}
|
2098
2098
|
;
|
2099
2099
|
|
@@ -2103,7 +2103,7 @@ xstring_contents: /* none */
|
|
2103
2103
|
}
|
2104
2104
|
| xstring_contents string_content
|
2105
2105
|
{
|
2106
|
-
$$ = literal_concat($1, $2);
|
2106
|
+
$$ = literal_concat(parse_state, $1, $2);
|
2107
2107
|
}
|
2108
2108
|
;
|
2109
2109
|
|
@@ -2134,9 +2134,9 @@ string_content : tSTRING_CONTENT
|
|
2134
2134
|
CMDARG_LEXPOP();
|
2135
2135
|
if (($$ = $3) && nd_type($$) == NODE_NEWLINE) {
|
2136
2136
|
$$ = $$->nd_next;
|
2137
|
-
rb_gc_force_recycle((VALUE)$3);
|
2137
|
+
// rb_gc_force_recycle((VALUE)$3);
|
2138
2138
|
}
|
2139
|
-
$$ = new_evstr($$);
|
2139
|
+
$$ = new_evstr(parse_state, $$);
|
2140
2140
|
}
|
2141
2141
|
;
|
2142
2142
|
|
@@ -2255,38 +2255,38 @@ f_arglist : '(' f_args opt_nl ')'
|
|
2255
2255
|
f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
|
2256
2256
|
{
|
2257
2257
|
// printf("rest + all = %d\n", $5);
|
2258
|
-
$$ = block_append(NEW_ARGS($1, $3, $5), $6);
|
2258
|
+
$$ = block_append(parse_state, NEW_ARGS($1, $3, $5), $6);
|
2259
2259
|
}
|
2260
2260
|
| f_arg ',' f_optarg opt_f_block_arg
|
2261
2261
|
{
|
2262
|
-
$$ = block_append(NEW_ARGS($1, $3, -1), $4);
|
2262
|
+
$$ = block_append(parse_state, NEW_ARGS($1, $3, -1), $4);
|
2263
2263
|
}
|
2264
2264
|
| f_arg ',' f_rest_arg opt_f_block_arg
|
2265
2265
|
{
|
2266
2266
|
// printf("arg + rest = %d\n", $3);
|
2267
|
-
$$ = block_append(NEW_ARGS($1, 0, $3), $4);
|
2267
|
+
$$ = block_append(parse_state, NEW_ARGS($1, 0, $3), $4);
|
2268
2268
|
}
|
2269
2269
|
| f_arg opt_f_block_arg
|
2270
2270
|
{
|
2271
|
-
$$ = block_append(NEW_ARGS($1, 0, -1), $2);
|
2271
|
+
$$ = block_append(parse_state, NEW_ARGS($1, 0, -1), $2);
|
2272
2272
|
}
|
2273
2273
|
| f_optarg ',' f_rest_arg opt_f_block_arg
|
2274
2274
|
{
|
2275
2275
|
// printf("rest + opt = %d\n", $3);
|
2276
|
-
$$ = block_append(NEW_ARGS(0, $1, $3), $4);
|
2276
|
+
$$ = block_append(parse_state, NEW_ARGS(0, $1, $3), $4);
|
2277
2277
|
}
|
2278
2278
|
| f_optarg opt_f_block_arg
|
2279
2279
|
{
|
2280
|
-
$$ = block_append(NEW_ARGS(0, $1, -1), $2);
|
2280
|
+
$$ = block_append(parse_state, NEW_ARGS(0, $1, -1), $2);
|
2281
2281
|
}
|
2282
2282
|
| f_rest_arg opt_f_block_arg
|
2283
2283
|
{
|
2284
2284
|
// printf("rest only = %d\n", $1);
|
2285
|
-
$$ = block_append(NEW_ARGS(0, 0, $1), $2);
|
2285
|
+
$$ = block_append(parse_state, NEW_ARGS(0, 0, $1), $2);
|
2286
2286
|
}
|
2287
2287
|
| f_block_arg
|
2288
2288
|
{
|
2289
|
-
$$ = block_append(NEW_ARGS(0, 0, -1), $1);
|
2289
|
+
$$ = block_append(parse_state, NEW_ARGS(0, 0, -1), $1);
|
2290
2290
|
}
|
2291
2291
|
| /* none */
|
2292
2292
|
{
|
@@ -2345,7 +2345,7 @@ f_optarg : f_opt
|
|
2345
2345
|
}
|
2346
2346
|
| f_optarg ',' f_opt
|
2347
2347
|
{
|
2348
|
-
$$ = block_append($1, $3);
|
2348
|
+
$$ = block_append(parse_state, $1, $3);
|
2349
2349
|
}
|
2350
2350
|
;
|
2351
2351
|
|
@@ -2451,12 +2451,12 @@ assoc : assoc1
|
|
2451
2451
|
|
2452
2452
|
assoc1 : arg_value tASSOC arg_value
|
2453
2453
|
{
|
2454
|
-
$$ = list_append(NEW_LIST($1), $3);
|
2454
|
+
$$ = list_append(parse_state, NEW_LIST($1), $3);
|
2455
2455
|
}
|
2456
2456
|
;
|
2457
2457
|
assoc2 : tKEYSYM arg_value
|
2458
2458
|
{
|
2459
|
-
$$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
|
2459
|
+
$$ = list_append(parse_state, NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
|
2460
2460
|
}
|
2461
2461
|
|
2462
2462
|
operation : tIDENTIFIER
|
@@ -3214,7 +3214,7 @@ tokadd_string(func, term, paren, nest, parse_state)
|
|
3214
3214
|
}
|
3215
3215
|
|
3216
3216
|
#define NEW_STRTERM(func, term, paren) \
|
3217
|
-
syd_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
|
3217
|
+
syd_node_newnode(parse_state, NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
|
3218
3218
|
#define pslval ((YYSTYPE *)parse_state->lval)
|
3219
3219
|
static int
|
3220
3220
|
parse_string(quote, parse_state)
|
@@ -3322,7 +3322,7 @@ heredoc_identifier(rb_parse_state *parse_state)
|
|
3322
3322
|
len = parse_state->lex_p - parse_state->lex_pbeg;
|
3323
3323
|
parse_state->lex_p = parse_state->lex_pend;
|
3324
3324
|
pslval->id = 0;
|
3325
|
-
lex_strterm = syd_node_newnode(NODE_HEREDOC,
|
3325
|
+
lex_strterm = syd_node_newnode(parse_state, NODE_HEREDOC,
|
3326
3326
|
rb_str_new(tok(), toklen()), /* nd_lit */
|
3327
3327
|
len, /* nd_nth */
|
3328
3328
|
parse_state->lex_lastline); /* nd_orig */
|
@@ -4667,14 +4667,19 @@ yylex(YYSTYPE *yylval, void *vstate)
|
|
4667
4667
|
}
|
4668
4668
|
}
|
4669
4669
|
|
4670
|
+
void *pt_allocate(rb_parse_state *st, int size);
|
4671
|
+
|
4670
4672
|
NODE*
|
4671
|
-
syd_node_newnode(type, a0, a1, a2)
|
4673
|
+
syd_node_newnode(st, type, a0, a1, a2)
|
4674
|
+
rb_parse_state *st;
|
4672
4675
|
enum node_type type;
|
4673
4676
|
VALUE a0, a1, a2;
|
4674
4677
|
{
|
4675
|
-
NODE *n = (NODE*)
|
4678
|
+
NODE *n = (NODE*)pt_allocate(st, sizeof(NODE));
|
4679
|
+
// NODE *n = (NODE*)rb_newobj();
|
4676
4680
|
|
4677
|
-
n->flags |= T_NODE;
|
4681
|
+
// n->flags |= T_NODE;
|
4682
|
+
n->flags = 0;
|
4678
4683
|
nd_set_type(n, type);
|
4679
4684
|
nd_set_line(n, ruby_sourceline);
|
4680
4685
|
n->nd_file = ruby_sourcefile;
|
@@ -4704,7 +4709,8 @@ nodeline(node)
|
|
4704
4709
|
#endif
|
4705
4710
|
|
4706
4711
|
static NODE*
|
4707
|
-
newline_node(node)
|
4712
|
+
newline_node(parse_state, node)
|
4713
|
+
rb_parse_state *parse_state;
|
4708
4714
|
NODE *node;
|
4709
4715
|
{
|
4710
4716
|
NODE *nl = 0;
|
@@ -4751,7 +4757,8 @@ parser_warn(node, mesg)
|
|
4751
4757
|
}
|
4752
4758
|
|
4753
4759
|
static NODE*
|
4754
|
-
block_append(head, tail)
|
4760
|
+
block_append(parse_state, head, tail)
|
4761
|
+
rb_parse_state *parse_state;
|
4755
4762
|
NODE *head, *tail;
|
4756
4763
|
{
|
4757
4764
|
NODE *end, *h = head;
|
@@ -4811,7 +4818,8 @@ block_append(head, tail)
|
|
4811
4818
|
|
4812
4819
|
/* append item to the list */
|
4813
4820
|
static NODE*
|
4814
|
-
list_append(list, item)
|
4821
|
+
list_append(parse_state, list, item)
|
4822
|
+
rb_parse_state *parse_state;
|
4815
4823
|
NODE *list, *item;
|
4816
4824
|
{
|
4817
4825
|
NODE *last;
|
@@ -4858,7 +4866,8 @@ list_concat(head, tail)
|
|
4858
4866
|
|
4859
4867
|
/* concat two string literals */
|
4860
4868
|
static NODE *
|
4861
|
-
literal_concat(head, tail)
|
4869
|
+
literal_concat(parse_state, head, tail)
|
4870
|
+
rb_parse_state *parse_state;
|
4862
4871
|
NODE *head, *tail;
|
4863
4872
|
{
|
4864
4873
|
enum node_type htype;
|
@@ -4869,16 +4878,16 @@ literal_concat(head, tail)
|
|
4869
4878
|
htype = nd_type(head);
|
4870
4879
|
if (htype == NODE_EVSTR) {
|
4871
4880
|
NODE *node = NEW_DSTR(rb_str_new(0, 0));
|
4872
|
-
head = list_append(node, head);
|
4881
|
+
head = list_append(parse_state, node, head);
|
4873
4882
|
}
|
4874
4883
|
switch (nd_type(tail)) {
|
4875
4884
|
case NODE_STR:
|
4876
4885
|
if (htype == NODE_STR) {
|
4877
4886
|
rb_str_concat(head->nd_lit, tail->nd_lit);
|
4878
|
-
rb_gc_force_recycle((VALUE)tail);
|
4887
|
+
// rb_gc_force_recycle((VALUE)tail);
|
4879
4888
|
}
|
4880
4889
|
else {
|
4881
|
-
list_append(head, tail);
|
4890
|
+
list_append(parse_state, head, tail);
|
4882
4891
|
}
|
4883
4892
|
break;
|
4884
4893
|
|
@@ -4886,7 +4895,7 @@ literal_concat(head, tail)
|
|
4886
4895
|
if (htype == NODE_STR) {
|
4887
4896
|
rb_str_concat(head->nd_lit, tail->nd_lit);
|
4888
4897
|
tail->nd_lit = head->nd_lit;
|
4889
|
-
rb_gc_force_recycle((VALUE)head);
|
4898
|
+
// rb_gc_force_recycle((VALUE)head);
|
4890
4899
|
head = tail;
|
4891
4900
|
}
|
4892
4901
|
else {
|
@@ -4901,24 +4910,26 @@ literal_concat(head, tail)
|
|
4901
4910
|
nd_set_type(head, NODE_DSTR);
|
4902
4911
|
head->nd_alen = 1;
|
4903
4912
|
}
|
4904
|
-
list_append(head, tail);
|
4913
|
+
list_append(parse_state, head, tail);
|
4905
4914
|
break;
|
4906
4915
|
}
|
4907
4916
|
return head;
|
4908
4917
|
}
|
4909
4918
|
|
4910
4919
|
static NODE *
|
4911
|
-
evstr2dstr(node)
|
4920
|
+
evstr2dstr(parse_state, node)
|
4921
|
+
rb_parse_state *parse_state;
|
4912
4922
|
NODE *node;
|
4913
4923
|
{
|
4914
4924
|
if (nd_type(node) == NODE_EVSTR) {
|
4915
|
-
node = list_append(NEW_DSTR(rb_str_new(0, 0)), node);
|
4925
|
+
node = list_append(parse_state, NEW_DSTR(rb_str_new(0, 0)), node);
|
4916
4926
|
}
|
4917
4927
|
return node;
|
4918
4928
|
}
|
4919
4929
|
|
4920
4930
|
static NODE *
|
4921
|
-
new_evstr(node)
|
4931
|
+
new_evstr(parse_state, node)
|
4932
|
+
rb_parse_state *parse_state;
|
4922
4933
|
NODE *node;
|
4923
4934
|
{
|
4924
4935
|
NODE *head = node;
|
@@ -5217,7 +5228,8 @@ rb_backref_error(node)
|
|
5217
5228
|
}
|
5218
5229
|
|
5219
5230
|
static NODE *
|
5220
|
-
arg_concat(node1, node2)
|
5231
|
+
arg_concat(parse_state, node1, node2)
|
5232
|
+
rb_parse_state *parse_state;
|
5221
5233
|
NODE *node1;
|
5222
5234
|
NODE *node2;
|
5223
5235
|
{
|
@@ -5226,13 +5238,14 @@ arg_concat(node1, node2)
|
|
5226
5238
|
}
|
5227
5239
|
|
5228
5240
|
static NODE *
|
5229
|
-
arg_add(node1, node2)
|
5241
|
+
arg_add(parse_state, node1, node2)
|
5242
|
+
rb_parse_state *parse_state;
|
5230
5243
|
NODE *node1;
|
5231
5244
|
NODE *node2;
|
5232
5245
|
{
|
5233
5246
|
if (!node1) return NEW_LIST(node2);
|
5234
5247
|
if (nd_type(node1) == NODE_ARRAY) {
|
5235
|
-
return list_append(node1, node2);
|
5248
|
+
return list_append(parse_state, node1, node2);
|
5236
5249
|
}
|
5237
5250
|
else {
|
5238
5251
|
return NEW_ARGSPUSH(node1, node2);
|
@@ -5262,7 +5275,7 @@ node_assign(lhs, rhs, parse_state)
|
|
5262
5275
|
|
5263
5276
|
case NODE_ATTRASGN:
|
5264
5277
|
case NODE_CALL:
|
5265
|
-
lhs->nd_args = arg_add(lhs->nd_args, rhs);
|
5278
|
+
lhs->nd_args = arg_add(parse_state, lhs->nd_args, rhs);
|
5266
5279
|
break;
|
5267
5280
|
|
5268
5281
|
default:
|
@@ -5698,7 +5711,8 @@ no_blockarg(node)
|
|
5698
5711
|
}
|
5699
5712
|
|
5700
5713
|
static NODE *
|
5701
|
-
ret_args(node)
|
5714
|
+
ret_args(parse_state, node)
|
5715
|
+
rb_parse_state *parse_state;
|
5702
5716
|
NODE *node;
|
5703
5717
|
{
|
5704
5718
|
if (node) {
|
@@ -5714,7 +5728,8 @@ ret_args(node)
|
|
5714
5728
|
}
|
5715
5729
|
|
5716
5730
|
static NODE *
|
5717
|
-
new_yield(node)
|
5731
|
+
new_yield(parse_state, node)
|
5732
|
+
rb_parse_state *parse_state;
|
5718
5733
|
NODE *node;
|
5719
5734
|
{
|
5720
5735
|
long state = Qtrue;
|
@@ -5768,7 +5783,8 @@ arg_blk_pass(node1, node2)
|
|
5768
5783
|
}
|
5769
5784
|
|
5770
5785
|
static NODE*
|
5771
|
-
arg_prepend(node1, node2)
|
5786
|
+
arg_prepend(parse_state, node1, node2)
|
5787
|
+
rb_parse_state *parse_state;
|
5772
5788
|
NODE *node1, *node2;
|
5773
5789
|
{
|
5774
5790
|
switch (nd_type(node2)) {
|
@@ -5776,10 +5792,10 @@ arg_prepend(node1, node2)
|
|
5776
5792
|
return list_concat(NEW_LIST(node1), node2);
|
5777
5793
|
|
5778
5794
|
case NODE_SPLAT:
|
5779
|
-
return arg_concat(node1, node2->nd_head);
|
5795
|
+
return arg_concat(parse_state, node1, node2->nd_head);
|
5780
5796
|
|
5781
5797
|
case NODE_BLOCK_PASS:
|
5782
|
-
node2->nd_body = arg_prepend(node1, node2->nd_body);
|
5798
|
+
node2->nd_body = arg_prepend(parse_state, node1, node2->nd_body);
|
5783
5799
|
return node2;
|
5784
5800
|
|
5785
5801
|
default:
|
@@ -5789,7 +5805,8 @@ arg_prepend(node1, node2)
|
|
5789
5805
|
}
|
5790
5806
|
|
5791
5807
|
static NODE*
|
5792
|
-
new_call(r,m,a)
|
5808
|
+
new_call(parse_state, r,m,a)
|
5809
|
+
rb_parse_state *parse_state;
|
5793
5810
|
NODE *r;
|
5794
5811
|
ID m;
|
5795
5812
|
NODE *a;
|
@@ -5802,7 +5819,8 @@ new_call(r,m,a)
|
|
5802
5819
|
}
|
5803
5820
|
|
5804
5821
|
static NODE*
|
5805
|
-
new_fcall(m,a)
|
5822
|
+
new_fcall(parse_state, m,a)
|
5823
|
+
rb_parse_state *parse_state;
|
5806
5824
|
ID m;
|
5807
5825
|
NODE *a;
|
5808
5826
|
{
|
@@ -5814,7 +5832,8 @@ new_fcall(m,a)
|
|
5814
5832
|
}
|
5815
5833
|
|
5816
5834
|
static NODE*
|
5817
|
-
new_super(a)
|
5835
|
+
new_super(parse_state,a)
|
5836
|
+
rb_parse_state *parse_state;
|
5818
5837
|
NODE *a;
|
5819
5838
|
{
|
5820
5839
|
if (a && nd_type(a) == NODE_BLOCK_PASS) {
|
@@ -6072,10 +6091,13 @@ syd_dyna_init(st, node, pre)
|
|
6072
6091
|
VALUE pre;
|
6073
6092
|
{
|
6074
6093
|
VALUE vars;
|
6094
|
+
rb_parse_state *parse_state;
|
6075
6095
|
int i;
|
6076
6096
|
// struct RVarmap *post = ruby_dyna_vars;
|
6077
6097
|
NODE *var, *out;
|
6078
6098
|
|
6099
|
+
parse_state = st;
|
6100
|
+
|
6079
6101
|
if (!node) return node;
|
6080
6102
|
|
6081
6103
|
vars = rb_funcall(st->self, rb_intern("dyna_init"), 1, pre);
|
@@ -6091,7 +6113,7 @@ syd_dyna_init(st, node, pre)
|
|
6091
6113
|
var = NEW_DASGN_CURR(post->id, var);
|
6092
6114
|
}
|
6093
6115
|
*/
|
6094
|
-
out = block_append(var, node);
|
6116
|
+
out = block_append(st, var, node);
|
6095
6117
|
return out;
|
6096
6118
|
}
|
6097
6119
|
|
@@ -6424,4 +6446,4 @@ rb_lastline_set(val)
|
|
6424
6446
|
special_local_set('_', val);
|
6425
6447
|
}
|
6426
6448
|
}
|
6427
|
-
*/
|
6449
|
+
*/
|