summaryrefslogtreecommitdiff
path: root/Compiler/Program.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-08 23:57:26 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-08 23:57:26 +1000
commite62b66dd08ca445d1f7e5b802a503ad3ec83b2df (patch)
tree8cdb4ee09d1eefe096f51d6c9150dc361d08ccb9 /Compiler/Program.cs
parent33e1c5fc6e37549b4eba833ae7e534f9da250b10 (diff)
added branching to compiler and comment generation
Diffstat (limited to 'Compiler/Program.cs')
-rw-r--r--Compiler/Program.cs17
1 files changed, 12 insertions, 5 deletions
diff --git a/Compiler/Program.cs b/Compiler/Program.cs
index b832a53..fdd8722 100644
--- a/Compiler/Program.cs
+++ b/Compiler/Program.cs
@@ -8,10 +8,16 @@ class Program
{
static void Main(string[] args)
{
- Parser.Default.ParseArguments<Options>(args).WithParsed(Program.Main);
+ Parser commandLineParser = new(with =>
+ {
+ with.CaseInsensitiveEnumValues = true;
+ });
+
+ commandLineParser.ParseArguments<CompilerOptions>(args)
+ .WithParsed(Program.Main);
}
- static void Main(Options options)
+ static void Main(CompilerOptions options)
{
Environment.CurrentDirectory = Path.GetDirectoryName(options.InputFile) ?? Environment.CurrentDirectory;
options.InputFile = Path.GetFileName(options.InputFile);
@@ -20,12 +26,13 @@ class Program
CGrammarLexer lexer = new(inputStream);
lexer.RemoveErrorListeners();
- CommonTokenStream tokenStream = new(lexer);
+ ITokenStream tokenStream = new BufferedTokenStream(lexer);
CGrammarParser parser = new(tokenStream);
parser.RemoveErrorListeners();
- CCompilerVisitor compiler = new();
- var result = compiler.Compile(parser.program());
+ CCompilerVisitor compiler = new(options.CommentCompilationMode);
+ IEnumerable<string> result = compiler.Compile(parser.program());
+
File.WriteAllLines(options.OutputFile, result);
}
} \ No newline at end of file