prism 1.5.1 → 1.9.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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +74 -1
  3. data/Makefile +12 -5
  4. data/README.md +2 -1
  5. data/config.yml +34 -8
  6. data/docs/build_system.md +2 -2
  7. data/docs/cruby_compilation.md +1 -1
  8. data/docs/design.md +2 -2
  9. data/docs/parser_translation.md +1 -1
  10. data/docs/releasing.md +4 -25
  11. data/docs/ripper_translation.md +8 -17
  12. data/docs/ruby_api.md +1 -0
  13. data/ext/prism/api_node.c +7 -3
  14. data/ext/prism/extconf.rb +1 -1
  15. data/ext/prism/extension.c +10 -2
  16. data/ext/prism/extension.h +1 -1
  17. data/include/prism/ast.h +89 -25
  18. data/include/prism/diagnostic.h +3 -0
  19. data/include/prism/options.h +8 -2
  20. data/include/prism/parser.h +3 -0
  21. data/include/prism/version.h +3 -3
  22. data/include/prism.h +1 -1
  23. data/lib/prism/compiler.rb +152 -152
  24. data/lib/prism/dot_visitor.rb +5 -0
  25. data/lib/prism/dsl.rb +2 -2
  26. data/lib/prism/ffi.rb +11 -3
  27. data/lib/prism/inspect_visitor.rb +1 -0
  28. data/lib/prism/lex_compat.rb +133 -150
  29. data/lib/prism/node.rb +1184 -34
  30. data/lib/prism/parse_result.rb +11 -15
  31. data/lib/prism/polyfill/scan_byte.rb +1 -1
  32. data/lib/prism/polyfill/warn.rb +16 -22
  33. data/lib/prism/reflection.rb +1 -1
  34. data/lib/prism/serialize.rb +8 -5
  35. data/lib/prism/translation/parser/compiler.rb +16 -16
  36. data/lib/prism/translation/parser.rb +12 -3
  37. data/lib/prism/translation/parser_current.rb +5 -3
  38. data/lib/prism/translation/parser_versions.rb +36 -0
  39. data/lib/prism/translation/ripper/filter.rb +53 -0
  40. data/lib/prism/translation/ripper/lexer.rb +135 -0
  41. data/lib/prism/translation/ripper.rb +86 -40
  42. data/lib/prism/translation/ruby_parser.rb +55 -20
  43. data/lib/prism/translation.rb +5 -3
  44. data/lib/prism/visitor.rb +152 -152
  45. data/lib/prism.rb +21 -14
  46. data/prism.gemspec +5 -7
  47. data/rbi/prism/dsl.rbi +3 -3
  48. data/rbi/prism/node.rbi +24 -8
  49. data/rbi/prism/translation/parser_versions.rbi +23 -0
  50. data/rbi/prism.rbi +0 -3
  51. data/sig/prism/dsl.rbs +2 -2
  52. data/sig/prism/node.rbs +22 -8
  53. data/sig/prism/parse_result.rbs +1 -0
  54. data/sig/prism.rbs +58 -40
  55. data/src/diagnostic.c +7 -1
  56. data/src/encoding.c +172 -67
  57. data/src/node.c +9 -0
  58. data/src/options.c +17 -7
  59. data/src/prettyprint.c +16 -0
  60. data/src/prism.c +1335 -1958
  61. data/src/serialize.c +7 -1
  62. data/src/token_type.c +2 -2
  63. data/src/util/pm_constant_pool.c +1 -1
  64. data/src/util/pm_string.c +6 -8
  65. metadata +7 -9
  66. data/lib/prism/translation/parser33.rb +0 -13
  67. data/lib/prism/translation/parser34.rb +0 -13
  68. data/lib/prism/translation/parser35.rb +0 -13
  69. data/rbi/prism/translation/parser33.rbi +0 -6
  70. data/rbi/prism/translation/parser34.rbi +0 -6
  71. data/rbi/prism/translation/parser35.rbi +0 -6
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 = (uint32_t) (1 << 31);
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:
@@ -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) (PM_CONSTANT_POOL_BUCKET_DEFAULT & 0x3);
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
- const uint8_t source[] = "";
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
- const uint8_t source[] = "";
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
- const uint8_t source[] = "";
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
- const uint8_t source[] = "";
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.5.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-09-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  email:
13
13
  - ruby@shopify.com
@@ -103,11 +103,11 @@ files:
103
103
  - lib/prism/translation/parser/builder.rb
104
104
  - lib/prism/translation/parser/compiler.rb
105
105
  - lib/prism/translation/parser/lexer.rb
106
- - lib/prism/translation/parser33.rb
107
- - lib/prism/translation/parser34.rb
108
- - lib/prism/translation/parser35.rb
109
106
  - lib/prism/translation/parser_current.rb
107
+ - lib/prism/translation/parser_versions.rb
110
108
  - lib/prism/translation/ripper.rb
109
+ - lib/prism/translation/ripper/filter.rb
110
+ - lib/prism/translation/ripper/lexer.rb
111
111
  - lib/prism/translation/ripper/sexp.rb
112
112
  - lib/prism/translation/ripper/shim.rb
113
113
  - lib/prism/translation/ruby_parser.rb
@@ -123,9 +123,7 @@ files:
123
123
  - rbi/prism/reflection.rbi
124
124
  - rbi/prism/string_query.rbi
125
125
  - rbi/prism/translation/parser.rbi
126
- - rbi/prism/translation/parser33.rbi
127
- - rbi/prism/translation/parser34.rbi
128
- - rbi/prism/translation/parser35.rbi
126
+ - rbi/prism/translation/parser_versions.rbi
129
127
  - rbi/prism/translation/ripper.rbi
130
128
  - rbi/prism/visitor.rbi
131
129
  - sig/prism.rbs
@@ -189,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
187
  - !ruby/object:Gem::Version
190
188
  version: '0'
191
189
  requirements: []
192
- rubygems_version: 3.6.2
190
+ rubygems_version: 3.6.9
193
191
  specification_version: 4
194
192
  summary: Prism Ruby parser
195
193
  test_files: []
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- # :markup: markdown
3
-
4
- module Prism
5
- module Translation
6
- # This class is the entry-point for Ruby 3.3 of `Prism::Translation::Parser`.
7
- class Parser33 < Parser
8
- def version # :nodoc:
9
- 33
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- # :markup: markdown
3
-
4
- module Prism
5
- module Translation
6
- # This class is the entry-point for Ruby 3.4 of `Prism::Translation::Parser`.
7
- class Parser34 < Parser
8
- def version # :nodoc:
9
- 34
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- # :markup: markdown
3
-
4
- module Prism
5
- module Translation
6
- # This class is the entry-point for Ruby 3.5 of `Prism::Translation::Parser`.
7
- class Parser35 < Parser
8
- def version # :nodoc:
9
- 35
10
- end
11
- end
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- # typed: strict
2
-
3
- class Prism::Translation::Parser33 < Prism::Translation::Parser
4
- sig { override.returns(Integer) }
5
- def version; end
6
- end
@@ -1,6 +0,0 @@
1
- # typed: strict
2
-
3
- class Prism::Translation::Parser34 < Prism::Translation::Parser
4
- sig { override.returns(Integer) }
5
- def version; end
6
- end
@@ -1,6 +0,0 @@
1
- # typed: strict
2
-
3
- class Prism::Translation::Parser35 < Prism::Translation::Parser
4
- sig { override.returns(Integer) }
5
- def version; end
6
- end