ruby/lib/prism/prism.gemspec

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

167 строки
4.9 KiB
Ruby
Исходник Постоянная ссылка Обычный вид История

# 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"
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"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.7.0"
2023-08-15 20:00:54 +03:00
spec.require_paths = ["lib"]
spec.files = [
"BSDmakefile",
"CHANGELOG.md",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE.md",
2023-08-15 20:00:54 +03:00
"Makefile",
"README.md",
"config.yml",
"docs/build_system.md",
"docs/configuration.md",
"docs/cruby_compilation.md",
"docs/design.md",
"docs/encoding.md",
"docs/fuzzing.md",
"docs/heredocs.md",
"docs/javascript.md",
"docs/local_variable_depth.md",
"docs/mapping.md",
"docs/parser_translation.md",
"docs/parsing_rules.md",
2023-10-30 19:35:39 +03:00
"docs/releasing.md",
"docs/relocation.md",
"docs/ripper_translation.md",
2023-08-15 20:00:54 +03:00
"docs/ruby_api.md",
"docs/ruby_parser_translation.md",
"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",
"include/prism/encoding.h",
2023-09-27 19:24:48 +03:00
"include/prism/node.h",
"include/prism/options.h",
2023-09-27 19:24:48 +03:00
"include/prism/pack.h",
"include/prism/parser.h",
"include/prism/prettyprint.h",
2023-09-27 19:24:48 +03:00
"include/prism/regexp.h",
"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",
"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",
"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",
"lib/prism/dot_visitor.rb",
2023-09-27 19:24:48 +03:00
"lib/prism/dsl.rb",
"lib/prism/ffi.rb",
"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",
"lib/prism/node.rb",
2023-09-27 19:24:48 +03:00
"lib/prism/pack.rb",
"lib/prism/parse_result.rb",
"lib/prism/parse_result/comments.rb",
"lib/prism/parse_result/errors.rb",
"lib/prism/parse_result/newlines.rb",
2023-09-27 19:24:48 +03:00
"lib/prism/pattern.rb",
"lib/prism/polyfill/byteindex.rb",
"lib/prism/polyfill/unpack1.rb",
"lib/prism/reflection.rb",
"lib/prism/relocation.rb",
2023-09-27 19:24:48 +03:00
"lib/prism/serialize.rb",
"lib/prism/string_query.rb",
"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",
"lib/prism/translation/parser/compiler.rb",
"lib/prism/translation/parser/lexer.rb",
"lib/prism/translation/ripper.rb",
"lib/prism/translation/ripper/sexp.rb",
"lib/prism/translation/ripper/shim.rb",
"lib/prism/translation/ruby_parser.rb",
2023-09-27 19:24:48 +03:00
"lib/prism/visitor.rb",
"prism.gemspec",
"rbi/prism.rbi",
"rbi/prism/compiler.rbi",
"rbi/prism/dsl.rbi",
"rbi/prism/inspect_visitor.rbi",
"rbi/prism/node_ext.rbi",
"rbi/prism/node.rbi",
"rbi/prism/parse_result.rbi",
"rbi/prism/reflection.rbi",
"rbi/prism/string_query.rbi",
"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",
"sig/prism/lex_compat.rbs",
"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",
"sig/prism/relocation.rbs",
"sig/prism/serialize.rbs",
"sig/prism/string_query.rbs",
"sig/prism/visitor.rbs",
"src/diagnostic.c",
"src/encoding.c",
"src/node.c",
"src/options.c",
"src/pack.c",
"src/prettyprint.c",
"src/prism.c",
"src/regexp.c",
"src/serialize.c",
"src/static_literals.c",
"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",
"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",
"src/util/pm_string.c",
2023-09-27 19:24:48 +03:00
"src/util/pm_strncasecmp.c",
"src/util/pm_strpbrk.c"
]
2023-09-27 19:24:48 +03:00
spec.extensions = ["ext/prism/extconf.rb"]
spec.metadata["allowed_push_host"] = "https://rubygems.org"
spec.metadata["source_code_uri"] = "https://github.com/ruby/prism"
spec.metadata["changelog_uri"] = "https://github.com/ruby/prism/blob/main/CHANGELOG.md"
end