prism 1.5.1 → 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 +44 -1
- data/Makefile +5 -4
- data/README.md +2 -1
- data/config.yml +30 -4
- 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 +1 -1
- data/docs/releasing.md +6 -25
- data/ext/prism/api_node.c +7 -3
- data/ext/prism/extconf.rb +1 -1
- data/ext/prism/extension.c +10 -2
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +85 -21
- data/include/prism/diagnostic.h +3 -0
- data/include/prism/options.h +8 -2
- data/include/prism/parser.h +3 -0
- data/include/prism/version.h +3 -3
- 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 +11 -3
- data/lib/prism/inspect_visitor.rb +1 -0
- data/lib/prism/node.rb +53 -14
- data/lib/prism/parse_result.rb +2 -15
- data/lib/prism/polyfill/scan_byte.rb +1 -1
- data/lib/prism/polyfill/warn.rb +16 -22
- data/lib/prism/reflection.rb +1 -1
- data/lib/prism/serialize.rb +8 -5
- data/lib/prism/translation/parser/compiler.rb +16 -16
- data/lib/prism/translation/parser.rb +12 -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 +54 -19
- data/lib/prism/translation.rb +2 -0
- data/lib/prism.rb +20 -0
- 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/sig/prism.rbs +4 -0
- data/src/diagnostic.c +7 -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 +1287 -1931
- data/src/serialize.c +7 -1
- data/src/token_type.c +2 -2
- data/src/util/pm_constant_pool.c +1 -1
- data/src/util/pm_string.c +6 -8
- metadata +7 -3
data/src/serialize.c
CHANGED
|
@@ -395,6 +395,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
|
|
|
395
395
|
pm_buffer_append_byte(buffer, 1);
|
|
396
396
|
pm_serialize_location(parser, &((pm_call_node_t *)node)->closing_loc, buffer);
|
|
397
397
|
}
|
|
398
|
+
if (((pm_call_node_t *)node)->equal_loc.start == NULL) {
|
|
399
|
+
pm_buffer_append_byte(buffer, 0);
|
|
400
|
+
} else {
|
|
401
|
+
pm_buffer_append_byte(buffer, 1);
|
|
402
|
+
pm_serialize_location(parser, &((pm_call_node_t *)node)->equal_loc, buffer);
|
|
403
|
+
}
|
|
398
404
|
if (((pm_call_node_t *)node)->block == NULL) {
|
|
399
405
|
pm_buffer_append_byte(buffer, 0);
|
|
400
406
|
} else {
|
|
@@ -2177,7 +2183,7 @@ pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer)
|
|
|
2177
2183
|
// buffer offset. We will add a leading 1 to indicate that this
|
|
2178
2184
|
// is a buffer offset.
|
|
2179
2185
|
uint32_t content_offset = pm_sizet_to_u32(buffer->length);
|
|
2180
|
-
uint32_t owned_mask =
|
|
2186
|
+
uint32_t owned_mask = 1U << 31;
|
|
2181
2187
|
|
|
2182
2188
|
assert(content_offset < owned_mask);
|
|
2183
2189
|
content_offset |= owned_mask;
|
data/src/token_type.c
CHANGED
|
@@ -48,6 +48,8 @@ pm_token_type_name(pm_token_type_t token_type) {
|
|
|
48
48
|
return "NEWLINE";
|
|
49
49
|
case PM_TOKEN_PARENTHESIS_RIGHT:
|
|
50
50
|
return "PARENTHESIS_RIGHT";
|
|
51
|
+
case PM_TOKEN_PIPE:
|
|
52
|
+
return "PIPE";
|
|
51
53
|
case PM_TOKEN_SEMICOLON:
|
|
52
54
|
return "SEMICOLON";
|
|
53
55
|
case PM_TOKEN_AMPERSAND:
|
|
@@ -280,8 +282,6 @@ pm_token_type_name(pm_token_type_t token_type) {
|
|
|
280
282
|
return "PERCENT_UPPER_I";
|
|
281
283
|
case PM_TOKEN_PERCENT_UPPER_W:
|
|
282
284
|
return "PERCENT_UPPER_W";
|
|
283
|
-
case PM_TOKEN_PIPE:
|
|
284
|
-
return "PIPE";
|
|
285
285
|
case PM_TOKEN_PIPE_EQUAL:
|
|
286
286
|
return "PIPE_EQUAL";
|
|
287
287
|
case PM_TOKEN_PIPE_PIPE:
|
data/src/util/pm_constant_pool.c
CHANGED
|
@@ -264,7 +264,7 @@ pm_constant_pool_insert(pm_constant_pool_t *pool, const uint8_t *start, size_t l
|
|
|
264
264
|
// constant and replace it with the shared constant.
|
|
265
265
|
xfree((void *) constant->start);
|
|
266
266
|
constant->start = start;
|
|
267
|
-
bucket->type = (unsigned int) (
|
|
267
|
+
bucket->type = (unsigned int) (type & 0x3);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
return bucket->id;
|
data/src/util/pm_string.c
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#include "prism/util/pm_string.h"
|
|
2
2
|
|
|
3
|
+
static const uint8_t empty_source[] = "";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Returns the size of the pm_string_t struct. This is necessary to allocate the
|
|
5
7
|
* correct amount of memory in the FFI backend.
|
|
@@ -133,8 +135,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
|
|
|
133
135
|
// the source to a constant empty string and return.
|
|
134
136
|
if (file_size == 0) {
|
|
135
137
|
pm_string_file_handle_close(&handle);
|
|
136
|
-
|
|
137
|
-
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
|
138
|
+
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 };
|
|
138
139
|
return PM_STRING_INIT_SUCCESS;
|
|
139
140
|
}
|
|
140
141
|
|
|
@@ -182,8 +183,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
|
|
|
182
183
|
|
|
183
184
|
if (size == 0) {
|
|
184
185
|
close(fd);
|
|
185
|
-
|
|
186
|
-
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
|
186
|
+
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 };
|
|
187
187
|
return PM_STRING_INIT_SUCCESS;
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -225,8 +225,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) {
|
|
|
225
225
|
// the source to a constant empty string and return.
|
|
226
226
|
if (file_size == 0) {
|
|
227
227
|
pm_string_file_handle_close(&handle);
|
|
228
|
-
|
|
229
|
-
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
|
228
|
+
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 };
|
|
230
229
|
return PM_STRING_INIT_SUCCESS;
|
|
231
230
|
}
|
|
232
231
|
|
|
@@ -278,8 +277,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) {
|
|
|
278
277
|
size_t size = (size_t) sb.st_size;
|
|
279
278
|
if (size == 0) {
|
|
280
279
|
close(fd);
|
|
281
|
-
|
|
282
|
-
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
|
280
|
+
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = empty_source, .length = 0 };
|
|
283
281
|
return PM_STRING_INIT_SUCCESS;
|
|
284
282
|
}
|
|
285
283
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prism
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shopify
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
email:
|
|
13
13
|
- ruby@shopify.com
|
|
@@ -106,6 +106,8 @@ files:
|
|
|
106
106
|
- lib/prism/translation/parser33.rb
|
|
107
107
|
- lib/prism/translation/parser34.rb
|
|
108
108
|
- lib/prism/translation/parser35.rb
|
|
109
|
+
- lib/prism/translation/parser40.rb
|
|
110
|
+
- lib/prism/translation/parser41.rb
|
|
109
111
|
- lib/prism/translation/parser_current.rb
|
|
110
112
|
- lib/prism/translation/ripper.rb
|
|
111
113
|
- lib/prism/translation/ripper/sexp.rb
|
|
@@ -126,6 +128,8 @@ files:
|
|
|
126
128
|
- rbi/prism/translation/parser33.rbi
|
|
127
129
|
- rbi/prism/translation/parser34.rbi
|
|
128
130
|
- rbi/prism/translation/parser35.rbi
|
|
131
|
+
- rbi/prism/translation/parser40.rbi
|
|
132
|
+
- rbi/prism/translation/parser41.rbi
|
|
129
133
|
- rbi/prism/translation/ripper.rbi
|
|
130
134
|
- rbi/prism/visitor.rbi
|
|
131
135
|
- sig/prism.rbs
|
|
@@ -189,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
189
193
|
- !ruby/object:Gem::Version
|
|
190
194
|
version: '0'
|
|
191
195
|
requirements: []
|
|
192
|
-
rubygems_version: 3.6.
|
|
196
|
+
rubygems_version: 3.6.9
|
|
193
197
|
specification_version: 4
|
|
194
198
|
summary: Prism Ruby parser
|
|
195
199
|
test_files: []
|