Skip to content

Commit 9b79d58

Browse files
committed
Support 3.5 for version option
1 parent c009746 commit 9b79d58

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

include/prism/options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ typedef enum {
6868
PM_OPTIONS_VERSION_LATEST = 0,
6969

7070
/** The vendored version of prism in CRuby 3.3.x. */
71-
PM_OPTIONS_VERSION_CRUBY_3_3 = 1
71+
PM_OPTIONS_VERSION_CRUBY_3_3 = 1,
72+
73+
/** The vendored version of prism in CRuby 3.4.x. */
74+
PM_OPTIONS_VERSION_CRUBY_3_4 = 2
7275
} pm_options_version_t;
7376

7477
/**

java/org/prism/ParsingOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public abstract class ParsingOptions {
1414
public enum SyntaxVersion {
1515
LATEST(0),
1616
V3_3(1);
17+
V3_4(2);
1718

1819
private final int value;
1920

javascript/src/parsePrism.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ function dumpOptions(options) {
103103
values.push(dumpCommandLineOptions(options));
104104

105105
template.push("C");
106-
if (!options.version || options.version === "latest" || options.version.match(/^3\.4(\.\d+)?$/)) {
106+
if (!options.version || options.version === "latest" || options.version.match(/^3\.5(\.\d+)?$/)) {
107107
values.push(0);
108108
} else if (options.version.match(/^3\.3(\.\d+)?$/)) {
109109
values.push(1);
110+
} else if (options.version.match(/^3\.4(\.\d+)?$/)) {
111+
values.push(2);
110112
} else {
111113
throw new Error(`Unsupported version '${options.version}' in compiler options`);
112114
}

lib/prism/ffi.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def dump_options_version(version)
431431
when /\A3\.3(\.\d+)?\z/
432432
1
433433
when /\A3\.4(\.\d+)?\z/
434+
2
435+
when /\A3\.5(\.\d+)?\z/
434436
0
435437
else
436438
raise ArgumentError, "invalid version: #{version}"

src/options.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
8484
}
8585

8686
if (strncmp(version, "3.4", 3) == 0) {
87+
options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
88+
return true;
89+
}
90+
91+
if (strncmp(version, "3.5", 3) == 0) {
8792
options->version = PM_OPTIONS_VERSION_LATEST;
8893
return true;
8994
}
@@ -98,6 +103,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
98103
}
99104

100105
if (strncmp(version, "3.4.", 4) == 0 && is_number(version + 4, length - 4)) {
106+
options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
107+
return true;
108+
}
109+
110+
if (strncmp(version, "3.5.", 4) == 0 && is_number(version + 4, length - 4)) {
101111
options->version = PM_OPTIONS_VERSION_LATEST;
102112
return true;
103113
}

test/prism/api/parse_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def test_version
116116
assert Prism.parse_success?("1 + 1", version: "3.4.9")
117117
assert Prism.parse_success?("1 + 1", version: "3.4.10")
118118

119+
assert Prism.parse_success?("1 + 1", version: "3.5")
120+
assert Prism.parse_success?("1 + 1", version: "3.5.0")
121+
119122
assert Prism.parse_success?("1 + 1", version: "latest")
120123

121124
# Test edge case
@@ -133,7 +136,7 @@ def test_version
133136

134137
# Not supported version (too new)
135138
assert_raise ArgumentError do
136-
Prism.parse("1 + 1", version: "3.5.0")
139+
Prism.parse("1 + 1", version: "3.6.0")
137140
end
138141
end
139142

0 commit comments

Comments
 (0)