prism 0.29.0 → 1.1.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -1
  3. data/CONTRIBUTING.md +0 -4
  4. data/README.md +4 -0
  5. data/config.yml +498 -145
  6. data/docs/fuzzing.md +1 -1
  7. data/docs/parsing_rules.md +4 -1
  8. data/docs/ripper_translation.md +22 -0
  9. data/docs/serialization.md +3 -0
  10. data/ext/prism/api_node.c +2858 -2082
  11. data/ext/prism/extconf.rb +1 -1
  12. data/ext/prism/extension.c +203 -421
  13. data/ext/prism/extension.h +2 -2
  14. data/include/prism/ast.h +1732 -453
  15. data/include/prism/defines.h +36 -0
  16. data/include/prism/diagnostic.h +23 -6
  17. data/include/prism/node.h +0 -21
  18. data/include/prism/options.h +94 -3
  19. data/include/prism/parser.h +57 -28
  20. data/include/prism/regexp.h +18 -8
  21. data/include/prism/static_literals.h +3 -2
  22. data/include/prism/util/pm_char.h +1 -2
  23. data/include/prism/util/pm_constant_pool.h +0 -8
  24. data/include/prism/util/pm_integer.h +22 -15
  25. data/include/prism/util/pm_newline_list.h +11 -0
  26. data/include/prism/util/pm_string.h +28 -12
  27. data/include/prism/version.h +3 -3
  28. data/include/prism.h +0 -11
  29. data/lib/prism/compiler.rb +3 -0
  30. data/lib/prism/desugar_compiler.rb +111 -74
  31. data/lib/prism/dispatcher.rb +16 -1
  32. data/lib/prism/dot_visitor.rb +45 -34
  33. data/lib/prism/dsl.rb +660 -468
  34. data/lib/prism/ffi.rb +64 -6
  35. data/lib/prism/inspect_visitor.rb +294 -64
  36. data/lib/prism/lex_compat.rb +1 -1
  37. data/lib/prism/mutation_compiler.rb +11 -6
  38. data/lib/prism/node.rb +2469 -4973
  39. data/lib/prism/node_ext.rb +91 -14
  40. data/lib/prism/parse_result/comments.rb +0 -7
  41. data/lib/prism/parse_result/errors.rb +65 -0
  42. data/lib/prism/parse_result/newlines.rb +101 -11
  43. data/lib/prism/parse_result.rb +43 -3
  44. data/lib/prism/reflection.rb +10 -8
  45. data/lib/prism/serialize.rb +484 -609
  46. data/lib/prism/translation/parser/compiler.rb +152 -132
  47. data/lib/prism/translation/parser/lexer.rb +26 -4
  48. data/lib/prism/translation/parser.rb +9 -4
  49. data/lib/prism/translation/ripper.rb +22 -20
  50. data/lib/prism/translation/ruby_parser.rb +73 -13
  51. data/lib/prism/visitor.rb +3 -0
  52. data/lib/prism.rb +0 -4
  53. data/prism.gemspec +3 -5
  54. data/rbi/prism/dsl.rbi +521 -0
  55. data/rbi/prism/node.rbi +744 -4837
  56. data/rbi/prism/visitor.rbi +3 -0
  57. data/rbi/prism.rbi +36 -30
  58. data/sig/prism/dsl.rbs +190 -303
  59. data/sig/prism/mutation_compiler.rbs +1 -0
  60. data/sig/prism/node.rbs +759 -628
  61. data/sig/prism/parse_result.rbs +2 -0
  62. data/sig/prism/visitor.rbs +1 -0
  63. data/sig/prism.rbs +103 -64
  64. data/src/diagnostic.c +62 -28
  65. data/src/node.c +499 -1754
  66. data/src/options.c +76 -27
  67. data/src/prettyprint.c +156 -112
  68. data/src/prism.c +2773 -2081
  69. data/src/regexp.c +202 -69
  70. data/src/serialize.c +170 -50
  71. data/src/static_literals.c +63 -84
  72. data/src/token_type.c +4 -4
  73. data/src/util/pm_constant_pool.c +0 -8
  74. data/src/util/pm_integer.c +53 -25
  75. data/src/util/pm_newline_list.c +29 -0
  76. data/src/util/pm_string.c +130 -80
  77. data/src/util/pm_strpbrk.c +32 -6
  78. metadata +4 -6
  79. data/include/prism/util/pm_string_list.h +0 -44
  80. data/lib/prism/debug.rb +0 -249
  81. data/lib/prism/translation/parser/rubocop.rb +0 -73
  82. data/src/util/pm_string_list.c +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ac8167684c0f975fdba449e77206d97756f6c39f22ce871f79a79a61260503f
