Here's a revised version of the python interpreter.
Code:
I'm probably going to publish this to codeberg, so I can regularly update it, and because it is not blocked by my school.
Code:
# predefining things
rcs = " ABCDEFGHIJKLMNOPQRSTUVWXYZ.,?:"
cursor = 0
memory = 0
accumulator = 0
flag = False
# starting up
print("RADISH interpreter V1.1")
p = input("Program:")
labels = {}
for i, ch in enumerate(p):
if ch.isdigit() and ch != "0":
labels[int(ch)] = i
while cursor < len(p): # checks if cursor position is further than the program
sub = p[cursor] # stores part of program to be evaluated
if sub.isdigit() and sub != "0":
cursor += 1
continue
if sub == "z":
if not flag:
cursor = labels.get(accumulator, cursor)
continue
if sub == "n":
if flag:
cursor = labels.get(accumulator, cursor)
continue
if sub == "j":
cursor = labels.get(accumulator, cursor)
continue
if sub == "r":
memory = 0
if sub == "a":
accumulator += 1
if sub == "d":
memory -= 1
if sub == "i":
memory += 1
if sub == "s":
memory *= accumulator
accumulator = 0
if sub == "c":
accumulator = memory
if sub == "f":
if flag >= memory:
memory += 1
if sub == "/":
previous = memory # temporary variable
memory = accumulator
accumulator = previous
del previous
if sub == "<":
if accumulator <= memory:
flag = True
else:
flag = False
if sub == ">":
if accumulator >= memory:
flag = True
else:
flag = False
if sub == "0":
accumulator = 0
if sub == "h":
print(rcs[memory % len(rcs)], end="")
cursor += 1
I'm probably going to publish this to codeberg, so I can regularly update it, and because it is not blocked by my school.




