diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-11 20:03:13 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-11 20:03:13 +0100 |
| commit | 975e56cb795a42e576a3e44aee155ff3a81b601b (patch) | |
| tree | 7610e73325b76693294e17e5013032977e3dd8c9 /src/main/java/org/shedlang/compiler/cli | |
| parent | 225ffd949c67664faceca9ab6d9b86b19a8a71dd (diff) | |
Add stubbed LLVM backend
Diffstat (limited to 'src/main/java/org/shedlang/compiler/cli')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/cli/ShedCli.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/org/shedlang/compiler/cli/ShedCli.java b/src/main/java/org/shedlang/compiler/cli/ShedCli.java index 169e6e7f..c2106768 100644 --- a/src/main/java/org/shedlang/compiler/cli/ShedCli.java +++ b/src/main/java/org/shedlang/compiler/cli/ShedCli.java @@ -4,6 +4,8 @@ import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import org.shedlang.compiler.ShedCompiler; +import org.shedlang.compiler.backends.GenerateInstructionsBackend; +import org.shedlang.compiler.backends.llvm.LlvmBackend; import org.shedlang.compiler.errors.SourceError; import java.io.IOException; @@ -27,11 +29,13 @@ public class ShedCli { var compiler = new ShedCompiler(); switch (args.<Command>get("command")) { + case COMPILE -> { + compiler.compile(sourcePath, new LlvmBackend()); + } case GENERATE_INSTRUCTIONS -> { - compiler.compile(sourcePath); + compiler.compile(sourcePath, new GenerateInstructionsBackend()); } } - } private static Namespace parseArgs(String[] args) { @@ -40,6 +44,12 @@ public class ShedCli { var subparsers = parser.addSubparsers(); + var compileSubParser = subparsers.addParser("compile"); + compileSubParser.setDefault("command", Command.COMPILE); + compileSubParser.addArgument("source").required(true); + compileSubParser.addArgument("--backend").choices("llvm").required(true); + compileSubParser.addArgument("-o", "--output").dest("output").required(true); + var generateInstructionsSubParser = subparsers.addParser("generate-instructions"); generateInstructionsSubParser.setDefault("command", Command.GENERATE_INSTRUCTIONS); generateInstructionsSubParser.addArgument("source").required(true); @@ -54,6 +64,7 @@ public class ShedCli { } private enum Command { + COMPILE, GENERATE_INSTRUCTIONS, } } |
