prism 1.6.0 → 1.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -1
- data/Makefile +3 -3
- data/README.md +1 -1
- data/config.yml +28 -3
- data/docs/build_system.md +2 -2
- data/docs/cruby_compilation.md +1 -1
- data/docs/releasing.md +2 -2
- data/ext/prism/api_node.c +7 -3
- data/ext/prism/extconf.rb +1 -1
- data/ext/prism/extension.c +2 -3
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +54 -20
- data/include/prism/diagnostic.h +2 -0
- data/include/prism/options.h +8 -2
- data/include/prism/parser.h +3 -0
- data/include/prism/version.h +2 -2
- data/include/prism.h +1 -1
- data/lib/prism/dot_visitor.rb +5 -0
- data/lib/prism/dsl.rb +2 -2
- data/lib/prism/ffi.rb +3 -1
- data/lib/prism/inspect_visitor.rb +1 -0
- data/lib/prism/node.rb +52 -13
- data/lib/prism/parse_result.rb +2 -15
- data/lib/prism/polyfill/scan_byte.rb +1 -1
- data/lib/prism/reflection.rb +1 -1
- data/lib/prism/serialize.rb +6 -4
- data/lib/prism/translation/parser/compiler.rb +16 -16
- data/lib/prism/translation/parser.rb +5 -3
- data/lib/prism/translation/parser35.rb +1 -6
- data/lib/prism/translation/parser40.rb +13 -0
- data/lib/prism/translation/parser41.rb +13 -0
- data/lib/prism/translation/parser_current.rb +4 -2
- data/lib/prism/translation/ripper.rb +2 -2
- data/lib/prism/translation/ruby_parser.rb +53 -18
- data/lib/prism/translation.rb +2 -0
- data/lib/prism.rb +4 -5
- data/prism.gemspec +5 -1
- data/rbi/prism/dsl.rbi +3 -3
- data/rbi/prism/node.rbi +21 -8
- data/rbi/prism/translation/parser35.rbi +0 -2
- data/rbi/prism/translation/parser40.rbi +6 -0
- data/rbi/prism/translation/parser41.rbi +6 -0
- data/sig/prism/dsl.rbs +2 -2
- data/sig/prism/node.rbs +18 -8
- data/src/diagnostic.c +5 -1
- data/src/encoding.c +172 -67
- data/src/node.c +9 -0
- data/src/options.c +17 -7
- data/src/prettyprint.c +16 -0
- data/src/prism.c +1192 -1895
- data/src/serialize.c +7 -1
- data/src/token_type.c +2 -2
- data/src/util/pm_constant_pool.c +1 -1
- metadata +5 -1
data/src/node.c
CHANGED
|
@@ -3805,6 +3805,15 @@ pm_dump_json(pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *no
|
|
|
3805
3805
|
pm_buffer_append_string(buffer, "null", 4);
|
|
3806
3806
|
}
|
|
3807
3807
|
|
|
3808
|
+
// Dump the equal_loc field
|
|
3809
|
+
pm_buffer_append_byte(buffer, ',');
|
|
3810
|
+
pm_buffer_append_string(buffer, "\"equal_loc\":", 12);
|
|
3811
|
+
if (cast->equal_loc.start != NULL) {
|
|
3812
|
+
pm_dump_json_location(buffer, parser, &cast->equal_loc);
|
|
3813
|
+
} else {
|
|
3814
|
+
pm_buffer_append_string(buffer, "null", 4);
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3808
3817
|
// Dump the block field
|
|
3809
3818
|
pm_buffer_append_byte(buffer, ',');
|
|
3810
3819
|
pm_buffer_append_string(buffer, "\"block\":", 8);
|
data/src/options.c
CHANGED
|
@@ -88,27 +88,37 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
|
|
|
88
88
|
return true;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
if (strncmp(version, "3.5", 3) == 0) {
|
|
92
|
-
options->version =
|
|
91
|
+
if (strncmp(version, "3.5", 3) == 0 || strncmp(version, "4.0", 3) == 0) {
|
|
92
|
+
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (strncmp(version, "4.1", 3) == 0) {
|
|
97
|
+
options->version = PM_OPTIONS_VERSION_CRUBY_4_1;
|
|
93
98
|
return true;
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
return false;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
if (length >= 4) {
|
|
100
|
-
if (strncmp(version, "3.3.", 4) == 0
|
|
104
|
+
if (length >= 4 && is_number(version + 4, length - 4)) {
|
|
105
|
+
if (strncmp(version, "3.3.", 4) == 0) {
|
|
101
106
|
options->version = PM_OPTIONS_VERSION_CRUBY_3_3;
|
|
102
107
|
return true;
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
if (strncmp(version, "3.4.", 4) == 0
|
|
110
|
+
if (strncmp(version, "3.4.", 4) == 0) {
|
|
106
111
|
options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
|
|
107
112
|
return true;
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
if (strncmp(version, "3.5.", 4) == 0
|
|
111
|
-
options->version =
|
|
115
|
+
if (strncmp(version, "3.5.", 4) == 0 || strncmp(version, "4.0.", 4) == 0) {
|
|
116
|
+
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (strncmp(version, "4.1.", 4) == 0) {
|
|
121
|
+
options->version = PM_OPTIONS_VERSION_CRUBY_4_1;
|
|
112
122
|
return true;
|
|
113
123
|
}
|
|
114
124
|
}
|
data/src/prettyprint.c
CHANGED
|
@@ -1268,6 +1268,22 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
|
1268
1268
|
}
|
|
1269
1269
|
}
|
|
1270
1270
|
|
|
1271
|
+
// equal_loc
|
|
1272
|
+
{
|
|
1273
|
+
pm_buffer_concat(output_buffer, prefix_buffer);
|
|
1274
|
+
pm_buffer_append_string(output_buffer, "+-- equal_loc:", 14);
|
|
1275
|
+
pm_location_t *location = &cast->equal_loc;
|
|
1276
|
+
if (location->start == NULL) {
|
|
1277
|
+
pm_buffer_append_string(output_buffer, " nil\n", 5);
|
|
1278
|
+
} else {
|
|
1279
|
+
pm_buffer_append_byte(output_buffer, ' ');
|
|
1280
|
+
prettyprint_location(output_buffer, parser, location);
|
|
1281
|
+
pm_buffer_append_string(output_buffer, " = \"", 4);
|
|
1282
|
+
pm_buffer_append_source(output_buffer, location->start, (size_t) (location->end - location->start), PM_BUFFER_ESCAPING_RUBY);
|
|
1283
|
+
pm_buffer_append_string(output_buffer, "\"\n", 2);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1271
1287
|
// block
|
|
1272
1288
|
{
|
|
1273
1289
|
pm_buffer_concat(output_buffer, prefix_buffer);
|