summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-12-05 21:37:21 +0000
committerMichael Williamson <mike@zwobble.org>2026-12-05 21:37:21 +0000
commit5a646ae3ae92b9756e005b38e40f9fd8476cdc7c (patch)
tree5a1edc8c98d8d3e19f04cab0c8e92122a8aba1b4 /src/main
parentc2c7d9d6ecdbd5ab361d90e420e4460c8a68a7dc (diff)
Add param refs to SQL AST
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java9
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java2
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java32
3 files changed, 42 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java
index 04c7869..4e0b71b 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/SqlWriter.java
@@ -187,6 +187,10 @@ public class SqlWriter {
this.writeIntLiteral(intLiteral);
}
+ case SqlParamRef paramRef -> {
+ this.writeParamRef(paramRef);
+ }
+
case SqlRef ref -> {
this.writeRef(ref);
}
@@ -219,6 +223,11 @@ public class SqlWriter {
this.writer.write(Long.toString(intLiteral.value()));
}
+ private void writeParamRef(SqlParamRef paramRef) throws IOException {
+ this.writer.write("?");
+ this.writer.write(Integer.toString(paramRef.number()));
+ }
+
private void writeRef(SqlRef ref) throws IOException {
this.writeIdentifier(ref.name());
}
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java
index 10b4e93..6075ebc 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlExpression.java
@@ -5,7 +5,7 @@ package org.zwobble.hobgoblin.compiler.output.lang.sql.ast;
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression imports
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression imports
-public sealed interface SqlExpression permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIntLiteral, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef {
+public sealed interface SqlExpression permits org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlBinaryOperation, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlColumnReference, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlIntLiteral, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef, org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlRef {
public interface Builder {
public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression build();
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java
new file mode 100644
index 0000000..f2203dd
--- /dev/null
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/sql/ast/SqlParamRef.java
@@ -0,0 +1,32 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.sql.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef imports
+
+public record SqlParamRef(
+ int number
+) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression {
+ public static org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder arbitrary() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder(0);
+ }
+
+ public record Builder(
+ int number
+ ) implements org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlExpression.Builder {
+ public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef build() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef(number);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder withNumber(int number) {
+ return new org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder(number);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef.Builder body
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.sql.ast.SqlParamRef body
+}