feat: beta compiling to fasm (codegen) + hello world example let's goooo

This commit is contained in:
2025-11-30 22:04:35 +01:00
parent 22f745e8dc
commit 16cc06b788
14 changed files with 1141 additions and 135 deletions

View File

@@ -3,6 +3,8 @@
#include <print>
#include "lexer.hpp"
#include "ast.hpp"
#include "ir.hpp"
#include "codegen.hpp"
void dump_tokens(const char* filename, Lexer* lexer)
{
@@ -19,9 +21,6 @@ void dump_tokens(const char* filename, Lexer* lexer)
int main(int argc, char** argv)
{
for (int i = 0; i < argc; ++i) {
std::println("arg#{}: {}", i, argv[i]);
}
char* filename;
if (argc > 1) {
filename = (++argv)[0];
@@ -40,11 +39,25 @@ int main(int argc, char** argv)
f.close();
Lexer lexer(filename, StringView(content.c_str(), content.size()));
Lexer lexer(filename, StringView(content.c_str()));
AstParser parser(&lexer);
auto program = parser.Parse();
IR::IRBuilder irBuilder(program);
auto ops = irBuilder.Build();
// printf("\n");
// for (size_t i = 0; i < ops.size; ++i)
// {
// printf("%s\n", ops.data[i]->Format(0).c_str());
// }
StackFasmX86_64Generator gen;
gen.Generate(filename, ops);
return 0;
}