functions basically work now, but they're extremely inneficient

This commit is contained in:
SpookyDervish
2025-09-13 06:26:15 +10:00
parent 865a31827a
commit 170272353c
6 changed files with 74 additions and 66 deletions

View File

@@ -1,6 +1,7 @@
from ground_ast import RootNode
from typing import Any
from ground_ast import *
from error import warning
class SymbolTable:
@@ -74,7 +75,7 @@ class Generator:
pass
def generate_node(self, node):
self.lines.append(f"; {node}\n\t")
#self.lines.append(f"; {node}\n\t")
node_type = str(type(node))[19:-2]
if not hasattr(self, f"generate_{node_type}"):
raise NotImplementedError(f"Generator has no generate method for {node_type}.")
@@ -83,6 +84,9 @@ class Generator:
def generate(self):
for statement in self.ast.statements:
self.generate_node(statement)
for name, var in self.global_scope.table.items():
if not var["used"]:
warning(self.code, f"warning: \"{name}\" was defined but never used.")
def write(self):
with open(self.output_path + ".asm", "w") as f: