from tokenizer import tokenize from ground_ast import generate_ast from rich import print from time import time from generators import x86_64 from os import system, remove from error import traceback def main(): in_path = "test2.grnd" out_path = "out" arch = "x86_64" start = time() file = open(in_path, "r") code = file.read() file.close() tokens = tokenize(code) ast = generate_ast(tokens, code) generator = None if arch == "x86_64": generator = x86_64.X86_64Generator(ast, code, out_path) else: traceback(code, "fatal error", f"unkown architecture \"{arch}\"") generator.init() system(f"nasm -felf64 {out_path}.asm") system(f"ld -o {out_path} {out_path}.o -m elf_{arch}") remove(out_path + ".o") remove(out_path + ".asm") compile_time = time()-start print(f"Compiled in {round(compile_time, 1)} seconds.") if __name__ == "__main__": main()