Example #1
0
#------------------------------------------------------------------------------
# Main:
#------------------------------------------------------------------------------

if fullCompiler: #if option was ommited meaning full compilation
	if is_dir: #if it is a directory compile all '*.jack' files
		for d in directory:
			#strips '.jack' off the end and adds '.vm'
			temp_out = re.search('(.*)(\.jack)',d)
			out_file = temp_out.group(1)+'.vm'

			#prints out what file it is compiling at the moment
			print("Compiling: "+d+"....")

			compiler = CompilationEngine(d,out_file)
			compiler.compileClass()

	else: #if not a directory
		compiler = CompilationEngine(in_file,out_file)
		compiler.compileClass()

else: #option for tokenized output selected
	if is_dir: #if it is a directory
		for d in directory:
			#Strips '.jack' off the end and adds '2.xml'
			temp_out = re.search('(.*)(\.jack)',d)
			out_file = temp_out.group(1)+'2.xml'

			compilerxml = CompilationEngineXML(d,out_file)
			compilerxml.compileClass()