Example #1
0
    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()