def main(): # If there is an invalid number of arguments the program stops. if len(sys.argv) != 2: print("ERROR: Invalid number of arguments. Expected: file_name.vm ") exit(1) # The VM translator accepts directories or vm files to be translated into assembly files. elif not os.path.isdir(sys.argv[1]) and sys.argv[1][-3:] != ".vm": print("ERROR: Invalid argument. Expected: directory or vm file") exit(1) # Get the name of the file to be parsed from the arguments. input_file = sys.argv[1] if os.path.isdir(input_file): # Split the file path file_path = input_file.split("/") if input_file.endswith("/"): # Creates the code writer with the given directory code_writer = CodeWriter("{}/{}".format(input_file, file_path[-2])) read_directory(input_file, code_writer) code_writer.close() else: # Creates the code writer with the given directory code_writer = CodeWriter("{}/{}".format(input_file, file_path[-1])) read_directory(input_file, code_writer) code_writer.close() else: # Creates the code writer with the input file excluding the .vm part code_writer = CodeWriter(input_file[0:-3]) read_file(input_file, code_writer) code_writer.close()
def main(argv): """ Main flow of program dealing with extracting files for reading and initializing files to translate into """ if not check_args(argv): return # extracting asm file to be processed vm_files_path = argv[1] # creating a .asm file to contain vm files translation to hack machine language if os.path.isdir(vm_files_path): dir_name = os.path.basename(vm_files_path) asm_file_name = "{0}/{1}.asm".format(vm_files_path, dir_name) code_writer = CodeWriter(asm_file_name) code_writer.write_init() for file in os.listdir(vm_files_path): if file.endswith(".vm"): code_writer.set_file_name(file) vm_parser = VMParser('{0}/{1}'.format(vm_files_path, file)) translate_vm_file(code_writer, vm_parser) else: asm_file_name = "{0}.asm".format(os.path.splitext(vm_files_path)[0]) code_writer = CodeWriter(asm_file_name) code_writer.write_init() code_writer.set_file_name(vm_files_path) vm_parser = VMParser(vm_files_path) translate_vm_file(code_writer, vm_parser)
def build_code_writer(dest): if is_dest_dir(dest): print('we have a dir') output_filename = str(dest.split('/')[-1]) output_filename = os.path.join(dest, output_filename + '.asm') print(output_filename) code_writer = CodeWriter(output_filename, dest) else: print('we have a file') output_filename = dest[:-3] + '.asm' print(output_filename) code_writer = CodeWriter(output_filename, dest[:-3]) return code_writer
def _set_website_snippet_controller_file(self, module): """ Function to set the module hook file :param module: :return: """ cw = CodeWriter() cw.emit("from odoo import http") cw.emit("from odoo.http import request") cw.emit("") cw.emit("") cw.emit("class HelloWorldController(http.Controller):") cw.emit("") with cw.indent(): cw.emit( f"@http.route(['/{module.name}/helloworld'], type='json', auth=\"public\", website=True," ) with cw.indent(): with cw.indent(): with cw.indent(): with cw.indent(): cw.emit("methods=['POST', 'GET'], csrf=False)") with cw.indent(): cw.emit("def hello_world(self):") with cw.indent(): cw.emit('return {"hello": "Hello World!"}') out = cw.render() l_model = out.split("\n") file_path = f"{self.code_generator_data.controllers_path}/main.py" self.code_generator_data.write_file_lst_content(file_path, l_model)
def set_module_python_file(self, module): super(CodeGeneratorWriter, self).set_module_python_file(module) if not module.theme_website: return cw = CodeWriter() for line in MODEL_HEAD: str_line = line.strip() cw.emit(str_line) cw.emit() cw.emit( f"class {self._get_class_name(module.name)}(models.AbstractModel):" ) with cw.indent(): cw.emit("_inherit = 'theme.utils'") cw.emit() with cw.indent(): cw.emit(f"def _{module.name}_post_copy(self, mod):") with cw.indent(): cw.emit( "self.disable_view('website_theme_install.customize_modal')" ) file_path = os.path.join( self.code_generator_data.models_path, f"{module.name}.py" ) self.code_generator_data.write_file_str(file_path, cw.render())
def main(infile_path: str, outfile_path: str): print(infile_path) vm_files = [path for path in glob.glob(infile_path + "/*.vm")] code_writer = CodeWriter(filepath=outfile_path) code_writer.write_init() for filepath in vm_files: print(filepath) parser = Parser(filepath=filepath) code_writer.set_file_path(filepath) while parser.hasMoreCommands(): cmd = parser.commandType() if cmd == C_ARITHMETIC: code_writer.writeArithmetic(parser.arithmetic()) elif cmd == C_PUSH or cmd == C_POP: code_writer.writePushPop(cmd, parser.arg1(), index=int(parser.arg2())) elif cmd == C_LABEL: code_writer.writeLabel(parser.arg1()) elif cmd == C_GOTO: code_writer.writeGoto(parser.arg1()) elif cmd == C_IF: code_writer.writeIf(parser.arg1()) elif cmd == C_FUNCTION: code_writer.writeFunction(parser.arg1(), parser.arg2()) elif cmd == C_RETURN: code_writer.writeReturn() elif cmd == C_CALL: code_writer.writeCall(parser.arg1(), parser.arg2()) parser.advance() code_writer.close()
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)
def generate_python_init_file(self, cg_module): for component, lst_module in self._dct_import_dir.items(): init_path = os.path.join(component, "__init__.py") if not component: lst_module = [a for a in self._dct_import_dir.keys() if a] lst_module.sort() cw = CodeWriter() if cg_module.license == "AGPL-3": cw.emit("# License AGPL-3.0 or later" " (https://www.gnu.org/licenses/agpl)") cw.emit() elif cg_module.license == "LGPL-3": cw.emit("# License LGPL-3.0 or later" " (https://www.gnu.org/licenses/lgpl)") cw.emit() else: _logger.warning(f"License {cg_module.license} not supported.") if component: for module in lst_module: cw.emit(f"from . import {module}") elif lst_module: cw.emit(f"from . import {', '.join(lst_module)}") for extra_import in self._dct_extra_module_init_path.get( component, []): cw.emit(extra_import) self.write_file_str(init_path, cw.render())
def test_mov_edi_literal(self): writer = CodeWriter() writer.mov_edi_literal(1234) code = writer.get_code() inst = code[len(code) - 5:] expected = [0xbf, 0xd2, 0x4, 0, 0] for i in range(len(expected)): self.assertEqual(inst[i], expected[i])
def main(input_file): if len(input_file.split('.')) == 1: if input_file[-1] == '/': input_file = input_file[:-1] output_file = join(input_file, input_file.split('/')[-1]) input_files = [ join(input_file, f) for f in listdir(input_file) if f.split('.')[1] == 'vm' and f != 'Sys.vm' and isfile(join(input_file, f)) ] input_files.insert(0, join(input_file, 'Sys.vm')) print('Input files: {}'.format(input_files)) else: input_files = [input_file] directory = '/'.join(input_file.split('/')[:-1]) output_file = join(directory, input_file.split('/')[-1].split('.')[0]) code_writer = CodeWriter(output_file) code_writer.write_init() for input_file in input_files: parser = Parser(input_file) code_writer.set_filename(input_file) n = 0 while parser.advance(): com_type = parser.command_type() print('LINE {}'.format(n)) print('\tcom type: {}'.format(com_type)) print('\tcommand: {}'.format(parser.command)) if com_type != parser.c_return: arg1 = parser.arg1() if com_type in [ parser.c_push, parser.c_pop, parser.c_function, parser.c_call ]: arg2 = parser.arg2() if com_type == parser.c_arithmetic: code_writer.write_arithmetic(arg1) elif com_type in [parser.c_pop, parser.c_push]: code_writer.write_push_pop(com_type, arg1, int(arg2)) elif com_type == parser.c_label: code_writer.write_label(arg1) elif com_type == parser.c_goto: code_writer.write_goto(arg1) elif com_type == parser.c_if: code_writer.write_if(arg1) elif com_type == parser.c_function: code_writer.write_function(arg1, arg2) elif com_type == parser.c_return: code_writer.write_return() elif com_type == parser.c_call: code_writer.write_call(arg1, arg2) n += 1 code_writer.close()
def main(): parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('path', type=str, help='vm file or folder') args = parser.parse_args() path = args.path if path.endswith(".vm"): # file with CodeWriter(path[:-3] + ".asm") as code_writer: translate_file(path, code_writer) print "Translated to", path[:-3] + ".asm" else: # directory if path.endswith("/"): path = path[:-1] with CodeWriter(path + ".asm") as code_writer: files = glob.glob("%s/*" % path) for file in files: if file.endswith(".vm"): translate_file(file, code_writer) print "Translated to", path + ".asm"
def __init__(self): """Inciializa una tabald e simbolos y un ecritor de codigo junto con variables auxiliares""" self.symbolTable = SymbolTable() self.contWhile = -1 self.contIf = -1 self.nombreClase = "" self.kindMetodo = "" self.nombreMetodo = "" self.vmWriter = CodeWriter() self.vmWriter.vm = "" self.nArgs = 0
def main(): argument = sys.argv[1] if argument.endswith('.vm'): asm_filename = argument.replace('.vm', '.asm') asm_file = open(asm_filename, 'a') code_writer = CodeWriter(asm_file) open_vm_file(argument, code_writer) code_writer.close() else: if argument.endswith('/'): argument = argument[0:-1] foldername = os.path.basename(argument) asm_file = open('%s/%s.asm' % (argument, foldername), 'a') code_writer = CodeWriter(asm_file) code_writer.write_comment('write init') code_writer.write_init() files = glob.glob('%s/*.vm' % argument) for file in files: open_vm_file(file, code_writer) code_writer.close()
def translate(vmfiles, asmfile): w = CodeWriter(asmfile) for fn in vmfiles: print 'Parsing %s...' % fn p = Parser(fn) w.set_filename(os.path.splitext(os.path.split(fn)[-1])[0]) # Insert Code Here print 'Writing %s...' % asmfile w.close()
def __init__(self, scanner, output_file=None): self.scanner = scanner self.tokens = scanner.tokens self.log = logging.getLogger('parser') self.table = SymbolTable() if not len(self.log.handlers): self.log.setLevel(logging.DEBUG) hdlr = logging.FileHandler('/tmp/myapp.log') formatter = logging.Formatter( '%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) self.log.addHandler(hdlr) self.writer = CodeWriter(out_file=output_file)
def main(): path = Util.getCommandLineArgument(1) code_writer = CodeWriter(path.replace('.vm', '') + '.asm') if os.path.isdir(path): files = FileSet(path, 'vm') while files.hasMoreFiles(): filename = files.nextFile() Main.parse(filename, code_writer) elif os.path.isfile(path): Main.parse(path, code_writer) code_writer.Close()
def generate(self): for file_path, lst_info in self.dct_cb.items(): cw = CodeWriter() lst_header = [b for a in lst_info for b in a[0]] # Fix divergence import try: index_pos = lst_header.index("import odoo.http as http") lst_header.pop(index_pos) lst_header.append("from odoo import http") except: pass set_header = set(lst_header) lst_cb = [a[1] for a in lst_info] enable_logger = any([a[3] for a in lst_info]) lst_inherit_class = list(set([a[2] for a in lst_info])) if len(lst_inherit_class) > 1: _logger.error( "Cannot support multiple class in the same python file:" f" '{lst_inherit_class}', filepath: '{file_path}'") continue str_inherit_class = lst_inherit_class[0] for line in set_header: cw.emit(line) if enable_logger: cw.emit("import logging") cw.emit("_logger = logging.getLogger(__name__)") cw.emit( "class" f" {self._module.name.replace('_', ' ').title().replace(' ', '')}Controller({str_inherit_class}):" ) with cw.indent(): for cb in lst_cb: cb(self._module, cw) out = cw.render() l_model = out.split("\n") self._code_generator_data.write_file_lst_content( file_path, l_model)
def main(): if len(sys.argv) != 2: print('<VMTranslator>: Execute script with ' 'one argument only (The path of an existing "vm" file)\n') exit() vm_file = sys.argv[1] parser = VMParser(vm_file) asm_file = vm_file.replace('.vm', '.asm') code_writer = CodeWriter(asm_file) while parser.has_more_commands(): code_writer.write_command(parser.command) parser.advance() code_writer.write_end() print '<VMTranslator>: Successfully created "{}"\n'.format(asm_file)
def main(): filename = sys.argv[1].split('.')[0] parser = Parser(filename) code = CodeWriter(filename) while(parser.has_more_commands()): parser.advance() command_type = parser.command_type() if command_type == 'C_ARITHMETIC': code.write_arithmetic(parser.arg1()) elif command_type == 'C_PUSH' or command_type == 'C_POP': code.write_push_pop(parser.command(), parser.arg1(), parser.arg2()) # print(parser.current_command) parser.close() code.close()
def main(): args = get_args() dbc_filepath = args.dbc output = args.output print_only = args.print_only dbc_node_name = args.dbc_node_name if not os.path.isfile(dbc_filepath): print("Unable to find DBC file: [{}]".format(dbc_filepath)) return 1 # Return early try: code_writer = CodeWriter(dbc_filepath, dbc_node_name) except InvalidDBCNodeError as err: print(ColorString(str(err)).red) return 1 # Return early if not print_only: dbc_filename = os.path.basename(dbc_filepath) basename, ext = os.path.splitext(os.path.basename(dbc_filepath)) output_filename = "{}.h".format(basename) if output is None: output_filepath = output_filename elif os.path.isdir(output) or "." not in os.path.basename(output): output_filepath = os.path.join(output, output_filename) else: output_filepath = output message = "Generating code [{}] -> [{}]".format( dbc_filename, output_filename) if dbc_node_name != GENERATE_ALL_NODE_NAME: message += " using node [{}]".format(dbc_node_name) print(ColorString(message).green) if not os.path.isdir(os.path.dirname(output_filepath)): os.makedirs(os.path.dirname(output_filepath)) with open(output_filepath, "w") as file: file.write(str(code_writer)) else: print(code_writer) return 0
def main(): vm_filename = sys.argv[1] asm_filename = vm_filename.replace('.vm', '.asm') vm_file = open(vm_filename, 'r') asm_file = open(asm_filename, 'a') parser = Parser(vm_file) code_writer = CodeWriter(asm_file) while parser.has_more_commands(): parser.advance() if parser.command_type() == C_ARITHMETIC: code_writer.write_arithmetic(parser.arg1()) elif parser.command_type() == C_PUSH: code_writer.write_push_pop(C_PUSH, parser.arg1(), parser.arg2()) elif parser.command_type() == C_POP: code_writer.write_push_pop(C_POP, parser.arg1(), parser.arg2()) vm_file.close() code_writer.close()
def translate(self): for count, f in enumerate(self.files_to_translate): should_bootstrap = True if count == 0 else False code_writer = CodeWriter(f.split('.vm')[0].split('/')[-1]) parser = Parser(f) for line in parser.read_lines(): if should_bootstrap and self.initiate_bootstrap: self.output_string += code_writer.bootstrap( self.contains_sys_vm_file) should_bootstrap = False command_type = parser.command_type(line) arg1 = parser.arg1(line) arg2 = parser.arg2(line) translated_line = code_writer.generate(command_type, arg1, arg2) self.output_string += translated_line self.__write_out()
def main(): file_name = parse_args() file_name_noext, _ = path.splitext(file_name) raw_data = None with open(file_name, "r") as stream: raw_data = stream.readlines() parser = Parser(raw_data) code_writer = CodeWriter() code_writer.set_file_name(file_name_noext.split("/")[-1] + ".asm") while parser.has_more_commands(): parser.advance() if parser.command_type == C_ARITHMETIC: code_writer.writer_arithmetic(parser.operator) elif parser.command_type == C_PUSH: code_writer.write_push_pop(parser.operator, parser.arg1(), parser.arg2()) elif parser.command_type == C_POP: code_writer.write_push_pop(parser.operator, parser.arg1(), parser.arg2()) elif parser.command_type == C_LABEL: pass elif parser.command_type == C_GOTO: pass elif parser.command_type == C_IF: pass elif parser.command_type == C_FUNCTION: pass elif parser.command_type == C_RETURN: pass elif parser.command_type == C_CALL: pass else: pass code_writer.close()
def main(): # If there is an invalid number of arguments the program stops. if len(sys.argv) != 2: print("ERROR: Invalid number of arguments. Expected: file_name.vm ") exit(1) # the VM translator only accepts vm files to be translated into assembly files. elif sys.argv[1][-3:] != ".vm": print("ERROR: Invalid file type. Expected: vm file") exit(1) # Get the name of the file to be parsed from the arguments. input_file = sys.argv[1] # Creates a new parser to parse the file. parser = Parser(input_file) # Creates the code writer with the input file excluding the .vm part code_writer = CodeWriter(input_file[0:-3]) # Reads the whole file. while parser.has_more_commands(): parser.advance() # Gets the command type from the current command. command_type = parser.command_type() # If the command type is C_ARITHMETIC parses it to get the command and passes it to the code writer to add it to the output file if command_type == "C_ARITHMETIC": command = parser.arg1() code_writer.write_arithmetic(command) # If the command type is C_PUSH or C_POP parses it to get the segment and the index and passes it to the code writer to add it to the output file elif command_type == "C_PUSH" or command_type == "C_POP": segment = parser.arg1() index = parser.arg2() code_writer.write_push_pop(command_type, segment, index) del parser code_writer.close()
"pointer": MemorySegType.M_POINTER, "temp": MemorySegType.M_TEMP } if __name__ == "__main__": if len(sys.argv) != 2: print(f"Usage: {sys.argv[0]} <{sys.argv[1]}>") files = [] if sys.argv[1].endswith('.vm'): files.append(sys.argv[1]) elif os.path.isdir(sys.argv[1]): files.extend(glob.glob("*.vm")) cw = CodeWriter(sys.argv[1].strip(".vm") + ".asm") print(f"Creating {sys.argv[1].strip('.vm') + '.asm'} ...") for f in files: p = Parser(f) cw.file_name = f while p.advance(): if p.command_type == CommandType.C_ARITHMETIC: cw.write_arithmetic(p.arg1()) elif p.command_type == CommandType.C_PUSH: cw.write_push_pop(CommandType.C_PUSH, segment_map[p.arg1()], p.arg2()) elif p.command_type == CommandType.C_POP: cw.write_push_pop(CommandType.C_POP, segment_map[p.arg1()], p.arg2())
def main(): '''Main entry point for the script.''' # For each .vm file, create a parser object filetrue = os.path.isfile(sys.argv[1]) dirtrue = os.path.isdir(sys.argv[1]) vmfiles = [] # Rename directory as a ".asm" file for later use finame = os.path.basename(os.path.normpath(sys.argv[1])) + ".asm" # Get file path with .asm file appended dirname = os.path.join(sys.argv[1], finame) # Create list of files to convert and add to asm file if dirtrue: cw = CodeWriter(dirname) fi = os.listdir(sys.argv[1]) for names in fi: if names.endswith(".vm"): vmfiles.append(sys.argv[1] + names) elif filetrue: di = sys.argv[1] if di.endswith(".vm"): vmfiles.append(di) tr = vmfiles[0] trs = tr.replace("vm", "asm") cw = CodeWriter(trs) else: print "invalid filetype: only input .vm files" else: print "usage: 'python <file.vm> or <dirname/>'" out = cw.constructor() cw.writeInit(out) with out as outfile: for files in vmfiles: # Create new instance of class Parser() p = cw.setFileName(files) with p.constructor() as infile: for line in infile: if p.commandType(line) == "comments": pass elif p.commandType(line) == "C_ARITHMETIC": cw.writeArithmetic(outfile, p.args(line)[0]) elif p.commandType(line) == "C_IF": # Handle if-goto command cw.writeIf(outfile, p.args(line)[1]) elif p.commandType(line) == "C_GOTO": # Handle goto command cw.writeGoto(outfile, p.args(line)[1]) elif p.commandType(line) == "C_RETURN": # Return function result cw.writeReturn(outfile) elif p.commandType(line) == "C_LABEL": # Set label address cw.writeLabel(outfile, p.args(line)[1]) elif p.commandType(line) == "C_CALL": # Handle function calls cw.writeCall(outfile, p.args(line)[1], p.args(line)[2]) elif p.commandType(line) == "C_FUNCTION": cw.writeFunction(outfile, p.args(line)[1], p.args(line)[2]) elif p.commandType(line) == "C_PUSH" or "C_POP": cw.writePushPop(outfile, p.commandType(line), p.args(line)[1], p.args(line)[2])
def _set_website_snippet_static_javascript_file(self, module): """ Function to set the module hook file :param module: :return: """ cw = CodeWriter() cw.cur_indent = 4 * cw.default_dent if module.generate_website_snippet_generic_model: lst_model_search = ( module.generate_website_snippet_generic_model.split(";") ) lst_model_id_search = [] for s_model in lst_model_search: model_id = self.env["ir.model"].search( [("model", "=", s_model)] ) if model_id: lst_model_id_search.append(model_id[0]) else: _logger.warning(f"Model not existing : {s_model}") for model_id in lst_model_id_search: for field_id in model_id.field_id: if field_id.name not in MAGIC_FIELDS: cw.emit(f'if (data["{field_id.name}"]) {{') with cw.indent(): with cw.indent(): cw.emit( f'self.$(".{field_id.name}_value").text(data["{field_id.name}"]);' ) cw.emit("}") else: cw.emit("var data_json = data;") cw.emit('var hello = data_json["hello"];') cw.emit(f'self.$(".{module.name}_value").text(hello);') code = cw.render() content = ( f"odoo.define('{module.name}.animation', function (require)" """ { 'use strict'; var sAnimation = require('website.content.snippets.animation'); sAnimation.registry.""" f"{module.name}" """ = sAnimation.Class.extend({ """ f"selector: '.o_{module.name}'," """ start: function () { var self = this; var def = this._rpc({route: '""" f"/{module.name}/helloworld" """'}).then(function (data) { if (data.error) { return; } if (_.isEmpty(data)) { return; } """ + code + """ }); return $.when(this._super.apply(this, arguments), def); } }) }); """ ) file_path = os.path.join( "static", "src", "js", f"website.{module.name}.animation.js" ) self.code_generator_data.write_file_str(file_path, content)
def __init__(self, src: str): self.asm_file, self.vm_files = self._parse_files(src) print("Translate to %s." % self.asm_file) self.code_writer = CodeWriter(self.asm_file)
from os import listdir from parser import Parser from code_writer import CodeWriter # TODO: make this command line arguments FILENAME='StaticsTest' BASE = '/Users/plum/Desktop/codes/nand2tetris/projects/08/FunctionCalls/StaticsTest/' READ_ADDRESS = '{0}'.format(BASE) WRITE_ADDRESS = '{0}{1}.asm'.format(BASE, FILENAME) if __name__ == '__main__': c = CodeWriter(WRITE_ADDRESS) files = [f for f in listdir(READ_ADDRESS) if f.find('.vm') != -1] sys_init = files.index('Sys.vm') rest = [f for f in files if files.index(f) != sys_init] c.write_init() for filename in [files[sys_init]] + rest: # order matters # only parse .vm files if filename.find('.vm') != -1: c.set_filename(filename) p = Parser(BASE + filename) while p.has_more_lines(): p.advance() command = p.command_type() arg_1 = p.arg_1() arg_2 = p.arg_2() if command in ['C_PUSH', 'C_POP']: c.write_push_pop(command, arg_1, arg_2) if command == 'C_ARITHMETIC':
except IndexError: example_usage('improper arguments') if '.vm' in input: if input in os.listdir(): vm_files = [input] else: example_usage('file not found') else: if input in os.getcwd(): vm_files = get_all_VM_files(os.getcwd()) if len(vm_files) == 0: example_usage('no vm files found') else: try: os.chdir(input) vm_files = get_all_VM_files(os.getcwd()) if len(vm_files) == 0: example_usage('no vm files in specified directory') except FileNotFoundError: example_usage('no such directory') # create a CodeWriter instance cw = CodeWriter(vm_files, output, boot) # perform translation cw.translate() # close the output of the CodeWriter cw.close()