Compact AssembleiInterpreter.py

This commit is contained in:
Matt07734 2020-04-27 15:16:53 -07:00 committed by GitHub
parent 738a2f8a7c
commit 3e87235965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 121 deletions

View File

@ -1,126 +1,29 @@
fte = input("What file to execute?> ")
a="0"
b="0"
c="0"
d="0"
e="0"
f="0"
g="0"
h="0"
cell=""
def lts(s):
str1 = ""
for ele in s:
str1 += ele
return str1
def Forward():
if cell == "":
return "a"
if cell == "a":
return "b"
if cell == "b":
return "c"
if cell == "c":
return "d"
if cell == "d":
return "e"
if cell == "e":
return "f"
if cell == "f":
return "g"
if cell == "g":
return "h"
if cell == "h":
return ""
def GetCell():
if cell == "":
return "nocell"
if cell == "a":
return "a"
if cell == "b":
return "b"
if cell == "c":
return "c"
if cell == "d":
return "d"
if cell == "e":
return "e"
if cell == "f":
return "f"
if cell == "g":
return "g"
if cell == "h":
return "h"
def Backward():
if cell == "":
return "h"
if cell == "a":
return ""
if cell == "b":
return "a"
if cell == "c":
return "b"
if cell == "d":
return "c"
if cell == "e":
return "d"
if cell == "f":
return "e"
if cell == "g":
return "f"
if cell == "h":
return "g"
with open(fte, 'r') as fte2:
for row in fte2:
a, b, c, d, e, f, g, h = '00000000'
cell = ''
with open(input('What file to execute?> '), 'r') as F:
for row in F:
for x in str(row):
if x == "!":
cell = Forward()
if x == "?":
cell = Backward()
if x == "#":
x2 = str(a + b + c + d + e + f + g + h)
x3 = lts(x2)
print(x3)
if x == '!':
if cell == '': cell = 'a'
elif 'a' <= cell <= 'g': cell = chr(ord(cell) + 1)
elif cell == 'h': cell = ''
if x == '?':
if cell == '': cell = 'h'
elif cell == 'a': cell = ''
elif 'b' <= cell <= 'h': cell = chr(ord(cell) - 1)
if x == '#':
print(a + b + c + d + e + f + g + h)
if x == "+":
if cell == "a":
if a == "0":
a = "1"
if cell == "b":
if b == "0":
b = "1"
if cell == "c":
if c == "0":
c = "1"
if cell == "d":
if d == "0":
d = "1"
if cell == "e":
if e == "0":
e = "1"
if cell == "f":
if f == "0":
f = "1"
if cell == "g":
if g == "0":
g = "1"
if cell == "h":
if h == "0":
h = "1"
if cell == 'a' and a == '0': a = '1'
elif cell == 'b' and b == '0': b = '1'
elif cell == 'c' and c == '0': c = '1'
elif cell == 'd' and d == '0': d = '1'
elif cell == 'e' and e == '0': e = '1'
elif cell == 'f' and f == '0': f = '1'
elif cell == 'g' and g == '0': g = '1'
elif cell == 'h' and h == '0': h = '1'
if x == ".":
print(cell)
if x == ",":
a = "0"
b = "0"
c = "0"
d = "0"
e = "0"
f = "0"
g = "0"
h = "0"
cell = ""
a, b, c, d, e, f, g, h = '00000000'
cell = ''