prism 1.3.0 → 1.4.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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/config.yml +9 -0
  4. data/docs/releasing.md +1 -1
  5. data/docs/ruby_api.md +1 -1
  6. data/ext/prism/api_node.c +1814 -1303
  7. data/ext/prism/extension.c +230 -109
  8. data/ext/prism/extension.h +4 -4
  9. data/include/prism/ast.h +16 -0
  10. data/include/prism/defines.h +4 -1
  11. data/include/prism/options.h +47 -1
  12. data/include/prism/util/pm_buffer.h +10 -0
  13. data/include/prism/version.h +2 -2
  14. data/include/prism.h +4 -4
  15. data/lib/prism/dot_visitor.rb +16 -0
  16. data/lib/prism/dsl.rb +10 -2
  17. data/lib/prism/ffi.rb +45 -27
  18. data/lib/prism/inspect_visitor.rb +2 -1
  19. data/lib/prism/node.rb +48 -10
  20. data/lib/prism/parse_result/newlines.rb +1 -1
  21. data/lib/prism/parse_result.rb +52 -0
  22. data/lib/prism/polyfill/append_as_bytes.rb +15 -0
  23. data/lib/prism/reflection.rb +2 -2
  24. data/lib/prism/serialize.rb +1252 -765
  25. data/lib/prism/translation/parser/builder.rb +61 -0
  26. data/lib/prism/translation/parser/compiler.rb +192 -136
  27. data/lib/prism/translation/parser/lexer.rb +435 -61
  28. data/lib/prism/translation/parser.rb +51 -3
  29. data/lib/prism/translation/parser35.rb +12 -0
  30. data/lib/prism/translation/ripper.rb +13 -3
  31. data/lib/prism/translation/ruby_parser.rb +5 -4
  32. data/lib/prism/translation.rb +1 -0
  33. data/lib/prism.rb +3 -3
  34. data/prism.gemspec +5 -1
  35. data/rbi/prism/dsl.rbi +6 -3
  36. data/rbi/prism/node.rbi +22 -7
  37. data/rbi/prism/parse_result.rbi +17 -0
  38. data/rbi/prism/translation/parser35.rbi +6 -0
  39. data/rbi/prism.rbi +39 -36
  40. data/sig/prism/dsl.rbs +4 -2
  41. data/sig/prism/node.rbs +17 -7
  42. data/sig/prism/parse_result.rbs +10 -0
  43. data/sig/prism/serialize.rbs +4 -2
  44. data/sig/prism.rbs +22 -1
  45. data/src/diagnostic.c +2 -2
  46. data/src/node.c +21 -0
  47. data/src/options.c +31 -0
  48. data/src/prettyprint.c +30 -0
  49. data/src/prism.c +374 -118
  50. data/src/serialize.c +6 -0
  51. data/src/util/pm_buffer.c +40 -0
  52. data/src/util/pm_constant_pool.c +6 -2
  53. data/src/util/pm_strncasecmp.c +13 -1
  54. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc945a81285247ae139110607116e5ad0211e008f8e69d76002238755deca5dc
4
- data.tar.gz: 81703e9b86fd950af63fbea201f8cd9ddec3a3a330d24c80aba7461782bb347b
3
+ metadata.gz: a0209a58426470fc6afedb5922c9bf9264cb9ccd2debbef68fb1a307a4d1be78
4
+ data.tar.gz: 491a11ab3d9d840f4ac228e8b79e85ddb24ae1f82b3cee7cbdb1003bea9f33f2
5
5
  SHA512:
6
- metadata.gz: 39fb25eec8d603cd26f31ce75281e3cf257f8f21451e6687eda11d14e090013651284b1f7b35612004b0603105883d0e1d8de1d82b192ce5238843e03203e9fa
7
- data.tar.gz: 4544a22d735276ca60cf3dd4e7b91ce64aa60539d555466d73d3eebb91502a0a357232bd1c0722232f3745481e554ba6ab2eb7a23f05a25e5d0c114f9077dc52
6
+ metadata.gz: 30b9cb40262daf924f047034c6314b418c367691eccc188acd08328bd92e6a51d3818a91c3d17fb5dc3f159129186ef6c4bd7bfbe815b9c8f268fa9b938fd1ac
7
+ data.tar.gz: a1b9ab207e98c779b0d371f2f14e6c5fb8315273af7518bc8e8135ba3dff4f1385787e169a4e4c146aa1ea7c10f6fce4f82d37958f88e8f68f1e8dabe54115bf
data/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ 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.4.0] - 2025-03-18
10
+
11
+ ### Added
12
+
13
+ - Support `3.5` as a version option.
14
+ - Many, many compatibility fixes for the parser translation layer.
15
+ - Handle escapes in named capture names.
16
+ - The `freeze` option is added to the various `Prism::` APIs to deeply freeze the AST.
17
+ - Properly support `it` for the parser and ruby_parser translation layers.
18
+ - Track the `then` keyword on `rescue` nodes.
19
+ - Add a `multiple_statements?` flag to parentheses nodes to support desired `defined?` behavior.
20
+
21
+ ### Changed
22
+
23
+ - The strings used in the AST are now frozen.
24
+ - Fixed handling escaped characters after control sequences in character literals.
25
+ - Fix reading off the end of an unterminated global variable.
26
+ - Raise a syntax error for defining `[]=` with endless method syntax.
27
+ - Increase value of `PRISM_DEPTH_MAXIMUM` to `10000`.
28
+ - Freeze `Prism::VERSION`.
29
+ - Fix up rescue modifier precedence.
30
+
9
31
  ## [1.3.0] - 2024-12-21