4
- data.tar.gz: 6a2dd5c0a47df7c8c575ad2e5b344c789d548e93cfe82e5fa29974d46a52bb3c
3
+ metadata.gz: ea89f88aef2ec51d2cfb5868cf873ab256393f5ba632381a3a53631c2506dbc3
4
+ data.tar.gz: 4da85d79e85d5cca843eb6e71cea07efc80a6e77608aa3027e1cd75c3c3b735a
5
5
  SHA512:
6
- metadata.gz: dfa7fe63285b85cb45aa0be681916d6891ee5e5adf2162ab5c18423417f7938afc99f00eca8fd6187fbd0b7168af088d932fbda3c1361d1c73953f39329bed70
7
- data.tar.gz: 79bc51db60600d74a6bfbeae5eba3a8ec505e9809d0f7ff0b05563f1f7a8cd284cc293233397323a443217a4a5271f90b4c40516168ae3a8be0ddc2d7376cef9
6
+ metadata.gz: 1b7f92a58fa176b04aab230f49dcdc08f9b810575426402db6fc9eee0921ac5ddddf1f01f18bb9429a914955759e8d4cee5a70674e14eb0b0169018ce615780e
7
+ data.tar.gz: e4a5a6ba40bc7692c6c904f452dd8ff18881703c99d51969507619368748eec29936dc3f521e8967b6d728ea331f26f9f670b44daedde2106f649104aefe0c30
data/CHANGELOG.md CHANGED
@@ -6,6 +6,79 @@ 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.1.0] - 2024-10-02
10
+
11
+ ### Added
12
+
13
+ - Explicitly type each child node field in the Ruby API.
14
+ - Add the `main_script` option to the parse APIs, which controls whether or not shebangs are considered.
15
+ - Add the `partial_script` options to the parse APIs, which controls whether or not jumps that would otherwise be considered invalid are allowed. This is useful for parsing things like ERB sources, where you know it will be evaluated in a different context. Note that this functionality is replacing the previous idiom of passing in a list of scopes to indicate an `eval` context, because that behavior has changed upstream in `ruby/ruby`.
16
+ - Add `ArgumentsNode#contains_multiple_splats?`.
17
+ - Add `ArgumentsNode#contains_forwarding?`.
18
+ - Accept all valid Ruby versions for the `version` option on parse APIs.
19
+ - Accept version shorthands like `"3.3"` and `"3.4"` for the `version` option on parse APIs.
20
+ - Support a max depth to protect against malicious payloads without hitting the stack limit.
21
+
22
+ ### Changed
23
+
24
+ - Fix some token incompatibilities in the `parser` translation.
25
+ - Fix up parsing tempfiles on Windows.
26
+ - Fix up handling UTF-8 characters in file paths on Windows.
27
+ - Do not warn for a `\r` at the end of a shebang on Windows.
28
+ - Properly handle erroring for parsing a directory on Windows.
29
+ - When a numbered reference is out of range, warn instead of raise.
30
+ - Allow returns in default parameter values.
31
+ - Reject many more invalid syntax patterns.
32
+
33
+ ## [1.0.0] - 2024-08-28
34
+
35
+ ### Added
36
+
37
+ - Add `Node#breadth_first_search`.
38
+ - Add `Node#node_id`.
39
+ - Add `ArgumentsNode#contains_splat?`.
40
+ - Passing the special value `false` for the `encoding` option tells Prism to ignore magic encoding comments.
41
+ - Expose flags on every node type (allows checking static literal and newline).
42
+ - Implement mismatched indentation warning.
43
+ - Add C API for receiving a callback when parsing shebangs with additional flags.
44
+
45
+ ### Changed
46
+
47
+ - **BREAKING**: Some fields are renamed that had illogical names. The previous names all now emit deprecation warnings.
48
+ - `CaseMatchNode#consequent` was renamed to `CaseMatchNode#else_clause`
49
+ - `CaseNode#consequent` was renamed to `CaseNode#else_clause`
50
+ - `IfNode#consequent` was renamed to `IfNode#subsequent`
51
+ - `RescueNode#consequent` was renamed to `RescueNode#subsequent`
52
+ - `UnlessNode#consequent` was renamed to `UnlessNode#else_clause`
53
+ - Block exits are now allowed in loop predicates (e.g., `while _ && break do end`).
54
+ - Multi-writes are now disallowed when not at the statement level.
55
+ - Ensure that range operators are non-associative.
56
+ - (JavaScript) Correctly deserialize encoded strings.
57
+ - Properly support parsing regular expressions in extended mode.
58
+ - Use gmake on FreeBSD.
59
+ - Parsing streams now handles NUL bytes in the middle of the stream.
60
+ - Properly detect invalid returns.
61
+
62
+ ## [0.30.0] - 2024-06-07
63
+
64
+ ### Added
65
+
66
+ - More correctly raise mixed encoding errors.
67
+ - Implement ambiguous binary operator warning.
68
+ - Fix up regexp escapes with control and meta characters.
69
+ - Fix up support for the `it` implicit local variable.
70
+ - Heredoc identifiers now properly disallow CLRF.
71
+ - Errors added for void value expressions in begin clauses.
72
+ - Many updates to more closely match the `parser` gem in parser translation.
73
+ - Many errors added for invalid regular expressions.
74
+
75
+ ### Changed
76
+
77
+ - Handle parser translation missing the `parser` gem.
78
+ - Handle ruby_parser translation missing the `ruby_parser` gem.
79
+ - Various error messages have been updated to more closely match CRuby.
80
+ - `RationalNode` now has a `numerator` and `denominator` field instead of a `numeric` field. For the Ruby API we provide a `RationalNode#numeric` method for backwards-compatibility.
81
+
9
82
  ## [0.29.0] - 2024-05-10
