prism 0.21.0 → 0.23.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 +40 -1
- data/README.md +2 -1
- data/docs/releasing.md +84 -16
- data/docs/ruby_parser_translation.md +19 -0
- data/docs/serialization.md +2 -0
- data/ext/prism/api_node.c +784 -785
- data/ext/prism/extension.c +56 -19
- data/ext/prism/extension.h +2 -2
- data/include/prism/diagnostic.h +11 -6
- data/include/prism/encoding.h +7 -0
- data/include/prism/util/pm_constant_pool.h +1 -1
- data/include/prism/util/pm_strpbrk.h +4 -1
- data/include/prism/version.h +2 -2
- data/lib/prism/ffi.rb +8 -3
- data/lib/prism/lex_compat.rb +17 -1
- data/lib/prism/node.rb +212 -32
- data/lib/prism/node_ext.rb +25 -2
- data/lib/prism/parse_result.rb +46 -16
- data/lib/prism/serialize.rb +14 -6
- data/lib/prism/translation/parser/compiler.rb +16 -6
- data/lib/prism/translation/parser.rb +19 -12
- data/lib/prism/translation/ripper.rb +577 -0
- data/lib/prism/translation/ruby_parser.rb +1521 -0
- data/lib/prism/translation.rb +3 -3
- data/lib/prism.rb +0 -1
- data/prism.gemspec +5 -3
- data/src/diagnostic.c +20 -15
- data/src/encoding.c +16 -17
- data/src/options.c +7 -2
- data/src/prism.c +145 -90
- data/src/serialize.c +24 -13
- data/src/token_type.c +3 -3
- data/src/util/pm_constant_pool.c +1 -1
- data/src/util/pm_string.c +0 -7
- data/src/util/pm_strpbrk.c +122 -14
- metadata +6 -4
- data/lib/prism/ripper_compat.rb +0 -207
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21ba5f26f72f4d44a749e9afa3988a7844ae7b13bf9258bd6e9b907aa8a4941c
|
4
|
+
data.tar.gz: 469d952df74bbd51262e5c7945ddee1d9766eafe2091527c4a952e6de2eaba0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0a7686666636ac8a379a40415e6e8ce85d292afc8cc6e223d7157bc502ce24cfc635215f1e89623fac857056e399eaa5e8153337f31c2ecf3a770aa8c1db4e2
|
7
|
+
data.tar.gz: d5db770e2d47bbf85f044c461256f6c87eaf234e4c5bb8f11a848ca5a15e55654551879fa8db5a6e655ec506755a1f7cfdda1cfaafa2db0d9977886661e0b1a9
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,43 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.23.0] - 2024-02-14
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- More support for `Prism::RipperCompat` is added.
|
14
|
+
- A significantly faster offset cache for `Prism::Translation::Parser` is added for files with multibyte characters.
|
15
|
+
- `Prism::Translation::RubyParser` is added.
|
16
|
+
- `Prism::ConstantPathTarget#full_name` is added.
|
17
|
+
- `version: "3.4.0"` is added as an option that is an alias for `version: "latest"`.
|
18
|
+
- Four new APIs are added to `Prism::Location`:
|
19
|
+
- `Prism::Location#start_code_units_offset`
|
20
|
+
- `Prism::Location#end_code_units_offset`
|
21
|
+
- `Prism::Location#start_code_units_column`
|
22
|
+
- `Prism::Location#end_code_units_column`
|
23
|
+
- Invalid multibyte characters are now validated within strings, lists, and heredocs.
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
|
27
|
+
- When defining `def !@`, the `name_loc` was previously only pointing to `!`, but now includes the `@`. The `name` is the same.
|
28
|
+
- `Prism::RipperCompat` has been moved to `Prism::Translation::Ripper`.
|
29
|
+
- Many of the error messages that prism produces have been changed to match the error messages that CRuby produces.
|
30
|
+
|
31
|
+
## [0.22.0] - 2024-02-07
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- More support for `Prism::RipperCompat` is added.
|
36
|
+
- Support for Ruby 2.7 has been added, and the minimum Ruby requirement has been lowered to 2.7.
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
- The error for an invalid source encoding has a new `:argument` level to indicate it raises an argument error.
|
41
|
+
- `BeginNode` nodes that are used when a class, singleton class, module, method definition, or block have an inline `rescue`/`ensure`/`else` now have their opening locations set to the beginning of the respective keyword.
|
42
|
+
- Improved error messages for invalid characters.
|
43
|
+
- `Prism.parse_file` and similar APIs will raise more appropriate errors when the file does not exist or cannot be mapped.
|
44
|
+
- Correctly handle the `recover` parameter for `Prism::Translation::Parser`.
|
45
|
+
|
9
46
|
## [0.21.0] - 2024-02-05
|
10
47
|
|
11
48
|
### Added
|
@@ -341,7 +378,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
341
378
|
|
342
379
|
- 🎉 Initial release! 🎉
|
343
380
|
|
344
|
-
[unreleased]: https://github.com/ruby/prism/compare/v0.
|
381
|
+
[unreleased]: https://github.com/ruby/prism/compare/v0.23.0...HEAD
|
382
|
+
[0.23.0]: https://github.com/ruby/prism/compare/v0.22.0...v0.23.0
|
383
|
+
[0.22.0]: https://github.com/ruby/prism/compare/v0.21.0...v0.22.0
|
345
384
|
[0.21.0]: https://github.com/ruby/prism/compare/v0.20.0...v0.21.0
|
346
385
|
[0.20.0]: https://github.com/ruby/prism/compare/v0.19.0...v0.20.0
|
347
386
|
[0.19.0]: https://github.com/ruby/prism/compare/v0.18.0...v0.19.0
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ To compile the shared library, you will need:
|
|
52
52
|
|
53
53
|
* C99 compiler
|
54
54
|
* make
|
55
|
-
* Ruby
|
55
|
+
* Ruby 2.7.0 or later
|
56
56
|
|
57
57
|
Once you have these dependencies, run:
|
58
58
|
|
@@ -93,5 +93,6 @@ See the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. We additio
|
|
93
93
|
* [Releasing](docs/releasing.md)
|
94
94
|
* [Ripper](docs/ripper.md)
|
95
95
|
* [Ruby API](docs/ruby_api.md)
|
96
|
+
* [RubyParser translation](docs/ruby_parser_translation.md)
|
96
97
|
* [Serialization](docs/serialization.md)
|
97
98
|
* [Testing](docs/testing.md)
|
data/docs/releasing.md
CHANGED
@@ -8,23 +8,91 @@ To release a new version of Prism, perform the following steps:
|
|
8
8
|
* Add a new section for the new version at the top of the file.
|
9
9
|
* Fill in the relevant changes — it may be easiest to click the link for the `Unreleased` heading to find the commits.
|
10
10
|
* Update the links at the bottom of the file.
|
11
|
-
* Update the version in the
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
* Update the version numbers in the various files that reference them:
|
12
|
+
|
13
|
+
```sh
|
14
|
+
export PRISM_MAJOR="x"
|
15
|
+
export PRISM_MINOR="y"
|
16
|
+
export PRISM_PATCH="z"
|
17
|
+
export PRISM_VERSION="$PRISM_MAJOR.$PRISM_MINOR.$PRISM_PATCH"
|
18
|
+
ruby -pi -e 'gsub(/spec\.version = ".+?"/, %Q{spec.version = "#{ENV["PRISM_VERSION"]}"})' prism.gemspec
|
19
|
+
ruby -pi -e 'gsub(/EXPECTED_PRISM_VERSION ".+?"/, %Q{EXPECTED_PRISM_VERSION "#{ENV["PRISM_VERSION"]}"})' ext/prism/extension.h
|
20
|
+
ruby -pi -e 'gsub(/PRISM_VERSION_MAJOR \d+/, %Q{PRISM_VERSION_MAJOR #{ENV["PRISM_MAJOR"]}})' include/prism/version.h
|
21
|
+
ruby -pi -e 'gsub(/PRISM_VERSION_MINOR \d+/, %Q{PRISM_VERSION_MINOR #{ENV["PRISM_MINOR"]}})' include/prism/version.h
|
22
|
+
ruby -pi -e 'gsub(/PRISM_VERSION_PATCH \d+/, %Q{PRISM_VERSION_PATCH #{ENV["PRISM_PATCH"]}})' include/prism/version.h
|
23
|
+
ruby -pi -e 'gsub(/PRISM_VERSION ".+?"/, %Q{PRISM_VERSION "#{ENV["PRISM_VERSION"]}"})' include/prism/version.h
|
24
|
+
ruby -pi -e 'gsub(/"version": ".+?"/, %Q{"version": "#{ENV["PRISM_VERSION"]}"})' javascript/package.json
|
25
|
+
ruby -pi -e 'gsub(/lossy\(\), ".+?"/, %Q{lossy(), "#{ENV["PRISM_VERSION"]}"})' rust/ruby-prism-sys/tests/utils_tests.rs
|
26
|
+
ruby -pi -e 'gsub(/\d+, "prism major/, %Q{#{ENV["PRISM_MAJOR"]}, "prism major})' templates/java/org/prism/Loader.java.erb
|
27
|
+
ruby -pi -e 'gsub(/\d+, "prism minor/, %Q{#{ENV["PRISM_MINOR"]}, "prism minor})' templates/java/org/prism/Loader.java.erb
|
28
|
+
ruby -pi -e 'gsub(/\d+, "prism patch/, %Q{#{ENV["PRISM_PATCH"]}, "prism patch})' templates/java/org/prism/Loader.java.erb
|
29
|
+
ruby -pi -e 'gsub(/MAJOR_VERSION = \d+/, %Q{MAJOR_VERSION = #{ENV["PRISM_MAJOR"]}})' templates/javascript/src/deserialize.js.erb
|
30
|
+
ruby -pi -e 'gsub(/MINOR_VERSION = \d+/, %Q{MINOR_VERSION = #{ENV["PRISM_MINOR"]}})' templates/javascript/src/deserialize.js.erb
|
31
|
+
ruby -pi -e 'gsub(/PATCH_VERSION = \d+/, %Q{PATCH_VERSION = #{ENV["PRISM_PATCH"]}})' templates/javascript/src/deserialize.js.erb
|
32
|
+
ruby -pi -e 'gsub(/MAJOR_VERSION = \d+/, %Q{MAJOR_VERSION = #{ENV["PRISM_MAJOR"]}})' templates/lib/prism/serialize.rb.erb
|
33
|
+
ruby -pi -e 'gsub(/MINOR_VERSION = \d+/, %Q{MINOR_VERSION = #{ENV["PRISM_MINOR"]}})' templates/lib/prism/serialize.rb.erb
|
34
|
+
ruby -pi -e 'gsub(/PATCH_VERSION = \d+/, %Q{PATCH_VERSION = #{ENV["PRISM_PATCH"]}})' templates/lib/prism/serialize.rb.erb
|
35
|
+
ruby -pi -e 'gsub(/^version = ".+?"/, %Q{version = "#{ENV["PRISM_VERSION"]}"})' rust/ruby-prism-sys/Cargo.toml
|
36
|
+
ruby -pi -e 'gsub(/^version = ".+?"/, %Q{version = "#{ENV["PRISM_VERSION"]}"})' rust/ruby-prism/Cargo.toml
|
37
|
+
ruby -pi -e 'gsub(/^ruby-prism-sys = { version = ".+?"/, %Q{ruby-prism-sys = { version = "#{ENV["PRISM_VERSION"]}"})' rust/ruby-prism/Cargo.toml
|
38
|
+
```
|
39
|
+
|
40
|
+
* Update the `Gemfile.lock` file:
|
41
|
+
|
42
|
+
```sh
|
43
|
+
chruby ruby-3.4.0-dev
|
44
|
+
bundle install
|
45
|
+
```
|
46
|
+
|
47
|
+
* Update the version-specific lockfiles:
|
48
|
+
|
49
|
+
```sh
|
50
|
+
chruby ruby-2.7.8 && BUNDLE_GEMFILE=gemfiles/2.7/Gemfile bundle install
|
51
|
+
chruby ruby-3.0.6 && BUNDLE_GEMFILE=gemfiles/3.0/Gemfile bundle install
|
52
|
+
chruby ruby-3.1.4 && BUNDLE_GEMFILE=gemfiles/3.1/Gemfile bundle install
|
53
|
+
chruby ruby-3.2.3 && BUNDLE_GEMFILE=gemfiles/3.2/Gemfile bundle install
|
54
|
+
chruby ruby-3.3.0 && BUNDLE_GEMFILE=gemfiles/3.3/Gemfile bundle install
|
55
|
+
chruby ruby-3.4.0-dev && BUNDLE_GEMFILE=gemfiles/3.4/Gemfile bundle install
|
56
|
+
chruby jruby-9.4.5.0 && BUNDLE_GEMFILE=gemfiles/jruby/Gemfile bundle install
|
57
|
+
chruby truffleruby-23.1.2 && BUNDLE_GEMFILE=gemfiles/truffleruby/Gemfile bundle install
|
58
|
+
chruby ruby-3.4.0-dev
|
59
|
+
```
|
60
|
+
|
61
|
+
* Update the cargo lockfiles:
|
62
|
+
|
63
|
+
```sh
|
64
|
+
bundle exec rake cargo:build
|
65
|
+
```
|
66
|
+
|
67
|
+
* Commit all of the updated files:
|
68
|
+
|
69
|
+
```sh
|
70
|
+
git commit -am "Bump to v$PRISM_VERSION"
|
71
|
+
```
|
24
72
|
|
25
73
|
## Publishing
|
26
74
|
|
27
75
|
* Update the GitHub release page with a copy of the latest entry in the `CHANGELOG.md` file.
|
28
|
-
*
|
29
|
-
|
30
|
-
|
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
|
+
```
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# ruby_parser translation
|
2
|
+
|
3
|
+
Prism ships with the ability to translate its syntax tree into the syntax tree used by the [seattlerb/ruby_parser](https://github.com/seattlerb/ruby_parser) gem. This allows you to use tools built on top of the `ruby_parser` gem with the `prism` parser.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
You can call the `parse` and `parse_file` methods on the `Prism::Translation::RubyParser` module:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
filepath = "path/to/file.rb"
|
11
|
+
Prism::Translation::RubyParser.parse_file(filepath)
|
12
|
+
```
|
13
|
+
|
14
|
+
This will return to you `Sexp` objects that mirror the result of calling `RubyParser` methods, as in:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
filepath = "path/to/file.rb"
|
18
|
+
RubyParser.new.parse(File.read(filepath), filepath)
|
19
|
+
```
|
data/docs/serialization.md
CHANGED
@@ -85,6 +85,8 @@ The header is structured like the following table:
|
|
85
85
|
| `1` | 1 indicates only semantics fields were serialized, 0 indicates all fields were serialized (including location fields) |
|
86
86
|
| string | the encoding name |
|
87
87
|
| varsint | the start line |
|
88
|
+
| varuint | number of newline offsets |
|
89
|
+
| varuint* | newline offsets |
|
88
90
|
| varuint | number of comments |
|
89
91
|
| comment* | comments |
|
90
92
|
| varuint | number of magic comments |
|