Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #! /usr/bin/python
  2. import sys, os
  3. outfile, bf, tc, outname = open("out.c","w"), open(sys.argv[1],"r").read(), 1, "a.out" if len(sys.argv)<3 else sys.argv[2]
  4. outfile.write("#include <stdio.h>\nvoid main(){\n\tchar array[30000];\n char *ptr = array;\n\tint i = 0;\n\tfor(i=0;i<30000;i++)\n\t\tarray[i]=0;")
  5. for char in list(bf):
  6.     if char in list("+-<>.,[]"): outfile.write("\n"+tc*"\t"+{"+":"++*ptr;", "-":"--*ptr;", "<":"--ptr;", ">":"++ptr;", ".":"putchar(*ptr);", ",":"*ptr = getchar()", "[":"while(*ptr){","]":"}"}[char])
  7.     if char in list("]["): tc= tc+1 if char=="[" else tc-1
  8. outfile.write("\n}")
  9. outfile.close()
  10. os.system("gcc out.c -o "+outname)