...
This commit is contained in:
2
compiler/.gitignore
vendored
2
compiler/.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
bin
|
bin
|
||||||
obj
|
obj
|
||||||
out.c
|
.build
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using Compiler;
|
using System.Diagnostics;
|
||||||
|
using Compiler;
|
||||||
const string fileName = "test.nub";
|
|
||||||
|
|
||||||
|
foreach (var fileName in args)
|
||||||
|
{
|
||||||
var file = File.ReadAllText(fileName);
|
var file = File.ReadAllText(fileName);
|
||||||
|
|
||||||
var tokens = Tokenizer.Tokenize(fileName, file, out var tokenizerDiagnostics);
|
var tokens = Tokenizer.Tokenize(fileName, file, out var tokenizerDiagnostics);
|
||||||
@@ -42,6 +43,14 @@ if (typeCheckerDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
|
|||||||
|
|
||||||
var output = Generator.Emit(typedAst);
|
var output = Generator.Emit(typedAst);
|
||||||
|
|
||||||
File.WriteAllText("out.c", output);
|
Directory.Delete(".build", recursive: true);
|
||||||
|
Directory.CreateDirectory(".build");
|
||||||
|
|
||||||
|
var outFilePath = Path.Combine(".build", Path.ChangeExtension(fileName, "c"));
|
||||||
|
File.WriteAllText(outFilePath, output);
|
||||||
|
|
||||||
|
Process.Start("gcc", ["-Og", "-g", "-c", "-o", Path.ChangeExtension(outFilePath, "o"), outFilePath]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
Reference in New Issue
Block a user