prism 1.5.2 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 978703c8505b23f80431d302e3d46c42ebb753dfcf69b59f09a86b5eba91ee38
4
- data.tar.gz: d993141f8bcffd753f46367684e37910c01ff614bcde9e51548e16a1c5482a46
3
+ metadata.gz: 2ef507799374ba0281ff3d8ab78fc29f673b3fc213f695ae68c65cf0d38b4bcc
4
+ data.tar.gz: 7610a756cffd1aeb517f135446ae25360568cc00e6d78e748470469bd345463c
5
5
  SHA512:
6
- metadata.gz: 33f416b233e73ce8c395b9a1cbff869de36fa2ca9bdae893f4c716e53e01a408d632b7802776e62afecb2c19bce18004d66dba219831c57894e9436b3d64b294
7
- data.tar.gz: 122a557835cb1adb140fa0615cb983e156602b7f910e7680c6688668b2fece74cc246e3a6b8207d5916250cf3f0845f8deb5538bf3b6953981f2d387ae37f02b
6
+ metadata.gz: 539d064482f82c7fd85c7e8269b1c400fd576b20effbcb857636667ce8818367eea35446bc7ee2decf3cdde7171883e8aeaa154c2bf1b8d7f3c7fa5c12203f08
7
+ data.tar.gz: 59181adcac710bf7697b1dec0556eb306f9cf79d2b7492e0392d9698401dd3abb5a1406fc5d66d1c4d0acbd85d9ebf8e674683e9ec585d765216953f80a75297
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.6.0] - 2025-10-16
10
+
11
+ ### Added
12
+
13
+ - Add support for passing `"current"` as the version option to `Prism.*` APIs.
14
+
15
+ ### Changed
16
+
17
+ - Remove a compiler warning for a missing unsigned cast for a shift value.
18
+
9
19
  ## [1.5.2] - 2025-10-09
10
20
 
11
21
  ### Changed
@@ -685,7 +695,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
685
695
 
686
696
  - 🎉 Initial release! 🎉
687
697
 
688
- [unreleased]: https://github.com/ruby/prism/compare/v1.5.2...HEAD
698
+ [unreleased]: https://github.com/ruby/prism/compare/v1.6.0...HEAD
699
+ [1.6.0]: https://github.com/ruby/prism/compare/v1.5.2...v1.6.0
689
700
  [1.5.2]: https://github.com/ruby/prism/compare/v1.5.1...v1.5.2
690
701
  [1.5.1]: https://github.com/ruby/prism/compare/v1.5.0...v1.5.1
691
702
  [1.5.0]: https://github.com/ruby/prism/compare/v1.4.0...v1.5.0
data/docs/design.md CHANGED
@@ -18,11 +18,11 @@ The templated files contain all of the code required to allocate and initialize
18
18
 
19
19
  In order to provide the best possible error tolerance, the parser is hand-written. It is structured using Pratt parsing, a technique developed by Vaughan Pratt back in the 1970s. Below are a bunch of links to articles and papers that explain Pratt parsing in more detail.
20
20
 
21
- * https://web.archive.org/web/20151223215421/http://hall.org.ua/halls/wizzard/pdf/Vaughan.Pratt.TDOP.pdf
21
+ * https://github.com/tdop/tdop.github.io/raw/master/original.pdf
22
22
  * https://tdop.github.io/
23
23
  * https://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/
24
24
  * https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html
25
- * https://chidiwilliams.com/post/on-recursive-descent-and-pratt-parsing/
25
+ * https://chidiwilliams.com/posts/on-recursive-descent-and-pratt-parsing
26
26
 
27
27
  You can find most of the functions that correspond to constructs in the Pratt parsing algorithm in `prism.c`. As a couple of examples:
28
28
 
