blob: 86a1c15bb7fe5be1c61d25a3ea691e2785bc4af6 (
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
|
using AtLangCompiler;
using System.Diagnostics;
public class Program
{
public static void Main(string[] args)
{
if (args.Length != 1 || string.IsNullOrWhiteSpace(args[0]))
{
Console.WriteLine("Incorrect arguments!");
Console.WriteLine("Usage: AtLangCompiler.dll <source file path>");
}
string atPath = Path.GetFullPath(args[0]);
if (!File.Exists(atPath))
{
throw new FileNotFoundException(atPath);
}
string code = File.ReadAllText(atPath);
string sourceName = Path.GetFileNameWithoutExtension(atPath);
string outputFileName = $"{sourceName}.exe";
string outputPath = Path.GetFullPath(outputFileName);
Console.WriteLine($"Building {Path.GetFileName(atPath)}");
Stopwatch sw = Stopwatch.StartNew();
try
{
Compiler.CompileToIL(code, outputPath);
sw.Stop();
}
catch (Exception ex)
{
Console.WriteLine($"Failure to compile {atPath}");
Console.Write(ex.ToString());
}
Console.WriteLine($"Generated {outputFileName} in {sw.ElapsedMilliseconds}ms.");
Console.WriteLine($"Try: dotnet {outputPath}");
}
}
|