Print function and readme.md
This commit is contained in:
21
src/main.py
21
src/main.py
@@ -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)
|
||||
Reference in New Issue
Block a user