User:Jan jelo/a quine in python that contains a underload interpreter

From Esolang
Jump to navigation Jump to search

This is a Quine program in python by User:Jan jelo.

It contains a Underload interpreter.

def run(p):
    stack=[]
    program=p
    while program:
        x,program=program[0],program[1:]
        if x=='*':b,a=stack.pop(),stack.pop();stack.append(a+b)
        if x=='^':program=stack.pop()+program
        if x=='~':a,b=stack.pop(),stack.pop();stack.append(a);stack.append(b)
        if x==':':stack.append(stack[-1])
        if x=='!':stack.pop()
        if x=='a':stack.append(f'({stack.pop()})')
        if x=='S':print(stack.pop(),end='')
        if x=='(':#)
            i=1;tmp=''
            while True:
                x,program=program[0],program[1:]
                if x=='(':i+=1
                if x==')':i-=1
                if i==0:break
                tmp+=x
            stack.append(tmp)
program=r'''(a(def run(p):
    stack=[]
    program=p
    while program:
        x,program=program[0],program[1:]
        if x=='*':b,a=stack.pop(),stack.pop();stack.append(a+b)
        if x=='^':program=stack.pop()+program
        if x=='~':a,b=stack.pop(),stack.pop();stack.append(a);stack.append(b)
        if x==':':stack.append(stack[-1])
        if x=='!':stack.pop()
        if x=='a':stack.append(f'({stack.pop()})')
        if x=='S':print(stack.pop(),end='')
        if x=='(':#)
            i=1;tmp=''
            while True:
                x,program=program[0],program[1:]
                if x=='(':i+=1
                if x==')':i-=1
                if i==0:break
                tmp+=x
            stack.append(tmp)
program=r'')(')*a~:(a)~(('')('
run(program))****S)****^)a(def run(p):
    stack=[]
    program=p
    while program:
        x,program=program[0],program[1:]
        if x=='*':b,a=stack.pop(),stack.pop();stack.append(a+b)
        if x=='^':program=stack.pop()+program
        if x=='~':a,b=stack.pop(),stack.pop();stack.append(a);stack.append(b)
        if x==':':stack.append(stack[-1])
        if x=='!':stack.pop()
        if x=='a':stack.append(f'({stack.pop()})')
        if x=='S':print(stack.pop(),end='')
        if x=='(':#)
            i=1;tmp=''
            while True:
                x,program=program[0],program[1:]
                if x=='(':i+=1
                if x==')':i-=1
                if i==0:break
                tmp+=x
            stack.append(tmp)
program=r'')(')*a~:(a)~(('')('
run(program))****S)****^'''
run(program)