2023-07-20 21:51:17 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
Gem::Specification.new do |spec|
|
2023-09-27 19:24:48 +03:00
|
|
|
spec.name = "prism"
|
2024-08-28 22:43:32 +03:00
|
|
|
spec.version = "1.0.0"
|
2023-07-20 21:51:17 +03:00
|
|
|
spec.authors = ["Shopify"]
|
|
|
|
spec.email = ["ruby@shopify.com"]
|
|
|
|
|
2023-09-27 19:24:48 +03:00
|
|
|
spec.summary = "Prism Ruby parser"
|
|
|
|
spec.homepage = "https://github.com/ruby/prism"
|
2023-07-20 21:51:17 +03:00
|
|
|
spec.license = "MIT"
|
|
|
|
|
2024-02-05 23:41:46 +03:00
|
|
|
spec.required_ruby_version = ">= 2.7.0"
|
2023-08-15 20:00:54 +03:00
|
|
|
|
2023-07-20 21:51:17 +03:00
|
|
|
spec.require_paths = ["lib"]
|
|
|
|
spec.files = [
|
2024-03-04 19:15:20 +03:00
|
|
|
"BSDmakefile",
|
2023-08-09 17:57:00 +03:00
|
|
|
"CHANGELOG.md",
|
2023-07-20 21:51:17 +03:00
|
|
|
"CODE_OF_CONDUCT.md",
|
|
|
|
"CONTRIBUTING.md",
|
|
|
|
"LICENSE.md",
|
2023-08-15 20:00:54 +03:00
|
|
|
"Makefile",
|
2023-07-20 21:51:17 +03:00
|
|
|
"README.md",
|
|
|
|
"config.yml",
|
2023-08-03 01:01:15 +03:00
|
|
|
"docs/build_system.md",
|
2023-07-20 21:51:17 +03:00
|
|
|
"docs/configuration.md",
|
2024-01-11 00:21:15 +03:00
|
|
|
"docs/cruby_compilation.md",
|
2023-07-20 21:51:17 +03:00
|
|
|
"docs/design.md",
|
|
|
|
"docs/encoding.md",
|
|
|
|
"docs/fuzzing.md",
|
|
|
|
"docs/heredocs.md",
|
2023-10-24 21:23:39 +03:00
|
|
|
"docs/javascript.md",
|
2023-11-22 18:15:03 +03:00
|
|
|
"docs/local_variable_depth.md",
|
2023-07-20 21:51:17 +03:00
|
|
|
"docs/mapping.md",
|
2024-01-10 19:04:39 +03:00
|
|
|
"docs/parser_translation.md",
|
2024-01-19 19:12:12 +03:00
|
|
|
"docs/parsing_rules.md",
|
2023-10-30 19:35:39 +03:00
|
|
|
"docs/releasing.md",
|
2024-10-15 15:37:34 +03:00
|
|
|
"docs/relocation.md",
|
2024-03-06 20:07:33 +03:00
|
|
|
"docs/ripper_translation.md",
|
2023-08-15 20:00:54 +03:00
|
|
|
"docs/ruby_api.md",
|
2024-01-25 18:21:11 +03:00
|
|
|
"docs/ruby_parser_translation.md",
|
2023-07-20 21:51:17 +03:00
|
|
|
"docs/serialization.md",
|
|
|
|
"docs/testing.md",
|
2023-09-27 19:24:48 +03:00
|
|
|
"ext/prism/api_node.c",
|
|
|
|
"ext/prism/api_pack.c",
|
|
|
|
"ext/prism/extension.c",
|
|
|
|
"ext/prism/extension.h",
|
|
|
|
"include/prism.h",
|
|
|
|
"include/prism/ast.h",
|
|
|
|
"include/prism/defines.h",
|
|
|
|
"include/prism/diagnostic.h",
|
2023-11-30 19:36:10 +03:00
|
|
|
"include/prism/encoding.h",
|
2023-09-27 19:24:48 +03:00
|
|
|
"include/prism/node.h",
|
2023-11-02 18:15:37 +03:00
|
|
|
"include/prism/options.h",
|
2023-09-27 19:24:48 +03:00
|
|
|
"include/prism/pack.h",
|
|
|
|
"include/prism/parser.h",
|
2023-10-24 19:42:16 +03:00
|
|
|
"include/prism/prettyprint.h",
|
2023-09-27 19:24:48 +03:00
|
|
|
"include/prism/regexp.h",
|
2024-02-23 19:05:32 +03:00
|
|
|
"include/prism/static_literals.h",
|
2023-09-27 19:24:48 +03:00
|
|
|
"include/prism/util/pm_buffer.h",
|
|
|
|
"include/prism/util/pm_char.h",
|
|
|
|
"include/prism/util/pm_constant_pool.h",
|
2024-02-22 18:55:52 +03:00
|
|
|
"include/prism/util/pm_integer.h",
|
2023-09-27 19:24:48 +03:00
|
|
|
"include/prism/util/pm_list.h",
|
|
|
|
"include/prism/util/pm_memchr.h",
|
|
|
|
"include/prism/util/pm_newline_list.h",
|
2023-10-31 06:33:04 +03:00
|
|
|
"include/prism/util/pm_strncasecmp.h",
|
2023-09-27 19:24:48 +03:00
|
|
|
"include/prism/util/pm_string.h",
|
|
|
|
"include/prism/util/pm_strpbrk.h",
|
|
|
|
"include/prism/version.h",
|
|
|
|
"lib/prism.rb",
|
|
|
|
"lib/prism/compiler.rb",
|
|
|
|
"lib/prism/desugar_compiler.rb",
|
|
|
|
"lib/prism/dispatcher.rb",
|
2023-11-03 20:36:28 +03:00
|
|
|
"lib/prism/dot_visitor.rb",
|
2023-09-27 19:24:48 +03:00
|
|
|
"lib/prism/dsl.rb",
|
|
|
|
"lib/prism/ffi.rb",
|
2024-04-24 18:58:24 +03:00
|
|
|
"lib/prism/inspect_visitor.rb",
|
2023-09-27 19:24:48 +03:00
|
|
|
"lib/prism/lex_compat.rb",
|
|
|
|
"lib/prism/mutation_compiler.rb",
|
|
|
|
"lib/prism/node_ext.rb",
|
2024-01-10 19:04:39 +03:00
|
|
|
"lib/prism/node.rb",
|
2023-09-27 19:24:48 +03:00
|
|
|
"lib/prism/pack.rb",
|
|
|
|
"lib/prism/parse_result.rb",
|
2024-01-10 19:04:39 +03:00
|
|
|
"lib/prism/parse_result/comments.rb",
|
2024-07-03 15:50:22 +03:00
|
|
|
"lib/prism/parse_result/errors.rb",
|
2024-01-10 19:04:39 +03:00
|
|
|
"lib/prism/parse_result/newlines.rb",
|
2023-09-27 19:24:48 +03:00
|
|
|
"lib/prism/pattern.rb",
|
2024-05-03 21:58:40 +03:00
|
|
|
"lib/prism/polyfill/byteindex.rb",
|
|
|
|
"lib/prism/polyfill/unpack1.rb",
|
2024-04-17 18:28:52 +03:00
|
|
|
"lib/prism/reflection.rb",
|
2024-10-15 15:37:34 +03:00
|
|
|
"lib/prism/relocation.rb",
|
2023-09-27 19:24:48 +03:00
|
|
|
"lib/prism/serialize.rb",
|
2024-10-11 21:43:23 +03:00
|
|
|
"lib/prism/string_query.rb",
|
2024-01-10 19:04:39 +03:00
|
|
|
"lib/prism/translation.rb",
|
|
|
|
"lib/prism/translation/parser.rb",
|
[ruby/prism] Support multi-versioning for `Prism::Translation::Parser`
## Summary
Fixes https://github.com/ruby/prism/pull/2356.
I'm working on integrating Prism into RuboCop.
This PR introduces `Prism::Translation::Parser33` and `Prism::Translation::Parser34`, named
in accordance with the following comments.
https://github.com/rubocop/rubocop/issues/12600#issuecomment-1932707748
Currently, `Prism::Translation::Parser` always operates in Ruby 3.4 mode.
This means it will not parse as Ruby 3.3 even if `TargetRubyVersion: 80_82_73_83_77.33` is specified.
Therefore, the `it` introduced in Ruby 3.4 is parsed incompatibly with Ruby 3.3. In Ruby 3.3,
the expected name for an `lvar` is `:it`, not `:"0it"`.
### Expected AST
The following is an expected AST when parsing Ruby 3.3 code:
```console
$ bundle exec ruby -rprism -rprism/translation/parser33 -ve "p Prism::Translation::Parser33.parse('items.map { it.do_something }')"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
s(:block,
s(:send,
s(:send, nil, :items), :map),
s(:args),
s(:send,
s(:send, nil, :it), :do_something))
```
### Actual AST
The following is an actual AST when parsing Ruby 3.3 code:
```console
$ ruby -rprism -ve "p Prism::Translation::Parser.parse('items.map { it.do_something }')"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22]
s(:block,
s(:send,
s(:send, nil, :items), :map),
s(:args),
s(:send,
s(:lvar, :"0it"), :do_something))
```
`Prism::Translation::Parser33` and `Prism::Translation::Parser34` aim to correspond to Ruby 3.3 and Ruby 3.4, respectively.
And, The hack of specifying `TargetRubyVersion: 80_82_73_83_77.33` is expected to become unnecessary in the future,
but the behavior will be maintained until RuboCop's support is finalized:
https://github.com/rubocop/rubocop/issues/12600#issuecomment-1933657732
## Additional Information
A private method named `convert_for_prism` is prepared to convert the `version` from Parser to the `version` expected by Prism.
For example, a Parser-compatible value is `3.3`, whereas Prism expects `"3.3.0"`.
`Parser#version` is not used in RuboCop, but it's unclear how it is utilized in other libraries that rely on the Parser gem.
Therefore, logic to maintain compatibility between Parser and Prism is implemented.
https://github.com/ruby/prism/commit/62d3991e22
2024-02-14 16:13:04 +03:00
|
|
|
"lib/prism/translation/parser33.rb",
|
|
|
|
"lib/prism/translation/parser34.rb",
|
2024-01-10 19:04:39 +03:00
|
|
|
"lib/prism/translation/parser/compiler.rb",
|
|
|
|
"lib/prism/translation/parser/lexer.rb",
|
2024-02-12 18:47:33 +03:00
|
|
|
"lib/prism/translation/ripper.rb",
|
2024-03-06 15:45:28 +03:00
|
|
|
"lib/prism/translation/ripper/sexp.rb",
|
|
|
|
"lib/prism/translation/ripper/shim.rb",
|
2024-01-25 18:21:11 +03:00
|
|
|
"lib/prism/translation/ruby_parser.rb",
|
2023-09-27 19:24:48 +03:00
|
|
|
"lib/prism/visitor.rb",
|
2024-04-24 18:58:24 +03:00
|
|
|
"prism.gemspec",
|
|
|
|
"rbi/prism.rbi",
|
|
|
|
"rbi/prism/compiler.rbi",
|
2024-07-03 18:23:17 +03:00
|
|
|
"rbi/prism/dsl.rbi",
|
2024-04-24 18:58:24 +03:00
|
|
|
"rbi/prism/inspect_visitor.rbi",
|
|
|
|
"rbi/prism/node_ext.rbi",
|
|
|
|
"rbi/prism/node.rbi",
|
|
|
|
"rbi/prism/parse_result.rbi",
|
|
|
|
"rbi/prism/reflection.rbi",
|
2024-10-11 21:43:23 +03:00
|
|
|
"rbi/prism/string_query.rbi",
|
2024-04-24 18:58:24 +03:00
|
|
|
"rbi/prism/translation/parser.rbi",
|
|
|
|
"rbi/prism/translation/parser33.rbi",
|
|
|
|
"rbi/prism/translation/parser34.rbi",
|
|
|
|
"rbi/prism/translation/ripper.rbi",
|
|
|
|
"rbi/prism/visitor.rbi",
|
|
|
|
"sig/prism.rbs",
|
|
|
|
"sig/prism/compiler.rbs",
|
|
|
|
"sig/prism/dispatcher.rbs",
|
|
|
|
"sig/prism/dot_visitor.rbs",
|
|
|
|
"sig/prism/dsl.rbs",
|
|
|
|
"sig/prism/inspect_visitor.rbs",
|
2024-05-10 16:45:51 +03:00
|
|
|
"sig/prism/lex_compat.rbs",
|
2024-04-24 18:58:24 +03:00
|
|
|
"sig/prism/mutation_compiler.rbs",
|
|
|
|
"sig/prism/node_ext.rbs",
|
|
|
|
"sig/prism/node.rbs",
|
|
|
|
"sig/prism/pack.rbs",
|
|
|
|
"sig/prism/parse_result.rbs",
|
|
|
|
"sig/prism/pattern.rbs",
|
|
|
|
"sig/prism/reflection.rbs",
|
2024-10-15 15:37:34 +03:00
|
|
|
"sig/prism/relocation.rbs",
|
2024-04-24 18:58:24 +03:00
|
|
|
"sig/prism/serialize.rbs",
|
2024-10-11 21:43:23 +03:00
|
|
|
"sig/prism/string_query.rbs",
|
2024-04-24 18:58:24 +03:00
|
|
|
"sig/prism/visitor.rbs",
|
2023-07-20 21:51:17 +03:00
|
|
|
"src/diagnostic.c",
|
2023-11-30 19:36:10 +03:00
|
|
|
"src/encoding.c",
|
2023-07-20 21:51:17 +03:00
|
|
|
"src/node.c",
|
2024-04-24 18:58:24 +03:00
|
|
|
"src/options.c",
|
2023-07-20 21:51:17 +03:00
|
|
|
"src/pack.c",
|
|
|
|
"src/prettyprint.c",
|
2024-04-24 18:58:24 +03:00
|
|
|
"src/prism.c",
|
2023-07-20 21:51:17 +03:00
|
|
|
"src/regexp.c",
|
|
|
|
"src/serialize.c",
|
2024-02-23 19:05:32 +03:00
|
|
|
"src/static_literals.c",
|
2023-07-20 21:51:17 +03:00
|
|
|
"src/token_type.c",
|
2023-09-27 19:24:48 +03:00
|
|
|
"src/util/pm_buffer.c",
|
|
|
|
"src/util/pm_char.c",
|
|
|
|
"src/util/pm_constant_pool.c",
|
2024-02-22 18:55:52 +03:00
|
|
|
"src/util/pm_integer.c",
|
2023-09-27 19:24:48 +03:00
|
|
|
"src/util/pm_list.c",
|
|
|
|
"src/util/pm_memchr.c",
|
|
|
|
"src/util/pm_newline_list.c",
|
2024-04-24 18:58:24 +03:00
|
|
|
"src/util/pm_string.c",
|
2023-09-27 19:24:48 +03:00
|
|
|
"src/util/pm_strncasecmp.c",
|
2024-04-24 18:58:24 +03:00
|
|
|
"src/util/pm_strpbrk.c"
|
2023-07-20 21:51:17 +03:00
|
|
|
]
|
|
|
|
|
2023-09-27 19:24:48 +03:00
|
|
|
spec.extensions = ["ext/prism/extconf.rb"]
|
2023-07-20 21:51:17 +03:00
|
|
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
2023-11-10 20:04:46 +03:00
|
|
|
spec.metadata["source_code_uri"] = "https://github.com/ruby/prism"
|
|
|
|
spec.metadata["changelog_uri"] = "https://github.com/ruby/prism/blob/main/CHANGELOG.md"
|
2023-07-20 21:51:17 +03:00
|
|
|
end
|