summaryrefslogtreecommitdiff
path: root/Orchestrator/Program.cs
blob: a59127b5a72252efc804c494798cd3cc4ce893be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace Orchestrator;

using CommandLine;
using Q1.Assembler;
using Q1.Compiler;
using Q1.Emulator;

class Program
{
    static void Main(string[] args)
    {
        Parser p = new(with =>
        {
            with.CaseInsensitiveEnumValues = true;
        });
        
        p.ParseArguments<Options>(args).WithParsed(Main);
    }
    
    private static void Main(Options options)
    {
        string compiledFile = Path.ChangeExtension(options.InputFile, "asm");
        string assembledFile = Path.ChangeExtension(options.InputFile, "q1");
        
        Q1.Compiler.Program.Main(new CompilerOptions
        {
            CommentCompilationMode = options.CommentCompilationMode,
            InputFile = options.InputFile,
            OutputFile = compiledFile
        });
        
        Q1.Assembler.Program.Main(new AssemblerOptions
        {
            InputFile = compiledFile,
            OutputFile = assembledFile
        });
        
        Q1.Emulator.Program.Main(new EmulatorOptions
        {
            InputFile = assembledFile,
        });
    }
}

class Options
{
    [Option('i', "input", Required = true, HelpText = "Input file to process.")]
    public string InputFile { get; set; }
    
    [Option('c', "comment-compilation", Required = false, HelpText = "Comments to preserve in the compiled result")]
    public CommentCompilationMode CommentCompilationMode { get; set; } = CommentCompilationMode.UserDefined;
}