Print function and readme.md

This commit is contained in:
2025-10-06 12:52:38 +11:00
parent 5188784a11
commit ae37d8deab
5 changed files with 49 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ import string
from sys import argv
file = open(argv[1]).readlines();
bfcode = ""
variables = []
def removeChar(str, char):
ans = ""
for i in str:
@@ -47,9 +48,23 @@ for i in file:
if (j < len(a)):
bfcode += "+" * ord(a[j]) + ">"
bfcode += "<[[<<]<<]<<<<<<<<<"
print(type)
else:
print("what the sigma")
variables.append(i.split(" ")[1].split("*")[0])
elif (i.split(" ")[0] == "print"):
a = i.split(" ", 1)[1]
if a[len(a)-1] == "\n":
a = removeEnd(a, 1)
if (a in variables):
bfcode += ">>>>>>>>>>>>"
for i in range(variables.index(a)):
bfcode += "[>>]>>"
bfcode += "[>.>]<<[[<<]<<]<<<<<<<<++++++++++.[-]"
else:
raise NameError(f"Could not find variable {a}")
elif ((i != "\n") & (i != "")):
raise ValueError(f"Invalid Command")
with open(argv[2], "w") as file:
file.write(bfcode)