diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-02 09:36:57 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-02 09:36:57 +0100 |
| commit | 514a0eefe86174ba535f46f3fb3481c539b79f96 (patch) | |
| tree | a9df50b83ff6d1881e9dcbfb26762c23bf21ff0c /src/main | |
| parent | 7a68e62df187a56bedd9891881af1d4f70404e3e (diff) | |
Reorder rust writer code to match AST definitions
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java | 32 |
1 files changed, 21 insertions, 11 deletions
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"); + } + } } |
