def main(): # Input file Path in_file = Path(argv[1]) # Check if provided argument is # a file or a directory if (in_file.is_dir()): # Argument path to a directory out_file = in_file / in_file.with_suffix(".asm") elif (in_file.is_file()): # Argument is path to a file # Output file Path out_file = in_file.with_suffix(".asm") # Construct a CodeWriter to # handle output file asm_writer = CodeWriter(out_file) if (in_file.is_file()): # Translate the single file translate_in_file(asm_writer, in_file) elif (in_file.is_dir()): # Have to loop through every file asm_writer.write_bootstrap_code() # Loop through each file and translate for f in in_file.iterdir(): # File is .vm file? if f.suffix == ".vm": print(f"translating {f.name}...") asm_writer.set_file_name(f.stem) translate_in_file(asm_writer, f)