Skip to content

Commit

Permalink
Merge pull request #2304 from andrykonchin/ak/add-enum-for-syntax-ver…
Browse files Browse the repository at this point in the history
…sions

Add SyntaxVersion Java enum
  • Loading branch information
kddnewton authored Jan 30, 2024
2 parents d425651 + 6f33e80 commit 464ecc9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions java/org/prism/ParsingOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@

// @formatter:off
public abstract class ParsingOptions {
/** The version of Ruby syntax that we should be parsing with.
* See pm_options_version_t in c/yarp/include/prism/options.h */
public enum SyntaxVersion {
LATEST(0),
V3_3_0(1);

private final int value;

SyntaxVersion(int value) {
this.value = value;
}

public byte getValue() {
return (byte) value;
}
}

/** Serialize parsing options into byte array.
*
* @param filepath the name of the file that is currently being parsed
Expand All @@ -17,7 +34,7 @@ public abstract class ParsingOptions {
* @param scopes scopes surrounding the code that is being parsed with local variable names defined in every scope
* ordered from the outermost scope to the innermost one */
public static byte[] serialize(byte[] filepath, int line, byte[] encoding, boolean frozenStringLiteral,
boolean verbose, byte version, byte[][][] scopes) {
boolean verbose, SyntaxVersion version, byte[][][] scopes) {
final ByteArrayOutputStream output = new ByteArrayOutputStream();

// filepath
Expand Down Expand Up @@ -47,7 +64,7 @@ public static byte[] serialize(byte[] filepath, int line, byte[] encoding, boole
}

// version
output.write(version);
output.write(version.getValue());

// scopes

Expand Down

0 comments on commit 464ecc9

Please sign in to comment.