diff options
Diffstat (limited to 'src/main/java/org/zwobble/couscous/backends/csharp/CsharpBackend.java')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/backends/csharp/CsharpBackend.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/org/zwobble/couscous/backends/csharp/CsharpBackend.java b/src/main/java/org/zwobble/couscous/backends/csharp/CsharpBackend.java new file mode 100644 index 0000000..3f6c8a7 --- /dev/null +++ b/src/main/java/org/zwobble/couscous/backends/csharp/CsharpBackend.java @@ -0,0 +1,34 @@ +package org.zwobble.couscous.backends.csharp; + +import org.zwobble.couscous.Backend; +import org.zwobble.couscous.ast.ClassNode; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import static org.zwobble.couscous.util.ExtraLists.list; + +public class CsharpBackend implements Backend { + private final Path directoryPath; + private final String namespace; + + public CsharpBackend(Path directoryPath, String namespace) { + this.directoryPath = directoryPath; + this.namespace = namespace; + } + + @Override + public void compile(List<ClassNode> classes) throws IOException { + Files.write(directoryPath.resolve("Program.cs"), list( + "namespace " + namespace + "{" + + " class Program {" + + " public static string run() {" + + " return \"T\";" + + " }" + + " }" + + "}" + )); + } +} |
