From 7a8d2bcd75d88a5429937bf551878c55e1dcf0fd Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:36:34 +1000 Subject: moved everything to seperate projects, and started compiler work + push and pop instructions added --- Compiler/Program.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Compiler/Program.cs (limited to 'Compiler/Program.cs') diff --git a/Compiler/Program.cs b/Compiler/Program.cs new file mode 100644 index 0000000..b832a53 --- /dev/null +++ b/Compiler/Program.cs @@ -0,0 +1,31 @@ +namespace Q1.Compiler; + +using Antlr4.Runtime; +using CommandLine; +using Parser = CommandLine.Parser; + +class Program +{ + static void Main(string[] args) + { + Parser.Default.ParseArguments(args).WithParsed(Program.Main); + } + + static void Main(Options options) + { + Environment.CurrentDirectory = Path.GetDirectoryName(options.InputFile) ?? Environment.CurrentDirectory; + options.InputFile = Path.GetFileName(options.InputFile); + + AntlrFileStream inputStream = new(options.InputFile); + CGrammarLexer lexer = new(inputStream); + lexer.RemoveErrorListeners(); + + CommonTokenStream tokenStream = new(lexer); + CGrammarParser parser = new(tokenStream); + parser.RemoveErrorListeners(); + + CCompilerVisitor compiler = new(); + var result = compiler.Compile(parser.program()); + File.WriteAllLines(options.OutputFile, result); + } +} \ No newline at end of file -- cgit v1.3.1