10
83
 
11
84
  ### Added
@@ -518,7 +591,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
518
591
 
519
592
  - 🎉 Initial release! 🎉
520
593
 
521
- [unreleased]: https://github.com/ruby/prism/compare/v0.29.0...HEAD
594
+ [unreleased]: https://github.com/ruby/prism/compare/v1.1.0...HEAD
595
+ [1.1.0]: https://github.com/ruby/prism/compare/v1.0.0...v1.1.0
596
+ [1.0.0]: https://github.com/ruby/prism/compare/v0.30.0...v1.0.0
597
+ [0.30.0]: https://github.com/ruby/prism/compare/v0.29.0...v0.30.0
522
598
  [0.29.0]: https://github.com/ruby/prism/compare/v0.28.0...v0.29.0
523
599
  [0.28.0]: https://github.com/ruby/prism/compare/v0.27.0...v0.28.0
524
600
  [0.27.0]: https://github.com/ruby/prism/compare/v0.26.0...v0.27.0
data/CONTRIBUTING.md CHANGED
@@ -10,10 +10,6 @@ The discussions page on the GitHub repository are open. If you have a question o
10
10
 
11
11
  If you want to contribute code, please first open or contribute to a discussion. A lot of the project is in flux, and we want to make sure that you are contributing to the right place. Once you have a discussion going, you can open a pull request with your changes. We will review your code and get it merged in.
12
12
 
13
- ### Ruby Features
14
-
15
- Pattern matching and endless method definitions should be avoided as long as the latest TruffleRuby release does not support it.
16
-
17
13
  ## Tests
18
14
 
19
15
  We could always use more tests! One of the biggest challenges of this project is building up a big test suite. If you want to contribute tests, feel free to open a pull request. These will get merged in as soon as possible.
data/README.md CHANGED
@@ -40,6 +40,8 @@ The repository contains the infrastructure for both a shared library (libprism)
40
40
  ├── rust
41
41
  │   ├── ruby-prism Rustified crate for the shared library
42
42
  │   └── ruby-prism-sys FFI binding for Rust
43
+ ├── sample
44
+ │ └── prism Sample code that uses the Ruby API for documentation purposes
43
45
  ├── sig RBS type signatures for the Ruby library
44
46
  ├── src
45
47
  │   ├── util various utility files
@@ -119,6 +121,7 @@ Prism has been integrated into the majority of Ruby runtimes, many libraries, an
119
121
  ### Libraries
120
122
 
121
123
  * [dispersion](https://github.com/joeldrapper/dispersion)
124
+ * [minifyrb](https://github.com/koic/minifyrb)
122
125
  * [packwerk](https://github.com/Shopify/packwerk/pull/388) (via parser translator)
123
126
  * [rbi](https://github.com/Shopify/rbi)
124
127
  * [rails](https://github.com/rails/rails)
@@ -131,6 +134,7 @@ Prism has been integrated into the majority of Ruby runtimes, many libraries, an
131
134
  * [smart_todo](https://github.com/Shopify/smart_todo/pull/69)
132
135
  * [sorbet-eraser](https://github.com/kddnewton/sorbet-eraser/pull/25)
133
136
  * [synvert](https://github.com/xinminlabs/synvert-core-ruby)
137
+ * [typeprof](https://github.com/ruby/typeprof)
134
138
 
135
139
  ### Applications
136
140