From aa49c1bd78c3b498a6988a9f3ebe4af90d698412 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Wed, 25 Dec 2024 18:53:55 +0900 Subject: [PATCH] Support Ruby 3.5 for `Prism::Translation::Parser` Follow up https://github.com/ruby/prism/pull/3336. Development for Ruby 3.5 has begun on the master branch: https://github.com/ruby/ruby/commit/2f064b3b4b71f9495bbc4229e7efdbfad494862f --- lib/prism/translation.rb | 1 + lib/prism/translation/parser.rb | 2 ++ lib/prism/translation/parser35.rb | 12 ++++++++++++ prism.gemspec | 2 ++ rbi/prism/translation/parser35.rbi | 6 ++++++ 5 files changed, 23 insertions(+) create mode 100644 lib/prism/translation/parser35.rb create mode 100644 rbi/prism/translation/parser35.rbi diff --git a/lib/prism/translation.rb b/lib/prism/translation.rb index 8b75e8a3abe..f5044b9e389 100644 --- a/lib/prism/translation.rb +++ b/lib/prism/translation.rb @@ -7,6 +7,7 @@ module Translation # steep:ignore autoload :Parser, "prism/translation/parser" autoload :Parser33, "prism/translation/parser33" autoload :Parser34, "prism/translation/parser34" + autoload :Parser35, "prism/translation/parser35" autoload :Ripper, "prism/translation/ripper" autoload :RubyParser, "prism/translation/ruby_parser" end diff --git a/lib/prism/translation/parser.rb b/lib/prism/translation/parser.rb index 969f2b95b0e..4f28afa86f2 100644 --- a/lib/prism/translation/parser.rb +++ b/lib/prism/translation/parser.rb @@ -292,6 +292,8 @@ def convert_for_prism(version) "3.3.1" when 34 "3.4.0" + when 35 + "3.5.0" else "latest" end diff --git a/lib/prism/translation/parser35.rb b/lib/prism/translation/parser35.rb new file mode 100644 index 00000000000..a6abc12589a --- /dev/null +++ b/lib/prism/translation/parser35.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Prism + module Translation + # This class is the entry-point for Ruby 3.5 of `Prism::Translation::Parser`. + class Parser35 < Parser + def version # :nodoc: + 35 + end + end + end +end diff --git a/prism.gemspec b/prism.gemspec index 56979c0ef63..e17e092f4e6 100644 --- a/prism.gemspec +++ b/prism.gemspec @@ -96,6 +96,7 @@ Gem::Specification.new do |spec| "lib/prism/translation/parser.rb", "lib/prism/translation/parser33.rb", "lib/prism/translation/parser34.rb", + "lib/prism/translation/parser35.rb", "lib/prism/translation/parser/compiler.rb", "lib/prism/translation/parser/lexer.rb", "lib/prism/translation/ripper.rb", @@ -116,6 +117,7 @@ Gem::Specification.new do |spec| "rbi/prism/translation/parser.rbi", "rbi/prism/translation/parser33.rbi", "rbi/prism/translation/parser34.rbi", + "rbi/prism/translation/parser35.rbi", "rbi/prism/translation/ripper.rbi", "rbi/prism/visitor.rbi", "sig/prism.rbs", diff --git a/rbi/prism/translation/parser35.rbi b/rbi/prism/translation/parser35.rbi new file mode 100644 index 00000000000..0239fc82ad8 --- /dev/null +++ b/rbi/prism/translation/parser35.rbi @@ -0,0 +1,6 @@ +# typed: strict + +class Prism::Translation::Parser35 < Prism::Translation::Parser + sig { override.returns(Integer) } + def version; end +end