prism 1.4.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 +73 -1
- data/Makefile +7 -5
- data/README.md +3 -1
- data/config.yml +294 -41
- data/docs/build_system.md +2 -2
- data/docs/cruby_compilation.md +1 -1
- data/docs/design.md +2 -2
- data/docs/parser_translation.md +8 -23
- data/docs/releasing.md +6 -25
- data/docs/ripper_translation.md +1 -1
- data/ext/prism/api_node.c +9 -3
- data/ext/prism/extconf.rb +1 -1
- data/ext/prism/extension.c +24 -3
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +360 -70
- data/include/prism/diagnostic.h +7 -0
- data/include/prism/options.h +49 -3
- data/include/prism/parser.h +3 -0
- data/include/prism/regexp.h +2 -2
- data/include/prism/util/pm_buffer.h +8 -0
- data/include/prism/util/pm_integer.h +4 -0
- data/include/prism/util/pm_list.h +6 -0
- data/include/prism/util/pm_string.h +12 -2
- data/include/prism/version.h +2 -2
- data/include/prism.h +40 -15
- data/lib/prism/compiler.rb +456 -151
- data/lib/prism/desugar_compiler.rb +1 -0
- data/lib/prism/dispatcher.rb +16 -0
- data/lib/prism/dot_visitor.rb +10 -1
- data/lib/prism/dsl.rb +5 -2
- data/lib/prism/ffi.rb +28 -10
- data/lib/prism/inspect_visitor.rb +4 -0
- data/lib/prism/lex_compat.rb +1 -0
- data/lib/prism/mutation_compiler.rb +3 -0
- data/lib/prism/node.rb +559 -349
- data/lib/prism/node_ext.rb +4 -1
- data/lib/prism/pack.rb +2 -0
- data/lib/prism/parse_result/comments.rb +1 -0
- data/lib/prism/parse_result/errors.rb +1 -0
- data/lib/prism/parse_result/newlines.rb +1 -0
- data/lib/prism/parse_result.rb +3 -15
- data/lib/prism/pattern.rb +1 -0
- data/lib/prism/polyfill/scan_byte.rb +14 -0
- data/lib/prism/polyfill/warn.rb +36 -0
- data/lib/prism/reflection.rb +4 -1
- data/lib/prism/relocation.rb +1 -0
- data/lib/prism/serialize.rb +30 -22
- data/lib/prism/string_query.rb +1 -0
- data/lib/prism/translation/parser/builder.rb +1 -0
- data/lib/prism/translation/parser/compiler.rb +63 -41
- data/lib/prism/translation/parser/lexer.rb +29 -21
- data/lib/prism/translation/parser.rb +25 -4
- data/lib/prism/translation/parser33.rb +1 -0
- data/lib/prism/translation/parser34.rb +1 -0
- data/lib/prism/translation/parser35.rb +2 -6
- data/lib/prism/translation/parser40.rb +13 -0
- data/lib/prism/translation/parser41.rb +13 -0
- data/lib/prism/translation/parser_current.rb +26 -0
- data/lib/prism/translation/ripper/sexp.rb +1 -0
- data/lib/prism/translation/ripper.rb +19 -3
- data/lib/prism/translation/ruby_parser.rb +340 -22
- data/lib/prism/translation.rb +4 -0
- data/lib/prism/visitor.rb +457 -152
- data/lib/prism.rb +22 -0
- data/prism.gemspec +9 -1
- data/rbi/prism/dsl.rbi +6 -6
- data/rbi/prism/node.rbi +42 -17
- 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/dispatcher.rbs +3 -0
- data/sig/prism/dsl.rbs +5 -5
- data/sig/prism/node.rbs +462 -38
- data/sig/prism/node_ext.rbs +84 -17
- data/sig/prism/parse_result/comments.rbs +38 -0
- data/sig/prism/parse_result.rbs +4 -0
- data/sig/prism/reflection.rbs +1 -1
- data/sig/prism.rbs +4 -0
- data/src/diagnostic.c +13 -1
- data/src/encoding.c +172 -67
- data/src/node.c +11 -0
- data/src/options.c +17 -7
- data/src/prettyprint.c +18 -0
- data/src/prism.c +1495 -2021
- data/src/serialize.c +9 -1
- data/src/token_type.c +38 -36
- data/src/util/pm_constant_pool.c +1 -1
- data/src/util/pm_string.c +6 -8
- metadata +11 -3
data/src/node.c
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* :markup: markdown */
|
|
2
|
+
|
|
1
3
|
/*----------------------------------------------------------------------------*/
|
|
2
4
|
/* This file is generated by the templates/template.rb script and should not */
|
|
3
5
|
/* be modified manually. See */
|
|
@@ -3803,6 +3805,15 @@ pm_dump_json(pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *no
|
|
|
3803
3805
|
pm_buffer_append_string(buffer, "null", 4);
|
|
3804
3806
|
}
|
|
3805
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
|
+
|
|
3806
3817
|
// Dump the block field
|
|
3807
3818
|
pm_buffer_append_byte(buffer, ',');
|
|
3808
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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* :markup: markdown */
|
|
2
|
+
|
|
1
3
|
/*----------------------------------------------------------------------------*/
|
|
2
4
|
/* This file is generated by the templates/template.rb script and should not */
|
|
3
5
|
/* be modified manually. See */
|
|
@@ -1266,6 +1268,22 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
|
|
|
1266
1268
|
}
|
|
1267
1269
|
}
|
|
1268
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
|
+
|
|
1269
1287
|
// block
|
|
1270
1288
|
{
|
|
1271
1289
|
pm_buffer_concat(output_buffer, prefix_buffer);
|