Esempio n. 1
0
	#Strips .vm of the end and adds .asm
	temp_out=re.search('(.*)(\.vm)',in_file)
	out_file+=temp_out.group(1)+'.asm'

#------------------------------------------------------------------------------
# Main
#------------------------------------------------------------------------------

#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()