prism 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/README.md +1 -1
- data/config.yml +86 -21
- data/ext/prism/api_node.c +213 -67
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +133 -83
- data/include/prism/diagnostic.h +1 -0
- data/include/prism/node.h +7 -0
- data/include/prism/util/pm_constant_pool.h +20 -6
- data/include/prism/version.h +2 -2
- data/include/prism.h +1 -1
- data/lib/prism/compiler.rb +9 -0
- data/lib/prism/debug.rb +30 -26
- data/lib/prism/dispatcher.rb +42 -0
- data/lib/prism/dsl.rb +23 -8
- data/lib/prism/ffi.rb +2 -2
- data/lib/prism/lex_compat.rb +9 -9
- data/lib/prism/mutation_compiler.rb +18 -3
- data/lib/prism/node.rb +580 -120
- data/lib/prism/serialize.rb +83 -77
- data/lib/prism/visitor.rb +9 -0
- data/prism.gemspec +1 -1
- data/src/diagnostic.c +1 -0
- data/src/node.c +99 -18
- data/src/prettyprint.c +102 -45
- data/src/prism.c +288 -88
- data/src/serialize.c +95 -57
- data/src/util/pm_constant_pool.c +25 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d02e58a6abcd72bbe920246599ed073e7c074929dff4f5b2408f87c9a222a51
|
4
|
+
data.tar.gz: 3c89a774748375ff30057d712465678ecff0936db4359d8fef10a819ba410d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b5d4de5b481f30fe65177f04b22d323cc697512d0a16077a44aefe393c821d1527343d369fc0a4a850cae725d7ef5a5f073c65c29d4cb49a558262e5c4decb
|
7
|
+
data.tar.gz: 6a487e4ca950684075ab462ce3cb9e04653cfa0e9af6888280866f08ca05653172ce86dcb89a8dd7bda1d4c5d4bd45f6f8cd106f428cca723ffe9787ff3d19b5
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.15.0] - 2023-10-18
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- `BackReferenceReadNode#name` is now provided.
|
14
|
+
- `Index{Operator,And,Or}WriteNode` are introduced, split out from `Call{Operator,And,Or}WriteNode` when the method is `[]`.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Ensure `PM_NODE_FLAG_COMMON_MASK` into a constant expression to fix compile errors.
|
19
|
+
- `super(&arg)` is now fixed.
|
20
|
+
- Ensure the last encoding flag on regular expressions wins.
|
21
|
+
- Fix the common whitespace calculation when embedded expressions begin on a line.
|
22
|
+
- Capture groups in regular expressions now scan the unescaped version to get the correct local variables.
|
23
|
+
- `*` and `&` are added to the local table when `...` is found in the parameters of a method definition.
|
24
|
+
|
9
25
|
## [0.14.0] - 2023-10-13
|
10
26
|
|
11
27
|
### Added
|
@@ -179,7 +195,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
179
195
|
|
180
196
|
- 🎉 Initial release! 🎉
|
181
197
|
|
182
|
-
[unreleased]: https://github.com/ruby/prism/compare/v0.
|
198
|
+
[unreleased]: https://github.com/ruby/prism/compare/v0.15.0...HEAD
|
199
|
+
[0.15.0]: https://github.com/ruby/prism/compare/v0.14.0...v0.15.0
|
183
200
|
[0.14.0]: https://github.com/ruby/prism/compare/v0.13.0...v0.14.0
|
184
201
|
[0.13.0]: https://github.com/ruby/prism/compare/v0.12.0...v0.13.0
|
185
202
|
[0.12.0]: https://github.com/ruby/prism/compare/v0.11.0...v0.12.0
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<h1 align="center">Prism Ruby parser</h1>
|
2
2
|
<div align="center">
|
3
|
-
<img alt="Prism Ruby parser" height="256px" src="
|
3
|
+
<img alt="Prism Ruby parser" height="256px" src="https://github.com/ruby/prism/blob/main/docs/prism.png?raw=true">
|
4
4
|
</div>
|
5
5
|
|
6
6
|
This is a parser for the Ruby programming language. It is designed to be portable, error tolerant, and maintainable. It is written in C99 and has no dependencies. It is currently being integrated into [CRuby](https://github.com/ruby/ruby), [JRuby](https://github.com/jruby/jruby), [TruffleRuby](https://github.com/oracle/truffleruby), [Sorbet](https://github.com/sorbet/sorbet), and [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree).
|
data/config.yml
CHANGED
@@ -507,6 +507,9 @@ nodes:
|
|
507
507
|
{ **foo }
|
508
508
|
^^^^^
|
509
509
|
- name: BackReferenceReadNode
|
510
|
+
fields:
|
511
|
+
- name: name
|
512
|
+
type: constant
|
510
513
|
comment: |
|
511
514
|
Represents reading a reference to a field in the previous match.
|
512
515
|
|
@@ -630,13 +633,6 @@ nodes:
|
|
630
633
|
type: location?
|
631
634
|
- name: message_loc
|
632
635
|
type: location?
|
633
|
-
- name: opening_loc
|
634
|
-
type: location?
|
635
|
-
- name: arguments
|
636
|
-
type: node?
|
637
|
-
kind: ArgumentsNode
|
638
|
-
- name: closing_loc
|
639
|
-
type: location?
|
640
636
|
- name: flags
|
641
637
|
type: flags
|
642
638
|
kind: CallNodeFlags
|
@@ -703,13 +699,6 @@ nodes:
|
|
703
699
|
type: location?
|
704
700
|
- name: message_loc
|
705
701
|
type: location?
|
706
|
-
- name: opening_loc
|
707
|
-
type: location?
|
708
|
-
- name: arguments
|
709
|
-
type: node?
|
710
|
-
kind: ArgumentsNode
|
711
|
-
- name: closing_loc
|
712
|
-
type: location?
|
713
702
|
- name: flags
|
714
703
|
type: flags
|
715
704
|
kind: CallNodeFlags
|
@@ -736,13 +725,6 @@ nodes:
|
|
736
725
|
type: location?
|
737
726
|
- name: message_loc
|
738
727
|
type: location?
|
739
|
-
- name: opening_loc
|
740
|
-
type: location?
|
741
|
-
- name: arguments
|
742
|
-
type: node?
|
743
|
-
kind: ArgumentsNode
|
744
|
-
- name: closing_loc
|
745
|
-
type: location?
|
746
728
|
- name: flags
|
747
729
|
type: flags
|
748
730
|
kind: CallNodeFlags
|
@@ -1443,6 +1425,89 @@ nodes:
|
|
1443
1425
|
|
1444
1426
|
case a; in b then c end
|
1445
1427
|
^^^^^^^^^^^
|
1428
|
+
- name: IndexAndWriteNode
|
1429
|
+
fields:
|
1430
|
+
- name: receiver
|
1431
|
+
type: node?
|
1432
|
+
- name: call_operator_loc
|
1433
|
+
type: location?
|
1434
|
+
- name: opening_loc
|
1435
|
+
type: location
|
1436
|
+
- name: arguments
|
1437
|
+
type: node?
|
1438
|
+
kind: ArgumentsNode
|
1439
|
+
- name: closing_loc
|
1440
|
+
type: location
|
1441
|
+
- name: block
|
1442
|
+
type: node?
|
1443
|
+
- name: flags
|
1444
|
+
type: flags
|
1445
|
+
kind: CallNodeFlags
|
1446
|
+
- name: operator_loc
|
1447
|
+
type: location
|
1448
|
+
- name: value
|
1449
|
+
type: node
|
1450
|
+
comment: |
|
1451
|
+
Represents the use of the `&&=` operator on a call to the `[]` method.
|
1452
|
+
|
1453
|
+
foo.bar[baz] &&= value
|
1454
|
+
^^^^^^^^^^^^^^^^^^^^^^
|
1455
|
+
- name: IndexOperatorWriteNode
|
1456
|
+
fields:
|
1457
|
+
- name: receiver
|
1458
|
+
type: node?
|
1459
|
+
- name: call_operator_loc
|
1460
|
+
type: location?
|
1461
|
+
- name: opening_loc
|
1462
|
+
type: location
|
1463
|
+
- name: arguments
|
1464
|
+
type: node?
|
1465
|
+
kind: ArgumentsNode
|
1466
|
+
- name: closing_loc
|
1467
|
+
type: location
|
1468
|
+
- name: block
|
1469
|
+
type: node?
|
1470
|
+
- name: flags
|
1471
|
+
type: flags
|
1472
|
+
kind: CallNodeFlags
|
1473
|
+
- name: operator
|
1474
|
+
type: constant
|
1475
|
+
- name: operator_loc
|
1476
|
+
type: location
|
1477
|
+
- name: value
|
1478
|
+
type: node
|
1479
|
+
comment: |
|
1480
|
+
Represents the use of an assignment operator on a call to `[]`.
|
1481
|
+
|
1482
|
+
foo.bar[baz] += value
|
1483
|
+
^^^^^^^^^^^^^^^^^^^^^
|
1484
|
+
- name: IndexOrWriteNode
|
1485
|
+
fields:
|
1486
|
+
- name: receiver
|
1487
|
+
type: node?
|
1488
|
+
- name: call_operator_loc
|
1489
|
+
type: location?
|
1490
|
+
- name: opening_loc
|
1491
|
+
type: location
|
1492
|
+
- name: arguments
|
1493
|
+
type: node?
|
1494
|
+
kind: ArgumentsNode
|
1495
|
+
- name: closing_loc
|
1496
|
+
type: location
|
1497
|
+
- name: block
|
1498
|
+
type: node?
|
1499
|
+
- name: flags
|
1500
|
+
type: flags
|
1501
|
+
kind: CallNodeFlags
|
1502
|
+
- name: operator_loc
|
1503
|
+
type: location
|
1504
|
+
- name: value
|
1505
|
+
type: node
|
1506
|
+
comment: |
|
1507
|
+
Represents the use of the `||=` operator on a call to `[]`.
|
1508
|
+
|
1509
|
+
foo.bar[baz] ||= value
|
1510
|
+
^^^^^^^^^^^^^^^^^^^^^^
|
1446
1511
|
- name: InstanceVariableAndWriteNode
|
1447
1512
|
fields:
|
1448
1513
|
- name: name
|
data/ext/prism/api_node.c
CHANGED
@@ -82,6 +82,9 @@ static VALUE rb_cPrismIfNode;
|
|
82
82
|
static VALUE rb_cPrismImaginaryNode;
|
83
83
|
static VALUE rb_cPrismImplicitNode;
|
84
84
|
static VALUE rb_cPrismInNode;
|
85
|
+
static VALUE rb_cPrismIndexAndWriteNode;
|
86
|
+
static VALUE rb_cPrismIndexOperatorWriteNode;
|
87
|
+
static VALUE rb_cPrismIndexOrWriteNode;
|
85
88
|
static VALUE rb_cPrismInstanceVariableAndWriteNode;
|
86
89
|
static VALUE rb_cPrismInstanceVariableOperatorWriteNode;
|
87
90
|
static VALUE rb_cPrismInstanceVariableOrWriteNode;
|
@@ -358,7 +361,6 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
358
361
|
case PM_CALL_AND_WRITE_NODE: {
|
359
362
|
pm_call_and_write_node_t *cast = (pm_call_and_write_node_t *) node;
|
360
363
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->receiver);
|
361
|
-
pm_node_stack_push(&node_stack, (pm_node_t *) cast->arguments);
|
362
364
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->value);
|
363
365
|
break;
|
364
366
|
}
|
@@ -374,7 +376,6 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
374
376
|
case PM_CALL_OPERATOR_WRITE_NODE: {
|
375
377
|
pm_call_operator_write_node_t *cast = (pm_call_operator_write_node_t *) node;
|
376
378
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->receiver);
|
377
|
-
pm_node_stack_push(&node_stack, (pm_node_t *) cast->arguments);
|
378
379
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->value);
|
379
380
|
break;
|
380
381
|
}
|
@@ -382,7 +383,6 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
382
383
|
case PM_CALL_OR_WRITE_NODE: {
|
383
384
|
pm_call_or_write_node_t *cast = (pm_call_or_write_node_t *) node;
|
384
385
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->receiver);
|
385
|
-
pm_node_stack_push(&node_stack, (pm_node_t *) cast->arguments);
|
386
386
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->value);
|
387
387
|
break;
|
388
388
|
}
|
@@ -640,6 +640,33 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
640
640
|
pm_node_stack_push(&node_stack, (pm_node_t *) cast->statements);
|
641
641
|
break;
|
642
642
|
}
|
643
|
+
#line 108 "api_node.c.erb"
|
644
|
+
case PM_INDEX_AND_WRITE_NODE: {
|
645
|
+
pm_index_and_write_node_t *cast = (pm_index_and_write_node_t *) node;
|
646
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->receiver);
|
647
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->arguments);
|
648
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->block);
|
649
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->value);
|
650
|
+
break;
|
651
|
+
}
|
652
|
+
#line 108 "api_node.c.erb"
|
653
|
+
case PM_INDEX_OPERATOR_WRITE_NODE: {
|
654
|
+
pm_index_operator_write_node_t *cast = (pm_index_operator_write_node_t *) node;
|
655
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->receiver);
|
656
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->arguments);
|
657
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->block);
|
658
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->value);
|
659
|
+
break;
|
660
|
+
}
|
661
|
+
#line 108 "api_node.c.erb"
|
662
|
+
case PM_INDEX_OR_WRITE_NODE: {
|
663
|
+
pm_index_or_write_node_t *cast = (pm_index_or_write_node_t *) node;
|
664
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->receiver);
|
665
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->arguments);
|
666
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->block);
|
667
|
+
pm_node_stack_push(&node_stack, (pm_node_t *) cast->value);
|
668
|
+
break;
|
669
|
+
}
|
643
670
|
#line 108 "api_node.c.erb"
|
644
671
|
case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: {
|
645
672
|
pm_instance_variable_and_write_node_t *cast = (pm_instance_variable_and_write_node_t *) node;
|
@@ -1222,12 +1249,18 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
1222
1249
|
}
|
1223
1250
|
#line 134 "api_node.c.erb"
|
1224
1251
|
case PM_BACK_REFERENCE_READ_NODE: {
|
1225
|
-
|
1252
|
+
pm_back_reference_read_node_t *cast = (pm_back_reference_read_node_t *) node;
|
1253
|
+
VALUE argv[2];
|
1254
|
+
|
1255
|
+
// name
|
1256
|
+
#line 157 "api_node.c.erb"
|
1257
|
+
assert(cast->name != 0);
|
1258
|
+
argv[0] = rb_id2sym(constants[cast->name - 1]);
|
1226
1259
|
|
1227
1260
|
// location
|
1228
|
-
argv[
|
1261
|
+
argv[1] = pm_location_new(parser, node->location.start, node->location.end, source);
|
1229
1262
|
|
1230
|
-
rb_ary_push(value_stack, rb_class_new_instance(
|
1263
|
+
rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cPrismBackReferenceReadNode));
|
1231
1264
|
break;
|
1232
1265
|
}
|
1233
1266
|
#line 134 "api_node.c.erb"
|
@@ -1409,7 +1442,7 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
1409
1442
|
#line 134 "api_node.c.erb"
|
1410
1443
|
case PM_CALL_AND_WRITE_NODE: {
|
1411
1444
|
pm_call_and_write_node_t *cast = (pm_call_and_write_node_t *) node;
|
1412
|
-
VALUE argv[
|
1445
|
+
VALUE argv[9];
|
1413
1446
|
|
1414
1447
|
// receiver
|
1415
1448
|
#line 145 "api_node.c.erb"
|
@@ -1423,44 +1456,32 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
1423
1456
|
#line 173 "api_node.c.erb"
|
1424
1457
|
argv[2] = cast->message_loc.start == NULL ? Qnil : pm_location_new(parser, cast->message_loc.start, cast->message_loc.end, source);
|
1425
1458
|
|
1426
|
-
// opening_loc
|
1427
|
-
#line 173 "api_node.c.erb"
|
1428
|
-
argv[3] = cast->opening_loc.start == NULL ? Qnil : pm_location_new(parser, cast->opening_loc.start, cast->opening_loc.end, source);
|
1429
|
-
|
1430
|
-
// arguments
|
1431
|
-
#line 145 "api_node.c.erb"
|
1432
|
-
argv[4] = rb_ary_pop(value_stack);
|
1433
|
-
|
1434
|
-
// closing_loc
|
1435
|
-
#line 173 "api_node.c.erb"
|
1436
|
-
argv[5] = cast->closing_loc.start == NULL ? Qnil : pm_location_new(parser, cast->closing_loc.start, cast->closing_loc.end, source);
|
1437
|
-
|
1438
1459
|
// flags
|
1439
1460
|
#line 179 "api_node.c.erb"
|
1440
|
-
argv[
|
1461
|
+
argv[3] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
1441
1462
|
|
1442
1463
|
// read_name
|
1443
1464
|
#line 157 "api_node.c.erb"
|
1444
1465
|
assert(cast->read_name != 0);
|
1445
|
-
argv[
|
1466
|
+
argv[4] = rb_id2sym(constants[cast->read_name - 1]);
|
1446
1467
|
|
1447
1468
|
// write_name
|
1448
1469
|
#line 157 "api_node.c.erb"
|
1449
1470
|
assert(cast->write_name != 0);
|
1450
|
-
argv[
|
1471
|
+
argv[5] = rb_id2sym(constants[cast->write_name - 1]);
|
1451
1472
|
|
1452
1473
|
// operator_loc
|
1453
1474
|
#line 170 "api_node.c.erb"
|
1454
|
-
argv[
|
1475
|
+
argv[6] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source);
|
1455
1476
|
|
1456
1477
|
// value
|
1457
1478
|
#line 145 "api_node.c.erb"
|
1458
|
-
argv[
|
1479
|
+
argv[7] = rb_ary_pop(value_stack);
|
1459
1480
|
|
1460
1481
|
// location
|
1461
|
-
argv[
|
1482
|
+
argv[8] = pm_location_new(parser, node->location.start, node->location.end, source);
|
1462
1483
|
|
1463
|
-
rb_ary_push(value_stack, rb_class_new_instance(
|
1484
|
+
rb_ary_push(value_stack, rb_class_new_instance(9, argv, rb_cPrismCallAndWriteNode));
|
1464
1485
|
break;
|
1465
1486
|
}
|
1466
1487
|
#line 134 "api_node.c.erb"
|
@@ -1514,7 +1535,7 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
1514
1535
|
#line 134 "api_node.c.erb"
|
1515
1536
|
case PM_CALL_OPERATOR_WRITE_NODE: {
|
1516
1537
|
pm_call_operator_write_node_t *cast = (pm_call_operator_write_node_t *) node;
|
1517
|
-
VALUE argv[
|
1538
|
+
VALUE argv[10];
|
1518
1539
|
|
1519
1540
|
// receiver
|
1520
1541
|
#line 145 "api_node.c.erb"
|
@@ -1528,55 +1549,43 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
1528
1549
|
#line 173 "api_node.c.erb"
|
1529
1550
|
argv[2] = cast->message_loc.start == NULL ? Qnil : pm_location_new(parser, cast->message_loc.start, cast->message_loc.end, source);
|
1530
1551
|
|
1531
|
-
// opening_loc
|
1532
|
-
#line 173 "api_node.c.erb"
|
1533
|
-
argv[3] = cast->opening_loc.start == NULL ? Qnil : pm_location_new(parser, cast->opening_loc.start, cast->opening_loc.end, source);
|
1534
|
-
|
1535
|
-
// arguments
|
1536
|
-
#line 145 "api_node.c.erb"
|
1537
|
-
argv[4] = rb_ary_pop(value_stack);
|
1538
|
-
|
1539
|
-
// closing_loc
|
1540
|
-
#line 173 "api_node.c.erb"
|
1541
|
-
argv[5] = cast->closing_loc.start == NULL ? Qnil : pm_location_new(parser, cast->closing_loc.start, cast->closing_loc.end, source);
|
1542
|
-
|
1543
1552
|
// flags
|
1544
1553
|
#line 179 "api_node.c.erb"
|
1545
|
-
argv[
|
1554
|
+
argv[3] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
1546
1555
|
|
1547
1556
|
// read_name
|
1548
1557
|
#line 157 "api_node.c.erb"
|
1549
1558
|
assert(cast->read_name != 0);
|
1550
|
-
argv[
|
1559
|
+
argv[4] = rb_id2sym(constants[cast->read_name - 1]);
|
1551
1560
|
|
1552
1561
|
// write_name
|
1553
1562
|
#line 157 "api_node.c.erb"
|
1554
1563
|
assert(cast->write_name != 0);
|
1555
|
-
argv[
|
1564
|
+
argv[5] = rb_id2sym(constants[cast->write_name - 1]);
|
1556
1565
|
|
1557
1566
|
// operator
|
1558
1567
|
#line 157 "api_node.c.erb"
|
1559
1568
|
assert(cast->operator != 0);
|
1560
|
-
argv[
|
1569
|
+
argv[6] = rb_id2sym(constants[cast->operator - 1]);
|
1561
1570
|
|
1562
1571
|
// operator_loc
|
1563
1572
|
#line 170 "api_node.c.erb"
|
1564
|
-
argv[
|
1573
|
+
argv[7] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source);
|
1565
1574
|
|
1566
1575
|
// value
|
1567
1576
|
#line 145 "api_node.c.erb"
|
1568
|
-
argv[
|
1577
|
+
argv[8] = rb_ary_pop(value_stack);
|
1569
1578
|
|
1570
1579
|
// location
|
1571
|
-
argv[
|
1580
|
+
argv[9] = pm_location_new(parser, node->location.start, node->location.end, source);
|
1572
1581
|
|
1573
|
-
rb_ary_push(value_stack, rb_class_new_instance(
|
1582
|
+
rb_ary_push(value_stack, rb_class_new_instance(10, argv, rb_cPrismCallOperatorWriteNode));
|
1574
1583
|
break;
|
1575
1584
|
}
|
1576
1585
|
#line 134 "api_node.c.erb"
|
1577
1586
|
case PM_CALL_OR_WRITE_NODE: {
|
1578
1587
|
pm_call_or_write_node_t *cast = (pm_call_or_write_node_t *) node;
|
1579
|
-
VALUE argv[
|
1588
|
+
VALUE argv[9];
|
1580
1589
|
|
1581
1590
|
// receiver
|
1582
1591
|
#line 145 "api_node.c.erb"
|
@@ -1590,44 +1599,32 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
1590
1599
|
#line 173 "api_node.c.erb"
|
1591
1600
|
argv[2] = cast->message_loc.start == NULL ? Qnil : pm_location_new(parser, cast->message_loc.start, cast->message_loc.end, source);
|
1592
1601
|
|
1593
|
-
// opening_loc
|
1594
|
-
#line 173 "api_node.c.erb"
|
1595
|
-
argv[3] = cast->opening_loc.start == NULL ? Qnil : pm_location_new(parser, cast->opening_loc.start, cast->opening_loc.end, source);
|
1596
|
-
|
1597
|
-
// arguments
|
1598
|
-
#line 145 "api_node.c.erb"
|
1599
|
-
argv[4] = rb_ary_pop(value_stack);
|
1600
|
-
|
1601
|
-
// closing_loc
|
1602
|
-
#line 173 "api_node.c.erb"
|
1603
|
-
argv[5] = cast->closing_loc.start == NULL ? Qnil : pm_location_new(parser, cast->closing_loc.start, cast->closing_loc.end, source);
|
1604
|
-
|
1605
1602
|
// flags
|
1606
1603
|
#line 179 "api_node.c.erb"
|
1607
|
-
argv[
|
1604
|
+
argv[3] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
1608
1605
|
|
1609
1606
|
// read_name
|
1610
1607
|
#line 157 "api_node.c.erb"
|
1611
1608
|
assert(cast->read_name != 0);
|
1612
|
-
argv[
|
1609
|
+
argv[4] = rb_id2sym(constants[cast->read_name - 1]);
|
1613
1610
|
|
1614
1611
|
// write_name
|
1615
1612
|
#line 157 "api_node.c.erb"
|
1616
1613
|
assert(cast->write_name != 0);
|
1617
|
-
argv[
|
1614
|
+
argv[5] = rb_id2sym(constants[cast->write_name - 1]);
|
1618
1615
|
|
1619
1616
|
// operator_loc
|
1620
1617
|
#line 170 "api_node.c.erb"
|
1621
|
-
argv[
|
1618
|
+
argv[6] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source);
|
1622
1619
|
|
1623
1620
|
// value
|
1624
1621
|
#line 145 "api_node.c.erb"
|
1625
|
-
argv[
|
1622
|
+
argv[7] = rb_ary_pop(value_stack);
|
1626
1623
|
|
1627
1624
|
// location
|
1628
|
-
argv[
|
1625
|
+
argv[8] = pm_location_new(parser, node->location.start, node->location.end, source);
|
1629
1626
|
|
1630
|
-
rb_ary_push(value_stack, rb_class_new_instance(
|
1627
|
+
rb_ary_push(value_stack, rb_class_new_instance(9, argv, rb_cPrismCallOrWriteNode));
|
1631
1628
|
break;
|
1632
1629
|
}
|
1633
1630
|
#line 134 "api_node.c.erb"
|
@@ -2808,6 +2805,152 @@ pm_ast_new(pm_parser_t *parser, pm_node_t *node, rb_encoding *encoding) {
|
|
2808
2805
|
rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cPrismInNode));
|
2809
2806
|
break;
|
2810
2807
|
}
|
2808
|
+
#line 134 "api_node.c.erb"
|
2809
|
+
case PM_INDEX_AND_WRITE_NODE: {
|
2810
|
+
pm_index_and_write_node_t *cast = (pm_index_and_write_node_t *) node;
|
2811
|
+
VALUE argv[10];
|
2812
|
+
|
2813
|
+
// receiver
|
2814
|
+
#line 145 "api_node.c.erb"
|
2815
|
+
argv[0] = rb_ary_pop(value_stack);
|
2816
|
+
|
2817
|
+
// call_operator_loc
|
2818
|
+
#line 173 "api_node.c.erb"
|
2819
|
+
argv[1] = cast->call_operator_loc.start == NULL ? Qnil : pm_location_new(parser, cast->call_operator_loc.start, cast->call_operator_loc.end, source);
|
2820
|
+
|
2821
|
+
// opening_loc
|
2822
|
+
#line 170 "api_node.c.erb"
|
2823
|
+
argv[2] = pm_location_new(parser, cast->opening_loc.start, cast->opening_loc.end, source);
|
2824
|
+
|
2825
|
+
// arguments
|
2826
|
+
#line 145 "api_node.c.erb"
|
2827
|
+
argv[3] = rb_ary_pop(value_stack);
|
2828
|
+
|
2829
|
+
// closing_loc
|
2830
|
+
#line 170 "api_node.c.erb"
|
2831
|
+
argv[4] = pm_location_new(parser, cast->closing_loc.start, cast->closing_loc.end, source);
|
2832
|
+
|
2833
|
+
// block
|
2834
|
+
#line 145 "api_node.c.erb"
|
2835
|
+
argv[5] = rb_ary_pop(value_stack);
|
2836
|
+
|
2837
|
+
// flags
|
2838
|
+
#line 179 "api_node.c.erb"
|
2839
|
+
argv[6] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
2840
|
+
|
2841
|
+
// operator_loc
|
2842
|
+
#line 170 "api_node.c.erb"
|
2843
|
+
argv[7] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source);
|
2844
|
+
|
2845
|
+
// value
|
2846
|
+
#line 145 "api_node.c.erb"
|
2847
|
+
argv[8] = rb_ary_pop(value_stack);
|
2848
|
+
|
2849
|
+
// location
|
2850
|
+
argv[9] = pm_location_new(parser, node->location.start, node->location.end, source);
|
2851
|
+
|
2852
|
+
rb_ary_push(value_stack, rb_class_new_instance(10, argv, rb_cPrismIndexAndWriteNode));
|
2853
|
+
break;
|
2854
|
+
}
|
2855
|
+
#line 134 "api_node.c.erb"
|
2856
|
+
case PM_INDEX_OPERATOR_WRITE_NODE: {
|
2857
|
+
pm_index_operator_write_node_t *cast = (pm_index_operator_write_node_t *) node;
|
2858
|
+
VALUE argv[11];
|
2859
|
+
|
2860
|
+
// receiver
|
2861
|
+
#line 145 "api_node.c.erb"
|
2862
|
+
argv[0] = rb_ary_pop(value_stack);
|
2863
|
+
|
2864
|
+
// call_operator_loc
|
2865
|
+
#line 173 "api_node.c.erb"
|
2866
|
+
argv[1] = cast->call_operator_loc.start == NULL ? Qnil : pm_location_new(parser, cast->call_operator_loc.start, cast->call_operator_loc.end, source);
|
2867
|
+
|
2868
|
+
// opening_loc
|
2869
|
+
#line 170 "api_node.c.erb"
|
2870
|
+
argv[2] = pm_location_new(parser, cast->opening_loc.start, cast->opening_loc.end, source);
|
2871
|
+
|
2872
|
+
// arguments
|
2873
|
+
#line 145 "api_node.c.erb"
|
2874
|
+
argv[3] = rb_ary_pop(value_stack);
|
2875
|
+
|
2876
|
+
// closing_loc
|
2877
|
+
#line 170 "api_node.c.erb"
|
2878
|
+
argv[4] = pm_location_new(parser, cast->closing_loc.start, cast->closing_loc.end, source);
|
2879
|
+
|
2880
|
+
// block
|
2881
|
+
#line 145 "api_node.c.erb"
|
2882
|
+
argv[5] = rb_ary_pop(value_stack);
|
2883
|
+
|
2884
|
+
// flags
|
2885
|
+
#line 179 "api_node.c.erb"
|
2886
|
+
argv[6] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
2887
|
+
|
2888
|
+
// operator
|
2889
|
+
#line 157 "api_node.c.erb"
|
2890
|
+
assert(cast->operator != 0);
|
2891
|
+
argv[7] = rb_id2sym(constants[cast->operator - 1]);
|
2892
|
+
|
2893
|
+
// operator_loc
|
2894
|
+
#line 170 "api_node.c.erb"
|
2895
|
+
argv[8] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source);
|
2896
|
+
|
2897
|
+
// value
|
2898
|
+
#line 145 "api_node.c.erb"
|
2899
|
+
argv[9] = rb_ary_pop(value_stack);
|
2900
|
+
|
2901
|
+
// location
|
2902
|
+
argv[10] = pm_location_new(parser, node->location.start, node->location.end, source);
|
2903
|
+
|
2904
|
+
rb_ary_push(value_stack, rb_class_new_instance(11, argv, rb_cPrismIndexOperatorWriteNode));
|
2905
|
+
break;
|
2906
|
+
}
|
2907
|
+
#line 134 "api_node.c.erb"
|
2908
|
+
case PM_INDEX_OR_WRITE_NODE: {
|
2909
|
+
pm_index_or_write_node_t *cast = (pm_index_or_write_node_t *) node;
|
2910
|
+
VALUE argv[10];
|
2911
|
+
|
2912
|
+
// receiver
|
2913
|
+
#line 145 "api_node.c.erb"
|
2914
|
+
argv[0] = rb_ary_pop(value_stack);
|
2915
|
+
|
2916
|
+
// call_operator_loc
|
2917
|
+
#line 173 "api_node.c.erb"
|
2918
|
+
argv[1] = cast->call_operator_loc.start == NULL ? Qnil : pm_location_new(parser, cast->call_operator_loc.start, cast->call_operator_loc.end, source);
|
2919
|
+
|
2920
|
+
// opening_loc
|
2921
|
+
#line 170 "api_node.c.erb"
|
2922
|
+
argv[2] = pm_location_new(parser, cast->opening_loc.start, cast->opening_loc.end, source);
|
2923
|
+
|
2924
|
+
// arguments
|
2925
|
+
#line 145 "api_node.c.erb"
|
2926
|
+
argv[3] = rb_ary_pop(value_stack);
|
2927
|
+
|
2928
|
+
// closing_loc
|
2929
|
+
#line 170 "api_node.c.erb"
|
2930
|
+
argv[4] = pm_location_new(parser, cast->closing_loc.start, cast->closing_loc.end, source);
|
2931
|
+
|
2932
|
+
// block
|
2933
|
+
#line 145 "api_node.c.erb"
|
2934
|
+
argv[5] = rb_ary_pop(value_stack);
|
2935
|
+
|
2936
|
+
// flags
|
2937
|
+
#line 179 "api_node.c.erb"
|
2938
|
+
argv[6] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
2939
|
+
|
2940
|
+
// operator_loc
|
2941
|
+
#line 170 "api_node.c.erb"
|
2942
|
+
argv[7] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source);
|
2943
|
+
|
2944
|
+
// value
|
2945
|
+
#line 145 "api_node.c.erb"
|
2946
|
+
argv[8] = rb_ary_pop(value_stack);
|
2947
|
+
|
2948
|
+
// location
|
2949
|
+
argv[9] = pm_location_new(parser, node->location.start, node->location.end, source);
|
2950
|
+
|
2951
|
+
rb_ary_push(value_stack, rb_class_new_instance(10, argv, rb_cPrismIndexOrWriteNode));
|
2952
|
+
break;
|
2953
|
+
}
|
2811
2954
|
#line 134 "api_node.c.erb"
|
2812
2955
|
case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: {
|
2813
2956
|
pm_instance_variable_and_write_node_t *cast = (pm_instance_variable_and_write_node_t *) node;
|
@@ -4656,6 +4799,9 @@ Init_prism_api_node(void) {
|
|
4656
4799
|
rb_cPrismImaginaryNode = rb_define_class_under(rb_cPrism, "ImaginaryNode", rb_cPrismNode);
|
4657
4800
|
rb_cPrismImplicitNode = rb_define_class_under(rb_cPrism, "ImplicitNode", rb_cPrismNode);
|
4658
4801
|
rb_cPrismInNode = rb_define_class_under(rb_cPrism, "InNode", rb_cPrismNode);
|
4802
|
+
rb_cPrismIndexAndWriteNode = rb_define_class_under(rb_cPrism, "IndexAndWriteNode", rb_cPrismNode);
|
4803
|
+
rb_cPrismIndexOperatorWriteNode = rb_define_class_under(rb_cPrism, "IndexOperatorWriteNode", rb_cPrismNode);
|
4804
|
+
rb_cPrismIndexOrWriteNode = rb_define_class_under(rb_cPrism, "IndexOrWriteNode", rb_cPrismNode);
|
4659
4805
|
rb_cPrismInstanceVariableAndWriteNode = rb_define_class_under(rb_cPrism, "InstanceVariableAndWriteNode", rb_cPrismNode);
|
4660
4806
|
rb_cPrismInstanceVariableOperatorWriteNode = rb_define_class_under(rb_cPrism, "InstanceVariableOperatorWriteNode", rb_cPrismNode);
|
4661
4807
|
rb_cPrismInstanceVariableOrWriteNode = rb_define_class_under(rb_cPrism, "InstanceVariableOrWriteNode", rb_cPrismNode);
|