10
32
 
11
33
  ### Added
@@ -627,7 +649,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
627
649
 
628
650
  - 🎉 Initial release! 🎉
629
651
 
630
- [unreleased]: https://github.com/ruby/prism/compare/v1.3.0...HEAD
652
+ [unreleased]: https://github.com/ruby/prism/compare/v1.4.0...HEAD
653
+ [1.4.0]: https://github.com/ruby/prism/compare/v1.3.0...v1.4.0
631
654
  [1.3.0]: https://github.com/ruby/prism/compare/v1.2.0...v1.3.0
632
655
  [1.2.0]: https://github.com/ruby/prism/compare/v1.1.0...v1.2.0
633
656
  [1.1.0]: https://github.com/ruby/prism/compare/v1.0.0...v1.1.0
data/config.yml CHANGED
@@ -719,6 +719,11 @@ flags:
719
719
  - name: REPEATED_PARAMETER
720
720
  comment: "a parameter name that has been repeated in the method signature"
721
721
  comment: Flags for parameter nodes.
722
+ - name: ParenthesesNodeFlags
723
+ values:
724
+ - name: MULTIPLE_STATEMENTS
725
+ comment: "parentheses that contain multiple potentially void statements"
726
+ comment: Flags for parentheses nodes.
722
727
  - name: RangeFlags
723
728
  values:
724
729
  - name: EXCLUDE_END
@@ -3140,6 +3145,7 @@ nodes:
3140
3145
  - EmbeddedStatementsNode
3141
3146
  - EmbeddedVariableNode
3142
3147
  - InterpolatedStringNode # `"a" "#{b}"`
3148
+ - on error: XStringNode # `<<`FOO` "bar"
3143
3149
  - name: closing_loc
3144
3150
  type: location?
3145
3151
  newline: parts
@@ -3851,6 +3857,7 @@ nodes:
3851
3857
  ^^^^^^^
3852
3858
  end
3853
3859
  - name: ParenthesesNode
3860
+ flags: ParenthesesNodeFlags
3854
3861
  fields:
3855
3862
  - name: body
3856
3863
  type: node?
@@ -4084,6 +4091,8 @@ nodes:
4084
4091
  - on error: BackReferenceReadNode # => begin; rescue => $&; end
4085
4092
  - on error: NumberedReferenceReadNode # => begin; rescue => $1; end
4086
4093
  - on error: MissingNode # begin; rescue =>; end
4094
+ - name: then_keyword_loc
4095
+ type: location?
4087
4096
  - name: statements
4088
4097
  type: node?
4089
4098
  kind: StatementsNode
data/docs/releasing.md CHANGED
@@ -40,7 +40,7 @@ ruby -pi -e 'gsub(/^ruby-prism-sys = \{ version = ".+?"/, %Q{ruby-prism-sys = \{
40
40
  * Update the `Gemfile.lock` file:
41
41
 
42
42
  ```sh
43
- chruby ruby-3.4.0-dev
43
+ chruby ruby-3.5.0-dev
44
44
  bundle install
45
45
  ```
46
46
 
data/docs/ruby_api.md CHANGED
@@ -23,7 +23,7 @@ The full API is documented below.
23
23
  * `Prism.parse_stream(io)` - parse the syntax tree corresponding to the source that is read out of the given IO object using the `#gets` method and return it within a parse result
24
24
  * `Prism.parse_lex(source)` - parse the syntax tree corresponding to the given source string and return it within a parse result, along with the tokens
25
25
  * `Prism.parse_lex_file(filepath)` - parse the syntax tree corresponding to the given source file and return it within a parse result, along with the tokens
26
- * `Prism.load(source, serialized)` - load the serialized syntax tree using the source as a reference into a syntax tree
26
+ * `Prism.load(source, serialized, freeze = false)` - load the serialized syntax tree using the source as a reference into a syntax tree
27
27
  * `Prism.parse_comments(source)` - parse the comments corresponding to the given source string and return them
28
28
  * `Prism.parse_file_comments(source)` - parse the comments corresponding to the given source file and return them
29
29
  * `Prism.parse_success?(source)` - parse the syntax tree corresponding to the given source string and return true if it was parsed without errors