Deadfish "self-interpreter"

From Esolang
Jump to navigation Jump to search

Deadfish "self-interpreter" is a small Deadfish extension that supports interpreting Deadfish. (People might think that the : command interprets Deadfish, but it is really just an if statement. Do you consider if statements self-interpreting?)


Accumulator b is equivalent to Deadfish's accumulator, whereas accumulator a is an ASCII-based accumulator.

Command Description
a input accumulator a
i increment accumulator b
d decrement accumulator b
s square accumulator b
o output accumulator b
j jump back to the start of the program
:x conditional statement. It checks the character x against the accumulator a. Conditionally run the ASCII value inside accumulator a as a command if they are equal.

Example programs

Deadfish interpreter


Simple Python Interpreter

acc = 0
input_acc = 0

source = input("Program: ")

def run(program):
    global acc, input_acc
    ip = 0

    while ip < len(program):
        if acc == 256 or acc < 0:
            acc = 0

        if program[ip] == "j":
            ip = 0

        elif program[ip] == "i":
            acc += 1

        elif program[ip] == "d":
            acc -= 1

        elif program[ip] == "s":
            acc *= acc

        elif program[ip] == "o":

        elif program[ip] == ":":
            if ord(program[ip + 1]) == input_acc:
            ip += 2

        elif program[ip] == "a":
            try: input_acc = ord(input(">"))
            except: continue

        ip += 1


See also