diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-04 22:23:50 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-04 22:23:50 +0100 |
| commit | 2b396e9c0d450596814697e444bd8f44f060de0c (patch) | |
| tree | 8fd67e9b2ef11aec89bec5ddf1a3a1485768a588 | |
| parent | c9c7844ca575c477c90c9d714ac50394d7756782 (diff) | |
Combine binary operations into single Java AST node
12 files changed, 147 insertions, 210 deletions
diff --git a/hobgoblin/src/output/lang/java/ast.hob b/hobgoblin/src/output/lang/java/ast.hob index 93d6da2..f380173 100644 --- a/hobgoblin/src/output/lang/java/ast.hob +++ b/hobgoblin/src/output/lang/java/ast.hob @@ -153,7 +153,7 @@ struct JavaReturn { // == Expressions == sum JavaExpression { - variant JavaAssignment; + variant JavaBinaryOperation; variant JavaBooleanLiteral; variant JavaFieldAccess; variant JavaIntegerLiteral; @@ -165,14 +165,19 @@ sum JavaExpression { variant JavaStaticFieldAccess; variant JavaStaticMethodCall; variant JavaStringLiteral; - variant JavaUnsignedRightShift; } -struct JavaAssignment { +struct JavaBinaryOperation { + field operator: JavaBinaryOperator; field left: JavaExpression; field right: JavaExpression; } +enum JavaBinaryOperator { + variant assign; + variant unsignedRightShift; +} + struct JavaBooleanLiteral { field value: Bool; } @@ -224,11 +229,6 @@ struct JavaStringLiteral { field value: String; } -struct JavaUnsignedRightShift { - field left: JavaExpression; - field right: JavaExpression; -} - // == Identifiers == struct JavaIdentifier { diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java index 03d6ae7..69e8e94 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java @@ -133,7 +133,8 @@ public class JavaPreciselyMatchersGenerator implements Generator { ), new JavaBlock(List.of( new JavaExpressionStatement( - new JavaAssignment( + new JavaBinaryOperation( + JavaBinaryOperator.ASSIGN, new JavaFieldAccess(JavaRef.THIS, submatchersIdentifier), new JavaRef(submatchersIdentifier) ) diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java index e512650..ec91f63 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java @@ -39,10 +39,15 @@ public class JavaWriter implements AutoCloseable { this.writer.close(); } - private void writeAssignment(JavaAssignment assignment) throws IOException { - this.writeExpression(assignment.left()); - this.writer.write(" = "); - this.writeExpression(assignment.right()); + private void writeBinaryOperation(JavaBinaryOperation binaryOperation) throws IOException { + this.writeExpression(binaryOperation.left()); + this.writer.write(" "); + this.writer.write(switch (binaryOperation.operator()) { + case ASSIGN -> "="; + case UNSIGNED_RIGHT_SHIFT -> ">>>"; + }); + this.writer.write(" "); + this.writeExpression(binaryOperation.right()); } private void writeBooleanLiteral(JavaBooleanLiteral booleanLiteral) throws IOException { @@ -226,8 +231,8 @@ public class JavaWriter implements AutoCloseable { void writeExpression(JavaExpression expression) throws IOException { switch (expression) { - case JavaAssignment assignment -> { - writeAssignment(assignment); + case JavaBinaryOperation binaryOperation -> { + writeBinaryOperation(binaryOperation); } case JavaBooleanLiteral booleanLiteral -> { @@ -273,10 +278,6 @@ public class JavaWriter implements AutoCloseable { case JavaStringLiteral stringLiteral -> { writeStringLiteral(stringLiteral); } - - case JavaUnsignedRightShift unsignedRightShift -> { - writeUnsignedRightShift(unsignedRightShift); - } } } @@ -571,12 +572,6 @@ public class JavaWriter implements AutoCloseable { } } - private void writeUnsignedRightShift(JavaUnsignedRightShift unsignedRightShift) throws IOException { - this.writeExpression(unsignedRightShift.left()); - this.writer.write(" >>> "); - this.writeExpression(unsignedRightShift.right()); - } - private void writeVisibility(JavaVisibility visibility) throws IOException { this.writer.write(switch (visibility) { case PUBLIC -> "public"; diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignment.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignment.java deleted file mode 100644 index d9ca0c1..0000000 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignment.java +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.java.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment imports - -public record JavaAssignment(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { - public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build()); - } - - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment build() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment(left, right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder withLeft(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder(left, right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder withLeft(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder left) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder(left.build(), right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder withRight(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder(left, right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder withRight(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder right) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder(left, right.build()); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.Builder body - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment body -} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperation.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperation.java new file mode 100644 index 0000000..cb1c0ef --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperation.java @@ -0,0 +1,44 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation imports + +public record JavaBinaryOperation(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator operator, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder arbitrary() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator.ASSIGN, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build()); + } + + public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator operator, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation build() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation(operator, left, right); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder withOperator(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator operator) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder(operator, left, right); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder withLeft(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder(operator, left, right); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder withLeft(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder left) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder(operator, left.build(), right); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder withRight(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder(operator, left, right); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder withRight(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder right) { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder(operator, left, right.build()); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.Builder body + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperator.java new file mode 100644 index 0000000..4f646ba --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperator.java @@ -0,0 +1,14 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator imports + +public enum JavaBinaryOperator { + ASSIGN, + UNSIGNED_RIGHT_SHIFT + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator body +} diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaExpression.java index 7e9cdad..7652041 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaExpression.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaExpression.java @@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.java.ast; // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression imports // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression imports -public sealed interface JavaExpression permits org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaNewExpression, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaNullLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStringLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift { +public sealed interface JavaExpression permits org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaFieldAccess, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIntegerLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodCall, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaMethodRef, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaNewExpression, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaNullLiteral, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaRef, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticFieldAccess, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStaticMethodCall, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaStringLiteral { public interface Builder { public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression build(); diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShift.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShift.java deleted file mode 100644 index aced126..0000000 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShift.java +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.java.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift imports - -public record JavaUnsignedRightShift(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression { - public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder arbitrary() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build(), org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBooleanLiteral.arbitrary().build()); - } - - public record Builder(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left, org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) implements org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder { - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift build() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift(left, right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder withLeft(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression left) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder(left, right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder withLeft(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder left) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder(left.build(), right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder withRight(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression right) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder(left, right); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder withRight(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression.Builder right) { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder(left, right.build()); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.Builder body - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift body -} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java index ff374fb..8c3531f 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java @@ -836,8 +836,9 @@ public class JavaWriterTests { } @Test - public void assignment() throws IOException { - var java = new JavaAssignment( + public void binaryOperationAssignment() throws IOException { + var java = new JavaBinaryOperation( + JavaBinaryOperator.ASSIGN, new JavaRef(JavaIdentifier.of("x")), new JavaIntegerLiteral(42) ); @@ -848,6 +849,19 @@ public class JavaWriterTests { } @Test + public void binaryOperationUnsignedRightShift() throws IOException { + var java = JavaBinaryOperation.arbitrary() + .withOperator(JavaBinaryOperator.UNSIGNED_RIGHT_SHIFT) + .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x"))) + .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y"))) + .build(); + + var string = write(writer -> writer.writeExpression(java)); + + assertThat(string, equalTo("x >>> y")); + } + + @Test public void fieldAccess() throws IOException { var java = new JavaFieldAccess( new JavaRef(JavaIdentifier.of("one")), @@ -905,18 +919,6 @@ public class JavaWriterTests { } @Test - public void unsignedRightShift() throws IOException { - var java = JavaUnsignedRightShift.arbitrary() - .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x"))) - .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y"))) - .build(); - - var string = write(writer -> writer.writeExpression(java)); - - assertThat(string, equalTo("x >>> y")); - } - - @Test public void typeRefWithoutArgsHasNoAngleBrackets() throws IOException { var java = JavaTypeRef.topLevel( JavaPackageName.of("abc", "def"), diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignmentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignmentMatcher.java deleted file mode 100644 index dd3ce7d..0000000 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignmentMatcher.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.java.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher imports - -public class JavaAssignmentMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher isJavaAssignment() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher(java.util.List.of()); - } - - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>> submatchers; - - private JavaAssignmentMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>> submatchers) { - this.submatchers = submatchers; - } - - public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { - return this.toMatcher().match(actual); - } - - public org.zwobble.precisely.TextTree describe() { - return this.toMatcher().describe(); - } - - private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { - return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment.class, this.submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> left) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment::left, left)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> right) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment::right, right)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher(submatchers); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher body -} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperationMatcher.java new file mode 100644 index 0000000..4157a44 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperationMatcher.java @@ -0,0 +1,51 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher imports + +public class JavaBinaryOperationMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher isJavaBinaryOperation() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>> submatchers; + + private JavaBinaryOperationMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>> submatchers) { + this.submatchers = submatchers; + } + + public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { + return this.toMatcher().match(actual); + } + + public org.zwobble.precisely.TextTree describe() { + return this.toMatcher().describe(); + } + + private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher withOperator(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator> operator) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("operator", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation::operator, operator)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> left) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation::left, left)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> right) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation::right, right)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShiftMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShiftMatcher.java deleted file mode 100644 index 7da71c1..0000000 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShiftMatcher.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.java.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher imports - -public class JavaUnsignedRightShiftMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher isJavaUnsignedRightShift() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher(java.util.List.of()); - } - - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>> submatchers; - - private JavaUnsignedRightShiftMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>> submatchers) { - this.submatchers = submatchers; - } - - public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { - return this.toMatcher().match(actual); - } - - public org.zwobble.precisely.TextTree describe() { - return this.toMatcher().describe(); - } - - private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { - return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift.class, this.submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> left) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift::left, left)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> right) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift::right, right)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher(submatchers); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher body -} |
