feat: code translation scaffolding

This commit is contained in:
2026-03-30 15:59:50 +01:00
parent 8888f7b97a
commit d01abac9e9
4 changed files with 28 additions and 2 deletions
+13 -1
View File
@@ -4,12 +4,16 @@
#include <string>
#include <vector>
#include "code.hpp"
#include "parser.hpp"
#include "utils.hpp"
int process(std::string source) {
std::ifstream ifs(source);
std::string out = source.substr(0, source.find_last_of('.')) + ".asm";
std::ofstream ofs(out);
std::string line;
std::string output;
std::vector<Command> commands;
@@ -25,9 +29,17 @@ int process(std::string source) {
}
for (const Command &cmd : commands) {
std::cout << int(cmd.type) << " " << int(cmd.segment) << " " << cmd.index << std::endl;
int translateResult;
if ((translateResult = translateCommand(output, cmd)) != 0) {
return translateResult;
}
ofs << output;
}
ifs.close();
ofs.close();
return 0;
}