data/docs/releasing.md CHANGED
@@ -49,6 +49,7 @@ bundle install
49
49
  ```sh
50
50
  for VERSION in "2.7" "3.0" "3.1" "3.2" "3.3" "3.4"; do docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app -e BUNDLE_GEMFILE="gemfiles/$VERSION/Gemfile" "ruby:$VERSION" bundle update; done
51
51
  docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app -e BUNDLE_GEMFILE="gemfiles/3.5/Gemfile" ruby:3.5.0-preview1 bundle update
52
+ docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app -e BUNDLE_GEMFILE="gemfiles/jruby/Gemfile" jruby:latest bundle update
52
53
  BUNDLE_GEMFILE=gemfiles/truffleruby/Gemfile chruby-exec truffleruby -- bundle update
53
54
  ```
54
55
 
@@ -73,26 +74,4 @@ git push
73
74
  ## Publishing
74
75
 
75
76
  * Update the GitHub release page with a copy of the latest entry in the `CHANGELOG.md` file.
76
- * Publish the gem to [rubygems.org](rubygems.org). Note that you must have access to the `prism` gem to do this.
77
-
78
- ```sh
79
- bundle exec rake release
80
- ```
81
-
82
- * Generate the `wasm` artifact (or download it from GitHub actions and put it in `javascript/src/prism.wasm`).
83
-
84
- ```sh
85
- make wasm
86
- ```
87
-
88
- * Publish the JavaScript package to [npmjs.com](npmjs.com). Note that you must have access to the `@ruby/prism` package to do this.
89
-
90
- ```sh
91
- npm publish
92
- ```
93
-
94
- * Publish the rust crate to [crates.io](crates.io). Note that you must have access to the `ruby-prism-sys` and `ruby-prism` crates to do this.
95
-
96
- ```sh
97
- bundle exec rake cargo:publish:real
98
- ```
77
+ * Push a new tag to the GitHub repository, following the `vX.Y.Z` format.
@@ -25,6 +25,7 @@ VALUE rb_cPrismLexResult;
25
25
  VALUE rb_cPrismParseLexResult;
26
26
  VALUE rb_cPrismStringQuery;
27
27
  VALUE rb_cPrismScope;
28
+ VALUE rb_cPrismCurrentVersionError;
28
29
 
29
30
  VALUE rb_cPrismDebugEncoding;
30
31
 
