Update main.py

This commit is contained in:
Mateusz779 2022-04-03 19:01:40 +02:00
parent 6fb1cfb2c8
commit e939761d6b

13
main.py
View File

@ -1,7 +1,6 @@
""" """
@author: Mateusz779 @author: Mateusz779
""" """
import re
pointer = 0 pointer = 0
cell = [] cell = []
code = "" code = ""
@ -15,23 +14,11 @@ def main():
global code, cell, pointer global code, cell, pointer
code = input("Enter the code: ") code = input("Enter the code: ")
print("\n\n") print("\n\n")
code=codeClear(code)
if code != "": if code != "":
for i in range(len(code)): for i in range(len(code)):
interpreter(code[i], i) interpreter(code[i], i)
print("\n\n") print("\n\n")
def codeClear(input):
"""
Clears the code from unnecessary characters
"""
pattern = "[\][\[\,\.\>\<\-\+]"
tmp=re.findall(pattern, input)
result=""
for i in range(len(tmp)):
result+=tmp[i]
return result
def interpreter(znak, i): def interpreter(znak, i):
""" """
Brainfuck interpreter Brainfuck interpreter