Skip to content

Commit 001b712

Browse files
committed
Bump Gradle wrapper to 7.3, target Java 17, use sealed types where applicable, clean up code
1 parent 1001f65 commit 001b712

File tree

11 files changed

+34
-16
lines changed

11 files changed

+34
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
implementation("com.googlecode.json-simple:json-simple:1.1.1")
3030
}
3131
```
32-
SemGuS-Java targets Java 16 and makes extensive use of records to represent SemGuS objects.
32+
SemGuS-Java targets Java 17 and makes extensive use of sealed types and records to represent SemGuS objects.
3333

3434
## Usage
3535

build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ repositories {
1313
}
1414
}
1515

16+
java {
17+
sourceCompatibility = JavaVersion.VERSION_17
18+
targetCompatibility = JavaVersion.VERSION_17
19+
}
20+
1621
dependencies {
1722
implementation("com.github.phantamanta44:jsr305:1.0.1")
1823
implementation("com.googlecode.json-simple:json-simple:1.1.1")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/org/semgus/java/Main.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.semgus.java;
22

3-
import org.json.simple.JSONObject;
43
import org.json.simple.parser.ParseException;
54
import org.semgus.java.event.EventParser;
65
import org.semgus.java.event.SpecEvent;
@@ -19,7 +18,14 @@
1918
/**
2019
* Entry point class that simply reads a SemGuS JSON document, parses it, and dumps the problem to standard output.
2120
*/
22-
public class Main {
21+
public final class Main {
22+
23+
/**
24+
* Empty helper class constructor.
25+
*/
26+
private Main() {
27+
// NO-OP
28+
}
2329

2430
/**
2531
* Entry point: reads a JSON document, parses it as a SemGuS JSON specification, and dumps it to standard output.

src/main/java/org/semgus/java/event/MetaSpecEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* A SemGuS parser event of the "meta" type.
77
*/
8-
public interface MetaSpecEvent extends SpecEvent {
8+
public sealed interface MetaSpecEvent extends SpecEvent {
99

1010
/**
1111
* A "set-info" event specifying some problem metadata.

src/main/java/org/semgus/java/event/SemgusSpecEvent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* A SemGuS parser event of the "semgus" type.
1313
*/
14-
public interface SemgusSpecEvent extends SpecEvent {
14+
public sealed interface SemgusSpecEvent extends SpecEvent {
1515

1616
/**
1717
* A "check-synth" event indicating that the synthesis problem specification is done.
@@ -43,7 +43,7 @@ record DefineTermTypeEvent(String name, List<Constructor> constructors) implemen
4343
* @param name The name of the constructor.
4444
* @param children The names of child term types for this constructor.
4545
*/
46-
public static record Constructor(String name, List<String> children) {
46+
public record Constructor(String name, List<String> children) {
4747
// NO-OP
4848
}
4949

@@ -73,7 +73,7 @@ record HornClauseEvent(
7373
* @param arguments The arguments to the constructor.
7474
* @param returnType The name of the term type constructed by the constructor.
7575
*/
76-
public static record Constructor(String name, List<TypedVar> arguments, String returnType) {
76+
public record Constructor(String name, List<TypedVar> arguments, String returnType) {
7777
// NO-OP
7878
}
7979

@@ -104,7 +104,7 @@ record SynthFunEvent(String name, Map<String, NonTerminal> grammar, String termT
104104
* @param termType The term type corresponding to this non-terminal.
105105
* @param productions A set of productions, indexed by production name.
106106
*/
107-
public static record NonTerminal(String termType, Map<String, Production> productions) {
107+
public record NonTerminal(String termType, Map<String, Production> productions) {
108108
// NO-OP
109109
}
110110

@@ -114,7 +114,7 @@ public static record NonTerminal(String termType, Map<String, Production> produc
114114
* @param operator The name/symbol for this production.
115115
* @param occurrences The names of non-terminals for child terms.
116116
*/
117-
public static record Production(String operator, List<String> occurrences) {
117+
public record Production(String operator, List<String> occurrences) {
118118
// NO-OP
119119
}
120120

src/main/java/org/semgus/java/event/SpecEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
/**
44
* Parent interface for all SemGuS parser events.
55
*/
6-
public interface SpecEvent {
6+
public sealed interface SpecEvent permits MetaSpecEvent, SemgusSpecEvent {
77
// NO-OP
88
}

src/main/java/org/semgus/java/object/AttributeValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Represents the value of an SMT-Lib attribute. Used by SemGuS for various pieces of metadata.
1212
*/
13-
public interface AttributeValue {
13+
public sealed interface AttributeValue {
1414

1515
/**
1616
* Deserializes an attribute value from the SemGuS JSON format.

src/main/java/org/semgus/java/object/Identifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public String toString() {
8484
/**
8585
* An index value for an indexed identifier.
8686
*/
87-
public interface Index {
87+
public sealed interface Index {
8888

8989
/**
9090
* Deserializes an index value for an identifier.

src/main/java/org/semgus/java/object/SmtTerm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Represents a term of an SMT formula.
1515
*/
16-
public interface SmtTerm {
16+
public sealed interface SmtTerm {
1717

1818
/**
1919
* Deserializes an SMT formula term in the SemGuS JSON format.
@@ -260,7 +260,7 @@ public String toString() {
260260
* @param type The argument type.
261261
* @param term The subterm being passed as an argument.
262262
*/
263-
public static record TypedTerm(Identifier type, SmtTerm term) {
263+
public record TypedTerm(Identifier type, SmtTerm term) {
264264

265265
@Override
266266
public String toString() {

0 commit comments

Comments
 (0)