MIRROR
Jump to navigation
Jump to search
MIRROR is a two-dimensional stack-based esoteric programming language made by User:Fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff. It uses a direction pointer similar to Befunge and each direction is given a number (up = -2, down = 4, left = 0, right = 2).
Commands
All commands are one letter long. Numbers must be between 0 and 265536
Command | What it do |
---|---|
/ |
swap up and right, and swap left with down |
\ |
swap up and left, and swap right with down |
0-9 |
push that number onto the stack |
+ |
pop two numbers, a and b, and push a+b
|
- |
pop two numbers, a and b, and push b-a
|
x |
pop two numbers, a and b, and push a*b
|
k |
pop two numbers, a and b, and push b // a , and then push b % a
|
d |
pop a value, and set the direction to that |
q |
push the direction to the stack |
s |
swap top two values of stack |
" |
pop, and print that as a BASE-10,000 number |
& |
pop two numbers, a and b, and push int(str(a)+str(b))
|
f |
reverse the direction pointer |
' |
pop the top value of the stack and print that as a unicode character |
* |
clone the top element of the stack |
y |
skip the next command if the top element of the stack is 0 |
a |
make the top element a positive number |
p |
pop the top element a print it as a number |
@ |
stop the program@
|
$ |
delete the top element of the stack |
^ |
pop two numbers, a and b, and push b * 10000 + a
|
# |
convert the top element from BASE-10,000 number to number |
` |
the opposite of #
|
u |
input as string |
b |
push 231 - 1 |
r |
reverse the stack |
c |
get the letter at position x:b, y:a |
g |
get the sign of the top element of stack |
All other letters are ignored by the compiler
Programs
Hello World
88x*8+'*5+'*6+6+'*6+6+'*6+9+'48x'*23&+'*15&+'*18&+'*12&+'*4+'@
99 bottles of beer
\ \99&q2-y/32&^98&^11&1&^11&6&^10&8&^11&5&^32&^11&1&^10&2&^32&^98&^10&1&^10&1&^11&4&^32&^11&1&^11&0&^32&^11&6&^10&4&^10&1&^32&^11&9&^97&^10&8&^10&8&^44&^p32&^98&^11&1&^11&6&^10&8&^11&5&^32&^11&1&^10&2&^32&^98&^10&1&^10&1&^11&4&^46&^p1-84&^97&^10&7&^10&1&^20&^11&1&^11&0&^10&1&^20&^10&0&^11&1&^11&9&^11&0&^44&^20&^11&2&^97&^11&5&^20&^10&5&^11&6&^20&^97&^72&^11&1&^11&7&^11&0&^10&0&^44&^p*y\@ ;;;;;;;;\;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;/;
Truth Machine
u#y\0p@ \0yf1p1f
A+B Problem
u#u#+p
Interpreter
Python
import sys sys.set_int_max_str_digits(19729) def tryint(text): try: return int(text) except ValueError: return -1 L = [] for _i in range(10000): L.append(chr(_i)) L[0]="" def tryindex(_l,_q): try: return _l.index(_q) except ValueError: return 0 def sign(_n): if _n == 0: return 0 else: return _n // abs(_n) def BASE10K(_n): _c = 0 _o = _nSTR = ('0' * ((4 - (len(str(_n))) % 4))) +str(_n) while _c < len(_nSTR): _o = _o + L[int(_nSTR[int(_c):(int(_c)+4)])] _c = _c + 4 return _o def K10BASE(_n): _o = 0 for _i in _n: _o = tryindex(L,_i) return _o def compute(code): l = code.splitlines() x = 0 y = 0 dir = 2 end = False stack = [] while not(end): if l[y][x] == '/': if dir == 2: dir = -2 elif dir == -2: dir = 2 elif dir == 4: dir = 0 elif dir == 0: dir = 4 if l[y][x] == '\\': if dir == 2: dir = 0 elif dir == 0: dir = 2 elif dir == 4: dir = -2 elif dir == -2: dir = 4 if tryint(l[y][x]) > -1: stack.append(int(l[y][x])) if l[y][x] == '+': stack.append(stack.pop(-2)+stack.pop(-1)) if l[y][x] == '-': stack.append(stack.pop(-2)-stack.pop(-1)) if l[y][x] == 'x': stack.append(stack.pop(-2)*stack.pop(-1)) if l[y][x] == 'k': stack.append(stack[-2] // stack[-1]) stack.append(stack[-2] % stack[-1]) del stack[-1] del stack[-1] if l[y][x] == 'd': dir = stack.pop() if l[y][x] == 'q': stack.append(dir) if l[y][x] == 's': stack.append(stack.pop(-2)) if l[y][x] == 'u': stack.append(K10BASE(input())) if l[y][x] == '"': print(BASE10K(stack.pop()),end=) if l[y][x] == '&': stack.append(tryint(str(stack[-2])+str(stack[-1]))) del stack[-2] del stack[-2] if l[y][x] == 'f': if dir == 2: dir = 0 if dir == 0: dir = 2 if dir == 4: dir = -2 if dir == -2: dir = 4 if l[y][x] == '\: print(chr(stack.pop()),end=) if l[y][x] == '*': stack.append(stack[-1]) if l[y][x] == 'y': if stack.pop() == 0: x = x + (dir % 3) - 1 y = y + (dir // 3) if l[y][x] == 'a': stack[-1] = abs(stack[-1]) if l[y][x] == 'p': print(stack.pop()) if l[y][x] == '@': end = True if l[y][x] == '$': stack.pop() if l[y][x] == '^': stack.append(stack.pop(-2)*10000 + stack.pop()) if l[y][x] == '#': stack.append(tryint(BASE10K(stack.pop()))) if l[y][x] == '`': stack.append(K10BASE(str(stack.pop()))) if l[y][x] == 'b': stack.append((2**31)-1) if l[y][x] == 'r': stack.reverse() if l[y][x] == 'g': stack[-1] = sign(stack[-1]) if l[y][x] == 'c': stack.append(l[stack[-1]][stack[-2]]) del stack[-1] del stack[-1] x = x + (dir % 3) - 1 x = x % (len(l[0])) y = y + (dir // 3) y = y % (len(l)) def start(): Import = input("Import a file?") if Import == "yes": Import = input("Please input file path:\n") Import = open(Import,encoding='utf-8') Import = Import.read() else: c = " " Import = "" while c != "": c = input() Import = Import + c + "\n" compute(Import) start() input()