diff --git a/src/compiler/Nub.Lang.CLI/Nub.Lang.CLI.csproj b/src/compiler/Nub.Lang.CLI/Nub.Lang.CLI.csproj
new file mode 100644
index 0000000..e9b75dd
--- /dev/null
+++ b/src/compiler/Nub.Lang.CLI/Nub.Lang.CLI.csproj
@@ -0,0 +1,16 @@
+
+
+
+ nub
+ Exe
+ net9.0
+ enable
+ enable
+ true
+
+
+
+
+
+
+
diff --git a/src/compiler/Nub.Lang.CLI/Program.cs b/src/compiler/Nub.Lang.CLI/Program.cs
new file mode 100644
index 0000000..a5552dd
--- /dev/null
+++ b/src/compiler/Nub.Lang.CLI/Program.cs
@@ -0,0 +1,57 @@
+using Nub.Lang.Backend;
+using Nub.Lang.Frontend.Diagnostics;
+using Nub.Lang.Frontend.Lexing;
+using Nub.Lang.Frontend.Parsing;
+using Nub.Lang.Frontend.Typing;
+
+if (args.Length != 1)
+{
+ Console.Error.WriteLine("Usage: nub ");
+ Console.Error.WriteLine("Example: nub src");
+ return 1;
+}
+
+var srcDir = Path.GetFullPath(args[0]);
+
+if (!Directory.Exists(srcDir))
+{
+ Console.Error.WriteLine($"Error: Input directory '{srcDir}' does not exist.");
+ return 1;
+}
+
+var error = false;
+var lexer = new Lexer();
+var parser = new Parser();
+var typeChecker = new TypeChecker();
+
+List files = [];
+foreach (var file in Directory.EnumerateFiles(srcDir, "*.nub", SearchOption.AllDirectories))
+{
+ var content = File.ReadAllText(file);
+
+ var tokenizeResult = lexer.Tokenize(new SourceText(file, content));
+ tokenizeResult.PrintAllDiagnostics();
+ error = error || tokenizeResult.HasErrors;
+
+ var parseResult = parser.ParseModule(tokenizeResult.Value);
+ parseResult.PrintAllDiagnostics();
+ error = error || parseResult.HasErrors;
+
+ if (parseResult.Value != null)
+ {
+ files.Add(parseResult.Value);
+ }
+}
+
+var typeCheckResult = typeChecker.TypeCheck(files);
+typeCheckResult.PrintAllDiagnostics();
+error = error || typeCheckResult.HasErrors;
+
+if (error) return 1;
+
+var generator = new Generator();
+var result = generator.Generate(files);
+
+Console.Out.Write(result);
+
+return 0;
\ No newline at end of file
diff --git a/src/compiler/Nub.Lang.sln b/src/compiler/Nub.Lang.sln
index c5692ff..3b0a90e 100644
--- a/src/compiler/Nub.Lang.sln
+++ b/src/compiler/Nub.Lang.sln
@@ -2,6 +2,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nub.Lang", "Nub.Lang\Nub.Lang.csproj", "{5047E21F-590D-4CB3-AFF3-064316485009}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nub.Lang.CLI", "Nub.Lang.CLI\Nub.Lang.CLI.csproj", "{A22F17ED-FA17-45AB-92BA-CD02C28B3524}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +14,9 @@ Global
{5047E21F-590D-4CB3-AFF3-064316485009}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5047E21F-590D-4CB3-AFF3-064316485009}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5047E21F-590D-4CB3-AFF3-064316485009}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/src/compiler/Nub.Lang/Nub.Lang.csproj b/src/compiler/Nub.Lang/Nub.Lang.csproj
index ee51912..b682a68 100644
--- a/src/compiler/Nub.Lang/Nub.Lang.csproj
+++ b/src/compiler/Nub.Lang/Nub.Lang.csproj
@@ -1,12 +1,10 @@
- nub
- Exe
net9.0
enable
enable
- true
+ true
diff --git a/src/compiler/Nub.Lang/Program.cs b/src/compiler/Nub.Lang/Program.cs
deleted file mode 100644
index 4dd96bb..0000000
--- a/src/compiler/Nub.Lang/Program.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using Nub.Lang.Backend;
-using Nub.Lang.Frontend.Diagnostics;
-using Nub.Lang.Frontend.Lexing;
-using Nub.Lang.Frontend.Parsing;
-using Nub.Lang.Frontend.Typing;
-
-namespace Nub.Lang;
-
-internal static class Program
-{
- public static int Main(string[] args)
- {
- if (args.Length != 1)
- {
- Console.Error.WriteLine("Usage: nub ");
- Console.Error.WriteLine("Example: nub src");
- return 1;
- }
-
- var srcDir = Path.GetFullPath(args[0]);
-
- if (!Directory.Exists(srcDir))
- {
- Console.Error.WriteLine($"Error: Input directory '{srcDir}' does not exist.");
- return 1;
- }
-
- return Compile(srcDir);
- }
-
- private static int Compile(string srcDir)
- {
- var error = false;
- var lexer = new Lexer();
- var parser = new Parser();
- var typeChecker = new TypeChecker();
-
- List files = [];
- foreach (var file in Directory.EnumerateFiles(srcDir, "*.nub", SearchOption.AllDirectories))
- {
- var content = File.ReadAllText(file);
-
- var tokenizeResult = lexer.Tokenize(new SourceText(file, content));
- tokenizeResult.PrintAllDiagnostics();
- error = error || tokenizeResult.HasErrors;
-
- var parseResult = parser.ParseModule(tokenizeResult.Value);
- parseResult.PrintAllDiagnostics();
- error = error || parseResult.HasErrors;
-
- if (parseResult.Value != null)
- {
- files.Add(parseResult.Value);
- }
- }
-
- var typeCheckResult = typeChecker.TypeCheck(files);
- typeCheckResult.PrintAllDiagnostics();
- error = error || typeCheckResult.HasErrors;
-
- if (error) return 1;
-
- var generator = new Generator();
- var result = generator.Generate(files);
-
- Console.Out.Write(result);
-
- return 0;
- }
-}
\ No newline at end of file