HOLY COW VARIABLES WORK

This commit is contained in:
SpookyDervish
2025-09-02 06:42:58 +10:00
parent 88cdcfa54f
commit a1e1cf3dd8
7 changed files with 93 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ class Generator:
self.lines: list[str] = []
self.code = code
self.output_path = output_path
self.variables = {}
def init(self):
pass
@@ -15,12 +16,13 @@ class Generator:
self.lines.append(f"; {node}\n\t")
node_type = str(type(node))[19:-2]
if not hasattr(self, f"generate_{node_type}"):
raise Exception(f"Generator has no generate method for {node_type}.")
raise NotImplementedError(f"Generator has no generate method for {node_type}.")
getattr(self, f"generate_{node_type}")(node)
def generate(self):
for statement in self.ast.statements:
self.generate_node(statement)
def write(self):
with open(self.output_path + ".asm", "w") as f:
f.writelines(self.lines)