Skip to content

Commit 138db9c

Browse files
committed
Add Ruby 4.1 as a version specifier
1 parent 609c80c commit 138db9c

File tree

13 files changed

+51
-4
lines changed

13 files changed

+51
-4
lines changed

include/prism/options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ typedef enum {
9797
/** The vendored version of prism in CRuby 4.0.x. */
9898
PM_OPTIONS_VERSION_CRUBY_4_0 = 3,
9999

100+
/** The vendored version of prism in CRuby 4.1.x. */
101+
PM_OPTIONS_VERSION_CRUBY_4_1 = 4,
102+
100103
/** The current version of prism. */
101-
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_0
104+
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_1
102105
} pm_options_version_t;
103106

104107
/**

java/org/prism/ParsingOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public enum SyntaxVersion {
1616
V3_3(1),
1717
V3_4(2),
1818
V3_5(3),
19-
V4_0(3);
19+
V4_0(3),
20+
V4_1(4);
2021

2122
private final int value;
2223

javascript/src/parsePrism.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ function dumpOptions(options) {
148148
values.push(2);
149149
} else if (options.version.match(/^3\.5(\.\d+)?$/) || options.version.match(/^4\.0(\.\d+)?$/)) {
150150
values.push(3);
151+
} else if (options.version.match(/^4\.1(\.\d+)?$/)) {
152+
values.push(4);
151153
} else {
152154
throw new Error(`Unsupported version '${options.version}' in compiler options`);
153155
}

lib/prism/ffi.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ def dump_options_version(version)
434434
2
435435
when /\A3\.5(\.\d+)?\z/, /\A4\.0(\.\d+)?\z/
436436
3
437+
when /\A4\.1(\.\d+)?\z/
438+
4
437439
else
438440
if current
439441
raise CurrentVersionError, RUBY_VERSION

lib/prism/translation.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Translation # steep:ignore
1111
autoload :Parser34, "prism/translation/parser34"
1212
autoload :Parser35, "prism/translation/parser35"
1313
autoload :Parser40, "prism/translation/parser40"
14+
autoload :Parser41, "prism/translation/parser41"
1415
autoload :Ripper, "prism/translation/ripper"
1516
autoload :RubyParser, "prism/translation/ruby_parser"
1617
end

lib/prism/translation/parser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def initialize(builder = Prism::Translation::Parser::Builder.new, parser: Prism)
8484
end
8585

8686
def version # :nodoc:
87-
40
87+
41
8888
end
8989

9090
# The default encoding for Ruby files is UTF-8.
@@ -358,6 +358,8 @@ def convert_for_prism(version)
358358
"3.4.0"
359359
when 35, 40
360360
"4.0.0"
361+
when 41
362+
"4.1.0"
361363
else
362364
"latest"
363365
end

lib/prism/translation/parser41.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
# :markup: markdown
3+
4+
module Prism
5+
module Translation
6+
# This class is the entry-point for Ruby 4.1 of `Prism::Translation::Parser`.
7+
class Parser41 < Parser
8+
def version # :nodoc:
9+
41
10+
end
11+
end
12+
end
13+
end

lib/prism/translation/parser_current.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module Translation
1212
ParserCurrent = Parser34
1313
when /^3\.5\./, /^4\.0\./
1414
ParserCurrent = Parser40
15+
when /^4\.1\./
16+
ParserCurrent = Parser41
1517
else
1618
# Keep this in sync with released Ruby.
1719
parser = Parser34

prism.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Gem::Specification.new do |spec|
102102
"lib/prism/translation/parser34.rb",
103103
"lib/prism/translation/parser35.rb",
104104
"lib/prism/translation/parser40.rb",
105+
"lib/prism/translation/parser41.rb",
105106
"lib/prism/translation/parser/builder.rb",
106107
"lib/prism/translation/parser/compiler.rb",
107108
"lib/prism/translation/parser/lexer.rb",
@@ -125,6 +126,7 @@ Gem::Specification.new do |spec|
125126
"rbi/prism/translation/parser34.rbi",
126127
"rbi/prism/translation/parser35.rbi",
127128
"rbi/prism/translation/parser40.rbi",
129+
"rbi/prism/translation/parser41.rbi",
128130
"rbi/prism/translation/ripper.rbi",
129131
"rbi/prism/visitor.rbi",
130132
"sig/prism.rbs",

rbi/prism/translation/parser41.rbi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# typed: strict
2+
3+
class Prism::Translation::Parser40 < Prism::Translation::Parser
4+
sig { override.returns(Integer) }
5+
def version; end
6+
end

0 commit comments

Comments
 (0)