From 975e56cb795a42e576a3e44aee155ff3a81b601b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 11 Jun 2023 20:03:13 +0100 Subject: Add stubbed LLVM backend --- src/main/java/org/shedlang/compiler/cli/ShedCli.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/shedlang/compiler/cli') 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.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, } } -- cgit v1.2.3