prism 0.28.0 → 0.30.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 +41 -1
- data/CONTRIBUTING.md +0 -4
- data/README.md +1 -0
- data/config.yml +95 -26
- data/docs/fuzzing.md +1 -1
- data/docs/ripper_translation.md +22 -0
- data/ext/prism/api_node.c +70 -52
- data/ext/prism/extconf.rb +27 -23
- data/ext/prism/extension.c +107 -372
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +170 -102
- data/include/prism/diagnostic.h +18 -3
- data/include/prism/node.h +0 -21
- data/include/prism/parser.h +23 -25
- data/include/prism/regexp.h +17 -8
- data/include/prism/static_literals.h +3 -2
- data/include/prism/util/pm_char.h +1 -2
- data/include/prism/util/pm_constant_pool.h +0 -8
- data/include/prism/util/pm_integer.h +16 -9
- data/include/prism/util/pm_string.h +0 -8
- data/include/prism/version.h +2 -2
- data/include/prism.h +0 -11
- data/lib/prism/compiler.rb +3 -0
- data/lib/prism/desugar_compiler.rb +4 -4
- data/lib/prism/dispatcher.rb +14 -0
- data/lib/prism/dot_visitor.rb +54 -35
- data/lib/prism/dsl.rb +23 -18
- data/lib/prism/ffi.rb +25 -4
- data/lib/prism/inspect_visitor.rb +26 -24
- data/lib/prism/mutation_compiler.rb +6 -1
- data/lib/prism/node.rb +314 -389
- data/lib/prism/node_ext.rb +175 -17
- data/lib/prism/parse_result/comments.rb +1 -8
- data/lib/prism/parse_result/newlines.rb +102 -12
- data/lib/prism/parse_result.rb +17 -0
- data/lib/prism/reflection.rb +11 -9
- data/lib/prism/serialize.rb +91 -68
- data/lib/prism/translation/parser/compiler.rb +288 -138
- data/lib/prism/translation/parser.rb +7 -2
- data/lib/prism/translation/ripper.rb +24 -22
- data/lib/prism/translation/ruby_parser.rb +32 -14
- data/lib/prism/visitor.rb +3 -0
- data/lib/prism.rb +0 -4
- data/prism.gemspec +2 -4
- data/rbi/prism/node.rbi +114 -57
- data/rbi/prism/node_ext.rbi +5 -0
- data/rbi/prism/parse_result.rbi +1 -1
- data/rbi/prism/visitor.rbi +3 -0
- data/rbi/prism.rbi +6 -0
- data/sig/prism/dsl.rbs +13 -10
- data/sig/prism/lex_compat.rbs +10 -0
- data/sig/prism/mutation_compiler.rbs +1 -0
- data/sig/prism/node.rbs +72 -48
- data/sig/prism/node_ext.rbs +4 -0
- data/sig/prism/visitor.rbs +1 -0
- data/sig/prism.rbs +21 -0
- data/src/diagnostic.c +56 -27
- data/src/node.c +432 -1690
- data/src/prettyprint.c +97 -54
- data/src/prism.c +1286 -1196
- data/src/regexp.c +133 -68
- data/src/serialize.c +22 -17
- data/src/static_literals.c +63 -84
- data/src/token_type.c +4 -4
- data/src/util/pm_constant_pool.c +0 -8
- data/src/util/pm_integer.c +39 -11
- data/src/util/pm_string.c +0 -12
- data/src/util/pm_strpbrk.c +32 -6
- metadata +3 -5
- data/include/prism/util/pm_string_list.h +0 -44
- data/lib/prism/debug.rb +0 -249
- data/src/util/pm_string_list.c +0 -28
data/src/prettyprint.c
CHANGED
@@ -1372,20 +1372,20 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
1372
1372
|
pm_buffer_append_byte(output_buffer, '\n');
|
1373
1373
|
}
|
1374
1374
|
|
1375
|
-
//
|
1375
|
+
// binary_operator
|
1376
1376
|
{
|
1377
1377
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
1378
|
-
pm_buffer_append_string(output_buffer, "+--
|
1378
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
1379
1379
|
pm_buffer_append_byte(output_buffer, ' ');
|
1380
|
-
prettyprint_constant(output_buffer, parser, cast->
|
1380
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
1381
1381
|
pm_buffer_append_byte(output_buffer, '\n');
|
1382
1382
|
}
|
1383
1383
|
|
1384
|
-
//
|
1384
|
+
// binary_operator_loc
|
1385
1385
|
{
|
1386
1386
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
1387
|
-
pm_buffer_append_string(output_buffer, "+--
|
1388
|
-
pm_location_t *location = &cast->
|
1387
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
1388
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
1389
1389
|
pm_buffer_append_byte(output_buffer, ' ');
|
1390
1390
|
prettyprint_location(output_buffer, parser, location);
|
1391
1391
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -2031,11 +2031,11 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
2031
2031
|
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
2032
2032
|
}
|
2033
2033
|
|
2034
|
-
//
|
2034
|
+
// binary_operator_loc
|
2035
2035
|
{
|
2036
2036
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
2037
|
-
pm_buffer_append_string(output_buffer, "+--
|
2038
|
-
pm_location_t *location = &cast->
|
2037
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
2038
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
2039
2039
|
pm_buffer_append_byte(output_buffer, ' ');
|
2040
2040
|
prettyprint_location(output_buffer, parser, location);
|
2041
2041
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -2056,12 +2056,12 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
2056
2056
|
prefix_buffer->length = prefix_length;
|
2057
2057
|
}
|
2058
2058
|
|
2059
|
-
//
|
2059
|
+
// binary_operator
|
2060
2060
|
{
|
2061
2061
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
2062
|
-
pm_buffer_append_string(output_buffer, "+--
|
2062
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
2063
2063
|
pm_buffer_append_byte(output_buffer, ' ');
|
2064
|
-
prettyprint_constant(output_buffer, parser, cast->
|
2064
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
2065
2065
|
pm_buffer_append_byte(output_buffer, '\n');
|
2066
2066
|
}
|
2067
2067
|
|
@@ -2290,11 +2290,11 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
2290
2290
|
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
2291
2291
|
}
|
2292
2292
|
|
2293
|
-
//
|
2293
|
+
// binary_operator_loc
|
2294
2294
|
{
|
2295
2295
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
2296
|
-
pm_buffer_append_string(output_buffer, "+--
|
2297
|
-
pm_location_t *location = &cast->
|
2296
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
2297
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
2298
2298
|
pm_buffer_append_byte(output_buffer, ' ');
|
2299
2299
|
prettyprint_location(output_buffer, parser, location);
|
2300
2300
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -2315,12 +2315,12 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
2315
2315
|
prefix_buffer->length = prefix_length;
|
2316
2316
|
}
|
2317
2317
|
|
2318
|
-
//
|
2318
|
+
// binary_operator
|
2319
2319
|
{
|
2320
2320
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
2321
|
-
pm_buffer_append_string(output_buffer, "+--
|
2321
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
2322
2322
|
pm_buffer_append_byte(output_buffer, ' ');
|
2323
|
-
prettyprint_constant(output_buffer, parser, cast->
|
2323
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
2324
2324
|
pm_buffer_append_byte(output_buffer, '\n');
|
2325
2325
|
}
|
2326
2326
|
|
@@ -2507,11 +2507,11 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
2507
2507
|
prefix_buffer->length = prefix_length;
|
2508
2508
|
}
|
2509
2509
|
|
2510
|
-
//
|
2510
|
+
// binary_operator_loc
|
2511
2511
|
{
|
2512
2512
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
2513
|
-
pm_buffer_append_string(output_buffer, "+--
|
2514
|
-
pm_location_t *location = &cast->
|
2513
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
2514
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
2515
2515
|
pm_buffer_append_byte(output_buffer, ' ');
|
2516
2516
|
prettyprint_location(output_buffer, parser, location);
|
2517
2517
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -2532,12 +2532,12 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
2532
2532
|
prefix_buffer->length = prefix_length;
|
2533
2533
|
}
|
2534
2534
|
|
2535
|
-
//
|
2535
|
+
// binary_operator
|
2536
2536
|
{
|
2537
2537
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
2538
|
-
pm_buffer_append_string(output_buffer, "+--
|
2538
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
2539
2539
|
pm_buffer_append_byte(output_buffer, ' ');
|
2540
|
-
prettyprint_constant(output_buffer, parser, cast->
|
2540
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
2541
2541
|
pm_buffer_append_byte(output_buffer, '\n');
|
2542
2542
|
}
|
2543
2543
|
|
@@ -3632,11 +3632,11 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
3632
3632
|
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
3633
3633
|
}
|
3634
3634
|
|
3635
|
-
//
|
3635
|
+
// binary_operator_loc
|
3636
3636
|
{
|
3637
3637
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
3638
|
-
pm_buffer_append_string(output_buffer, "+--
|
3639
|
-
pm_location_t *location = &cast->
|
3638
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
3639
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
3640
3640
|
pm_buffer_append_byte(output_buffer, ' ');
|
3641
3641
|
prettyprint_location(output_buffer, parser, location);
|
3642
3642
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -3657,12 +3657,12 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
3657
3657
|
prefix_buffer->length = prefix_length;
|
3658
3658
|
}
|
3659
3659
|
|
3660
|
-
//
|
3660
|
+
// binary_operator
|
3661
3661
|
{
|
3662
3662
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
3663
|
-
pm_buffer_append_string(output_buffer, "+--
|
3663
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
3664
3664
|
pm_buffer_append_byte(output_buffer, ' ');
|
3665
|
-
prettyprint_constant(output_buffer, parser, cast->
|
3665
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
3666
3666
|
pm_buffer_append_byte(output_buffer, '\n');
|
3667
3667
|
}
|
3668
3668
|
|
@@ -4449,20 +4449,20 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
4449
4449
|
}
|
4450
4450
|
}
|
4451
4451
|
|
4452
|
-
//
|
4452
|
+
// binary_operator
|
4453
4453
|
{
|
4454
4454
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
4455
|
-
pm_buffer_append_string(output_buffer, "+--
|
4455
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
4456
4456
|
pm_buffer_append_byte(output_buffer, ' ');
|
4457
|
-
prettyprint_constant(output_buffer, parser, cast->
|
4457
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
4458
4458
|
pm_buffer_append_byte(output_buffer, '\n');
|
4459
4459
|
}
|
4460
4460
|
|
4461
|
-
//
|
4461
|
+
// binary_operator_loc
|
4462
4462
|
{
|
4463
4463
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
4464
|
-
pm_buffer_append_string(output_buffer, "+--
|
4465
|
-
pm_location_t *location = &cast->
|
4464
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
4465
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
4466
4466
|
pm_buffer_append_byte(output_buffer, ' ');
|
4467
4467
|
prettyprint_location(output_buffer, parser, location);
|
4468
4468
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -4827,11 +4827,11 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
4827
4827
|
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
4828
4828
|
}
|
4829
4829
|
|
4830
|
-
//
|
4830
|
+
// binary_operator_loc
|
4831
4831
|
{
|
4832
4832
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
4833
|
-
pm_buffer_append_string(output_buffer, "+--
|
4834
|
-
pm_location_t *location = &cast->
|
4833
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
4834
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
4835
4835
|
pm_buffer_append_byte(output_buffer, ' ');
|
4836
4836
|
prettyprint_location(output_buffer, parser, location);
|
4837
4837
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -4852,12 +4852,12 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
4852
4852
|
prefix_buffer->length = prefix_length;
|
4853
4853
|
}
|
4854
4854
|
|
4855
|
-
//
|
4855
|
+
// binary_operator
|
4856
4856
|
{
|
4857
4857
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
4858
|
-
pm_buffer_append_string(output_buffer, "+--
|
4858
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
4859
4859
|
pm_buffer_append_byte(output_buffer, ' ');
|
4860
|
-
prettyprint_constant(output_buffer, parser, cast->
|
4860
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
4861
4861
|
pm_buffer_append_byte(output_buffer, '\n');
|
4862
4862
|
}
|
4863
4863
|
|
@@ -5465,6 +5465,13 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
5465
5465
|
|
5466
5466
|
break;
|
5467
5467
|
}
|
5468
|
+
case PM_IT_LOCAL_VARIABLE_READ_NODE: {
|
5469
|
+
pm_buffer_append_string(output_buffer, "@ ItLocalVariableReadNode (location: ", 37);
|
5470
|
+
prettyprint_location(output_buffer, parser, &node->location);
|
5471
|
+
pm_buffer_append_string(output_buffer, ")\n", 2);
|
5472
|
+
|
5473
|
+
break;
|
5474
|
+
}
|
5468
5475
|
case PM_IT_PARAMETERS_NODE: {
|
5469
5476
|
pm_buffer_append_string(output_buffer, "@ ItParametersNode (location: ", 30);
|
5470
5477
|
prettyprint_location(output_buffer, parser, &node->location);
|
@@ -5744,11 +5751,11 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
5744
5751
|
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
5745
5752
|
}
|
5746
5753
|
|
5747
|
-
//
|
5754
|
+
// binary_operator_loc
|
5748
5755
|
{
|
5749
5756
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
5750
|
-
pm_buffer_append_string(output_buffer, "+--
|
5751
|
-
pm_location_t *location = &cast->
|
5757
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator_loc:", 24);
|
5758
|
+
pm_location_t *location = &cast->binary_operator_loc;
|
5752
5759
|
pm_buffer_append_byte(output_buffer, ' ');
|
5753
5760
|
prettyprint_location(output_buffer, parser, location);
|
5754
5761
|
pm_buffer_append_string(output_buffer, " = \"", 4);
|
@@ -5778,12 +5785,12 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
5778
5785
|
pm_buffer_append_byte(output_buffer, '\n');
|
5779
5786
|
}
|
5780
5787
|
|
5781
|
-
//
|
5788
|
+
// binary_operator
|
5782
5789
|
{
|
5783
5790
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
5784
|
-
pm_buffer_append_string(output_buffer, "+--
|
5791
|
+
pm_buffer_append_string(output_buffer, "+-- binary_operator:", 20);
|
5785
5792
|
pm_buffer_append_byte(output_buffer, ' ');
|
5786
|
-
prettyprint_constant(output_buffer, parser, cast->
|
5793
|
+
prettyprint_constant(output_buffer, parser, cast->binary_operator);
|
5787
5794
|
pm_buffer_append_byte(output_buffer, '\n');
|
5788
5795
|
}
|
5789
5796
|
|
@@ -7290,17 +7297,53 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
7290
7297
|
prettyprint_location(output_buffer, parser, &node->location);
|
7291
7298
|
pm_buffer_append_string(output_buffer, ")\n", 2);
|
7292
7299
|
|
7293
|
-
//
|
7300
|
+
// flags
|
7294
7301
|
{
|
7295
7302
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
7296
|
-
pm_buffer_append_string(output_buffer, "+--
|
7303
|
+
pm_buffer_append_string(output_buffer, "+-- flags:", 10);
|
7304
|
+
bool found = false;
|
7305
|
+
if (cast->base.flags & PM_INTEGER_BASE_FLAGS_BINARY) {
|
7306
|
+
if (found) pm_buffer_append_byte(output_buffer, ',');
|
7307
|
+
pm_buffer_append_string(output_buffer, " binary", 7);
|
7308
|
+
found = true;
|
7309
|
+
}
|
7310
|
+
if (cast->base.flags & PM_INTEGER_BASE_FLAGS_DECIMAL) {
|
7311
|
+
if (found) pm_buffer_append_byte(output_buffer, ',');
|
7312
|
+
pm_buffer_append_string(output_buffer, " decimal", 8);
|
7313
|
+
found = true;
|
7314
|
+
}
|
7315
|
+
if (cast->base.flags & PM_INTEGER_BASE_FLAGS_OCTAL) {
|
7316
|
+
if (found) pm_buffer_append_byte(output_buffer, ',');
|
7317
|
+
pm_buffer_append_string(output_buffer, " octal", 6);
|
7318
|
+
found = true;
|
7319
|
+
}
|
7320
|
+
if (cast->base.flags & PM_INTEGER_BASE_FLAGS_HEXADECIMAL) {
|
7321
|
+
if (found) pm_buffer_append_byte(output_buffer, ',');
|
7322
|
+
pm_buffer_append_string(output_buffer, " hexadecimal", 12);
|
7323
|
+
found = true;
|
7324
|
+
}
|
7325
|
+
if (!found) pm_buffer_append_string(output_buffer, " nil", 4);
|
7297
7326
|
pm_buffer_append_byte(output_buffer, '\n');
|
7327
|
+
}
|
7298
7328
|
|
7299
|
-
|
7300
|
-
|
7329
|
+
// numerator
|
7330
|
+
{
|
7301
7331
|
pm_buffer_concat(output_buffer, prefix_buffer);
|
7302
|
-
|
7303
|
-
|
7332
|
+
pm_buffer_append_string(output_buffer, "+-- numerator:", 14);
|
7333
|
+
const pm_integer_t *integer = &cast->numerator;
|
7334
|
+
pm_buffer_append_byte(output_buffer, ' ');
|
7335
|
+
pm_integer_string(output_buffer, integer);
|
7336
|
+
pm_buffer_append_byte(output_buffer, '\n');
|
7337
|
+
}
|
7338
|
+
|
7339
|
+
// denominator
|
7340
|
+
{
|
7341
|
+
pm_buffer_concat(output_buffer, prefix_buffer);
|
7342
|
+
pm_buffer_append_string(output_buffer, "+-- denominator:", 16);
|
7343
|
+
const pm_integer_t *integer = &cast->denominator;
|
7344
|
+
pm_buffer_append_byte(output_buffer, ' ');
|
7345
|
+
pm_integer_string(output_buffer, integer);
|
7346
|
+
pm_buffer_append_byte(output_buffer, '\n');
|
7304
7347
|
}
|
7305
7348
|
|
7306
7349
|
break;
|