import string from sys import argv file = open(argv[1]).readlines(); bfcode = "" def removeChar(str, char): ans = 0 for i in str: if (i != char): ans += i return ans def removeEnd(string, num): ans = "" for i in range(len(string)-1): ans += string[i] return ans def ord2(char): if (len(char) == 1): return ord(char) elif (len(char == 0)): return(0) for i in file: if (i.split(" ")[0] == "create"): i = removeEnd(i, 2) bfcode += ">>>>>>>>>>>>[[>>]>>]" bytes = int(i.split("*", 1)[1].split("=", 1)[0]) a = i.split("=", 1)[1] if (a[0] == " "): a = a.split(" ", 1)[1] # Get type if ((a[0] == "\"") & (a[len(a)-1] == "\"")): type = "string" else: type = "undefined" if (type == "string"): a = a.split("\"", 1)[1] a = removeEnd(a, 1) for j in range(bytes): bfcode += "+++>" if (j < len(a)): bfcode += "+" * ord(a[j]) + ">" bfcode += "<[[<<]<<]<<<<<<<<<" print(type) else: print("what the sigma") with open(argv[2], "w") as file: file.write(bfcode)