@@ -199,7 +200,13 @@ build_options_i(VALUE key, VALUE value, VALUE argument) {
199
200
  if (!NIL_P(value)) {
200
201
  const char *version = check_string(value);
201
202
 
202
- if (!pm_options_version_set(options, version, RSTRING_LEN(value))) {
203
+ if (RSTRING_LEN(value) == 7 && strncmp(version, "current", 7) == 0) {
204
+ VALUE current_ruby_value = rb_const_get(rb_cObject, rb_intern("RUBY_VERSION"));
205
+ const char *current_version = RSTRING_PTR(current_ruby_value);
206
+ if (!pm_options_version_set(options, current_version, 3)) {
207
+ rb_exc_raise(rb_exc_new_str(rb_cPrismCurrentVersionError, current_ruby_value));
208
+ }
209
+ } else if (!pm_options_version_set(options, version, RSTRING_LEN(value))) {
203
210
  rb_raise(rb_eArgError, "invalid version: %" PRIsVALUE, value);
204
211
  }
205
212
  }
@@ -888,7 +895,7 @@ parse_input(pm_string_t *input, const pm_options_t *options) {
888
895
  * version of Ruby syntax (which you can trigger with `nil` or
889
896
  * `"latest"`). You may also restrict the syntax to a specific version of
890
897
  * Ruby, e.g., with `"3.3.0"`. To parse with the same syntax version that
891
- * the current Ruby is running use `version: RUBY_VERSION`. Raises
898
+ * the current Ruby is running use `version: "current"`. Raises
892
899
  * ArgumentError if the version is not currently supported by Prism.
893
900
  */
894
901
  static VALUE
@@ -1364,6 +1371,8 @@ Init_prism(void) {
1364
1371
  rb_cPrismStringQuery = rb_define_class_under(rb_cPrism, "StringQuery", rb_cObject);
1365
1372
  rb_cPrismScope = rb_define_class_under(rb_cPrism, "Scope", rb_cObject);
1366
1373
 
1374
+ rb_cPrismCurrentVersionError = rb_const_get(rb_cPrism, rb_intern("CurrentVersionError"));
1375
+
1367
1376
  // Intern all of the IDs eagerly that we support so that we don't have to do
1368
1377
  // it every time we parse.
1369
1378
  rb_id_option_command_line = rb_intern_const("command_line");
@@ -1,7 +1,7 @@
1
1
  #ifndef PRISM_EXT_NODE_H
2
2
  #define PRISM_EXT_NODE_H
3
3
 
4
- #define EXPECTED_PRISM_VERSION "1.5.2"
4
+ #define EXPECTED_PRISM_VERSION "1.6.0"
5
5
 
6
6
  #include <ruby.h>
7
7
  #include <ruby/encoding.h>
@@ -14,16 +14,16 @@
14
14
  /**
15
15
  * The minor version of the Prism library as an int.
16
16
  */
17
- #define PRISM_VERSION_MINOR 5
17
+ #define PRISM_VERSION_MINOR 6
18
18
 
19
19
  /**
20
20
  * The patch version of the Prism library as an int.
21
21
  */
22
- #define PRISM_VERSION_PATCH 2
22
+ #define PRISM_VERSION_PATCH 0
23
23
 
24
24
  /**
25
25
  * The version of the Prism library as a constant string.
26
26
  */
27
- #define PRISM_VERSION "1.5.2"
27
+ #define PRISM_VERSION "1.6.0"
28
28
 
29
29
  #endif
data/lib/prism/ffi.rb CHANGED
@@ -423,7 +423,9 @@ module Prism
423
423
 
424
424
  # Return the value that should be dumped for the version option.
425
425
  def dump_options_version(version)
426
- case version
426
+ current = version == "current"
427
+
428
+ case current ? RUBY_VERSION : version
427
429
  when nil, "latest"
428
430
  0 # Handled in pm_parser_init
429
431
  when /\A3\.3(\.\d+)?\z/
@@ -433,7 +435,11 @@ module Prism
433
435
  when /\A3\.5(\.\d+)?\z/
434
436
  3
435
437
  else
436
- raise ArgumentError, "invalid version: #{version}"
438
+ if current
439
+ raise CurrentVersionError, RUBY_VERSION
440
+ else
441
+ raise ArgumentError, "invalid version: #{version}"
442
+ end
437
443
  end
438
444
  end
439
445
 
@@ -21,11 +21,11 @@ module Prism
21
21
 
22
22
  # The minor version of prism that we are expecting to find in the serialized
23
23
  # strings.
24
- MINOR_VERSION = 5
24
+ MINOR_VERSION = 6
25
25
 
26
26
  # The patch version of prism that we are expecting to find in the serialized
27
27
  # strings.
28
- PATCH_VERSION = 2
28
+ PATCH_VERSION = 0
29
29
 
30
30
  # Deserialize the dumped output from a request to parse or parse_file.
31
31
  #
data/lib/prism.rb CHANGED
@@ -37,6 +37,27 @@ module Prism
37
37
  private_constant :LexCompat
38
38
  private_constant :LexRipper
39
39
 
40
+ # Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
41
+ class CurrentVersionError < ArgumentError
42
+ # Initialize a new exception for the given ruby version string.
43
+ def initialize(version)
44
+ message = +"invalid version: Requested to parse as `version: 'current'`; "
45
+ gem_version =
46
+ begin
47
+ Gem::Version.new(version)
48
+ rescue ArgumentError
49
+ end
50
+
51
+ if gem_version && gem_version < Gem::Version.new("3.3.0")
52
+ message << " #{version} is below the minimum supported syntax."
53
+ else
54
+ message << " #{version} is unknown. Please update the `prism` gem."
55
+ end
56
+
57
+ super(message)
58
+ end
59
+ end
60
+
40
61
  # :call-seq:
41
62
  # Prism::lex_compat(source, **options) -> LexCompat::Result
42
63
  #
data/prism.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prism"
5
- spec.version = "1.5.2"
5
+ spec.version = "1.6.0"
6
6
  spec.authors = ["Shopify"]
7
7
  spec.email = ["ruby@shopify.com"]
8
8
 
data/sig/prism.rbs CHANGED
@@ -6,6 +6,10 @@ module Prism
6
6
  BACKEND: :CEXT | :FFI
7
7
  VERSION: String
8
8
 
9
+ class CurrentVersionError < ArgumentError
10
+ def initialize: (String version) -> void
11
+ end
12
+
9
13
  # Methods taking a Ruby source code string:
10
14
 
11
15
  def self.parse: (
data/src/prism.c CHANGED
@@ -8591,64 +8591,64 @@ parser_lex_magic_comment(pm_parser_t *parser, bool semantic_token_seen) {
8591
8591
 
8592
8592
  static const uint32_t context_terminators[] = {
8593
8593
  [PM_CONTEXT_NONE] = 0,
8594
- [PM_CONTEXT_BEGIN] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8595
- [PM_CONTEXT_BEGIN_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8596
- [PM_CONTEXT_BEGIN_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8597
- [PM_CONTEXT_BEGIN_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8598
- [PM_CONTEXT_BLOCK_BRACES] = (1 << PM_TOKEN_BRACE_RIGHT),
8599
- [PM_CONTEXT_BLOCK_KEYWORDS] = (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ENSURE),
8600
- [PM_CONTEXT_BLOCK_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8601
- [PM_CONTEXT_BLOCK_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8602
- [PM_CONTEXT_BLOCK_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8603
- [PM_CONTEXT_CASE_WHEN] = (1 << PM_TOKEN_KEYWORD_WHEN) | (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_ELSE),
8604
- [PM_CONTEXT_CASE_IN] = (1 << PM_TOKEN_KEYWORD_IN) | (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_ELSE),
8605
- [PM_CONTEXT_CLASS] = (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ENSURE),
8606
- [PM_CONTEXT_CLASS_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8607
- [PM_CONTEXT_CLASS_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8608
- [PM_CONTEXT_CLASS_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8609
- [PM_CONTEXT_DEF] = (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ENSURE),
8610
- [PM_CONTEXT_DEF_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8611
- [PM_CONTEXT_DEF_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8612
- [PM_CONTEXT_DEF_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8613
- [PM_CONTEXT_DEF_PARAMS] = (1 << PM_TOKEN_EOF),
8614
- [PM_CONTEXT_DEFINED] = (1 << PM_TOKEN_EOF),
8615
- [PM_CONTEXT_DEFAULT_PARAMS] = (1 << PM_TOKEN_COMMA) | (1 << PM_TOKEN_PARENTHESIS_RIGHT),
8616
- [PM_CONTEXT_ELSE] = (1 << PM_TOKEN_KEYWORD_END),
8617
- [PM_CONTEXT_ELSIF] = (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_ELSIF) | (1 << PM_TOKEN_KEYWORD_END),
8618
- [PM_CONTEXT_EMBEXPR] = (1 << PM_TOKEN_EMBEXPR_END),
8619
- [PM_CONTEXT_FOR] = (1 << PM_TOKEN_KEYWORD_END),
8620
- [PM_CONTEXT_FOR_INDEX] = (1 << PM_TOKEN_KEYWORD_IN),
8621
- [PM_CONTEXT_IF] = (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_ELSIF) | (1 << PM_TOKEN_KEYWORD_END),
8622
- [PM_CONTEXT_LAMBDA_BRACES] = (1 << PM_TOKEN_BRACE_RIGHT),
8623
- [PM_CONTEXT_LAMBDA_DO_END] = (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ENSURE),
8624
- [PM_CONTEXT_LAMBDA_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8625
- [PM_CONTEXT_LAMBDA_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8626
- [PM_CONTEXT_LAMBDA_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8627
- [PM_CONTEXT_LOOP_PREDICATE] = (1 << PM_TOKEN_KEYWORD_DO) | (1 << PM_TOKEN_KEYWORD_THEN),
8628
- [PM_CONTEXT_MAIN] = (1 << PM_TOKEN_EOF),
8629
- [PM_CONTEXT_MODULE] = (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ENSURE),
8630
- [PM_CONTEXT_MODULE_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8631
- [PM_CONTEXT_MODULE_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8632
- [PM_CONTEXT_MODULE_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8633
- [PM_CONTEXT_MULTI_TARGET] = (1 << PM_TOKEN_EOF),
8634
- [PM_CONTEXT_PARENS] = (1 << PM_TOKEN_PARENTHESIS_RIGHT),
8635
- [PM_CONTEXT_POSTEXE] = (1 << PM_TOKEN_BRACE_RIGHT),
8636
- [PM_CONTEXT_PREDICATE] = (1 << PM_TOKEN_KEYWORD_THEN) | (1 << PM_TOKEN_NEWLINE) | (1 << PM_TOKEN_SEMICOLON),
8637
- [PM_CONTEXT_PREEXE] = (1 << PM_TOKEN_BRACE_RIGHT),
8638
- [PM_CONTEXT_RESCUE_MODIFIER] = (1 << PM_TOKEN_EOF),
8639
- [PM_CONTEXT_SCLASS] = (1 << PM_TOKEN_KEYWORD_END) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ENSURE),
8640
- [PM_CONTEXT_SCLASS_ENSURE] = (1 << PM_TOKEN_KEYWORD_END),
8641
- [PM_CONTEXT_SCLASS_ELSE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_END),
8642
- [PM_CONTEXT_SCLASS_RESCUE] = (1 << PM_TOKEN_KEYWORD_ENSURE) | (1 << PM_TOKEN_KEYWORD_RESCUE) | (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8643
- [PM_CONTEXT_TERNARY] = (1 << PM_TOKEN_EOF),
8644
- [PM_CONTEXT_UNLESS] = (1 << PM_TOKEN_KEYWORD_ELSE) | (1 << PM_TOKEN_KEYWORD_END),
8645
- [PM_CONTEXT_UNTIL] = (1 << PM_TOKEN_KEYWORD_END),
8646
- [PM_CONTEXT_WHILE] = (1 << PM_TOKEN_KEYWORD_END),
8594
+ [PM_CONTEXT_BEGIN] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8595
+ [PM_CONTEXT_BEGIN_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8596
+ [PM_CONTEXT_BEGIN_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8597
+ [PM_CONTEXT_BEGIN_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8598
+ [PM_CONTEXT_BLOCK_BRACES] = (1U << PM_TOKEN_BRACE_RIGHT),
8599
+ [PM_CONTEXT_BLOCK_KEYWORDS] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
8600
+ [PM_CONTEXT_BLOCK_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8601
+ [PM_CONTEXT_BLOCK_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8602
+ [PM_CONTEXT_BLOCK_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8603
+ [PM_CONTEXT_CASE_WHEN] = (1U << PM_TOKEN_KEYWORD_WHEN) | (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_ELSE),
8604
+ [PM_CONTEXT_CASE_IN] = (1U << PM_TOKEN_KEYWORD_IN) | (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_ELSE),
8605
+ [PM_CONTEXT_CLASS] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
8606
+ [PM_CONTEXT_CLASS_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8607
+ [PM_CONTEXT_CLASS_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8608
+ [PM_CONTEXT_CLASS_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8609
+ [PM_CONTEXT_DEF] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
8610
+ [PM_CONTEXT_DEF_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8611
+ [PM_CONTEXT_DEF_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8612
+ [PM_CONTEXT_DEF_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8613
+ [PM_CONTEXT_DEF_PARAMS] = (1U << PM_TOKEN_EOF),
8614
+ [PM_CONTEXT_DEFINED] = (1U << PM_TOKEN_EOF),
8615
+ [PM_CONTEXT_DEFAULT_PARAMS] = (1U << PM_TOKEN_COMMA) | (1U << PM_TOKEN_PARENTHESIS_RIGHT),
8616
+ [PM_CONTEXT_ELSE] = (1U << PM_TOKEN_KEYWORD_END),
8617
+ [PM_CONTEXT_ELSIF] = (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_ELSIF) | (1U << PM_TOKEN_KEYWORD_END),
8618
+ [PM_CONTEXT_EMBEXPR] = (1U << PM_TOKEN_EMBEXPR_END),
8619
+ [PM_CONTEXT_FOR] = (1U << PM_TOKEN_KEYWORD_END),
8620
+ [PM_CONTEXT_FOR_INDEX] = (1U << PM_TOKEN_KEYWORD_IN),
8621
+ [PM_CONTEXT_IF] = (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_ELSIF) | (1U << PM_TOKEN_KEYWORD_END),
8622
+ [PM_CONTEXT_LAMBDA_BRACES] = (1U << PM_TOKEN_BRACE_RIGHT),
8623
+ [PM_CONTEXT_LAMBDA_DO_END] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
8624
+ [PM_CONTEXT_LAMBDA_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8625
+ [PM_CONTEXT_LAMBDA_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8626
+ [PM_CONTEXT_LAMBDA_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8627
+ [PM_CONTEXT_LOOP_PREDICATE] = (1U << PM_TOKEN_KEYWORD_DO) | (1U << PM_TOKEN_KEYWORD_THEN),
8628
+ [PM_CONTEXT_MAIN] = (1U << PM_TOKEN_EOF),
8629
+ [PM_CONTEXT_MODULE] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
8630
+ [PM_CONTEXT_MODULE_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8631
+ [PM_CONTEXT_MODULE_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8632
+ [PM_CONTEXT_MODULE_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8633
+ [PM_CONTEXT_MULTI_TARGET] = (1U << PM_TOKEN_EOF),
8634
+ [PM_CONTEXT_PARENS] = (1U << PM_TOKEN_PARENTHESIS_RIGHT),
8635
+ [PM_CONTEXT_POSTEXE] = (1U << PM_TOKEN_BRACE_RIGHT),
8636
+ [PM_CONTEXT_PREDICATE] = (1U << PM_TOKEN_KEYWORD_THEN) | (1U << PM_TOKEN_NEWLINE) | (1U << PM_TOKEN_SEMICOLON),
8637
+ [PM_CONTEXT_PREEXE] = (1U << PM_TOKEN_BRACE_RIGHT),
8638
+ [PM_CONTEXT_RESCUE_MODIFIER] = (1U << PM_TOKEN_EOF),
8639
+ [PM_CONTEXT_SCLASS] = (1U << PM_TOKEN_KEYWORD_END) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ENSURE),
8640
+ [PM_CONTEXT_SCLASS_ENSURE] = (1U << PM_TOKEN_KEYWORD_END),
8641
+ [PM_CONTEXT_SCLASS_ELSE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_END),
8642
+ [PM_CONTEXT_SCLASS_RESCUE] = (1U << PM_TOKEN_KEYWORD_ENSURE) | (1U << PM_TOKEN_KEYWORD_RESCUE) | (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8643
+ [PM_CONTEXT_TERNARY] = (1U << PM_TOKEN_EOF),
8644
+ [PM_CONTEXT_UNLESS] = (1U << PM_TOKEN_KEYWORD_ELSE) | (1U << PM_TOKEN_KEYWORD_END),
8645
+ [PM_CONTEXT_UNTIL] = (1U << PM_TOKEN_KEYWORD_END),
8646
+ [PM_CONTEXT_WHILE] = (1U << PM_TOKEN_KEYWORD_END),
8647
8647
  };
8648
8648
 
8649
8649
  static inline bool
8650
8650
  context_terminator(pm_context_t context, pm_token_t *token) {
8651
- return token->type < 32 && (context_terminators[context] & (1 << token->type));
8651
+ return token->type < 32 && (context_terminators[context] & (1U << token->type));
8652
8652
  }
8653
8653
 
8654
8654
  /**
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.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-09 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
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.6.2
192
+ rubygems_version: 3.6.9
193
193
  specification_version: 4
194
194
  summary: Prism Ruby parser
195
195
  test_files: []