#For directories passed in if is_dir: cur_dir = os.getcwd() temp_dir = re.search('([\/"\\"]{1})([A-Za-z0-9\.\_\-\s]*$)',cur_dir) fileName = temp_dir.group(2)+'.asm' #opens the file named after the directory with .asm appended writer = CodeWriter(cur_dir+'/'+fileName) writer.writeInit() for d in directory: #Strips .vm of the end to get the file name temp_out=re.search('(.*[\.\/]+)(.*)(\.vm)',d) out_file = temp_out.group(2) #sets current file name writer.setFileName(out_file) #opens the input file par = Parser(d) #while not eof while par.hasMoreCommands(): par.advance() cType = par.commandType() if arith_type in cType: writer.writeArithmetic(par.arg_1()) elif push_type in cType: if len(par.arg_2()) == 0: writer.writePushPop(cType,'constant',par.arg_1()) else: