From 514a0eefe86174ba535f46f3fb3481c539b79f96 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 2 Jul 2026 09:36:57 +0100 Subject: Reorder rust writer code to match AST definitions --- .../compiler/output/lang/rust/RustWriter.java | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java index 77ed461..514e3f5 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java @@ -37,13 +37,7 @@ public class RustWriter implements AutoCloseable { this.writer.close(); } - private void writeDocComment(DocComment docComment) throws IOException { - for (var line : docComment.lines()) { - this.writer.write("/// "); - this.writer.write(line); - this.writer.write("\n"); - } - } + // == Modules == public void writeModule(RustModule module) throws IOException { writeWithSeparator( @@ -58,10 +52,7 @@ public class RustWriter implements AutoCloseable { this.writer.newLine(); } - void writeIdentifier(RustIdentifier identifier) throws IOException { - // TODO: handle keywords - this.writer.write(identifier.value()); - } + // == Items == void writeItem(RustItem item) throws IOException { switch (item) { @@ -96,6 +87,8 @@ public class RustWriter implements AutoCloseable { this.writer.write("}"); } + // == Types == + void writeType(RustType type) throws IOException { switch (type) { case RustTypePath typePath -> { @@ -133,4 +126,21 @@ public class RustWriter implements AutoCloseable { } } } + + // == Identifiers == + + void writeIdentifier(RustIdentifier identifier) throws IOException { + // TODO: handle keywords + this.writer.write(identifier.value()); + } + + // == Doc comments == + + private void writeDocComment(DocComment docComment) throws IOException { + for (var line : docComment.lines()) { + this.writer.write("/// "); + this.writer.write(line); + this.writer.write("\n"); + } + } } -- cgit v1.2.3