33 lines
756 B
C#
33 lines
756 B
C#
using Compiler;
|
|
|
|
var file = File.ReadAllText("test.nub");
|
|
|
|
var tokens = Tokenizer.Tokenize("test.nub", file, out var tokenizerDiagnostics);
|
|
|
|
foreach (var diagnostic in tokenizerDiagnostics)
|
|
{
|
|
DiagnosticFormatter.Print(diagnostic, Console.Error);
|
|
}
|
|
|
|
if (tokenizerDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
var nodes = Parser.Parse("test.nub", tokens, out var parserDiagnostics);
|
|
|
|
foreach (var diagnostic in parserDiagnostics)
|
|
{
|
|
DiagnosticFormatter.Print(diagnostic, Console.Error);
|
|
}
|
|
|
|
if (parserDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
var output = Generator.Emit(nodes);
|
|
|
|
File.WriteAllText("C:/Users/oliste/repos/nub-lang/compiler/Compiler/out.c", output);
|
|
|
|
return 0; |