diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2025-08-06 22:36:34 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2025-08-06 22:36:34 +1000 |
| commit | 7a8d2bcd75d88a5429937bf551878c55e1dcf0fd (patch) | |
| tree | 81bc1f259fb8678513aa8b214df4ef72720bb585 /Compiler/Program.cs | |
| parent | 16f3cb74564cf7c19da6e13666c98aca36094716 (diff) | |
moved everything to seperate projects, and started compiler work + push and pop instructions added
Diffstat (limited to 'Compiler/Program.cs')
| -rw-r--r-- | Compiler/Program.cs | 31 |
1 files changed, 31 insertions, 0 deletions
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<Options>(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 |
