luaaaaah/Program.cs

55 lines
977 B
C#

namespace luaaaaah;
public class Program
{
public static void Main(string[] args)
{
switch(args[0])
{
case "test":
{
Test(args[1]);
}
break;
case "run":
{
Run(args[1]);
}
break;
}
}
public static void Run(string file)
{
Token[] tokens = new Tokenizer().Tokenize(File.ReadAllText(file));
foreach(Token token in tokens)
{
Console.WriteLine($"{token.region}: {token.type} {{{token.data}}}");
}
}
public static void Test(string directory)
{
Dictionary<string, string> failedFiles = [];
foreach(string file in Directory.EnumerateFiles(directory))
{
if(file.EndsWith(".lua"))
{
try
{
Run(file);
}
catch(Exception e)
{
Console.WriteLine($"{file}: {e.Message}");
failedFiles.Add(file, e.Message);
}
}
}
Console.WriteLine("===FAILED===");
foreach(KeyValuePair<string, string> entry in failedFiles)
{
Console.WriteLine($"{entry.Key}: {entry.Value}");
}
}
}