Reflecto
Jump to navigation
Jump to search
Reflecto is an esoteric 2d stack-based programming language inspired Befunge and Fish made by User:QuantumV. Each instruction is a single symbol on a text file that performs operations like reflecting the instruction pointer, manipulating stack values, and basic arithmetic.
The program counter is always moving, starting out moving to the right from the top left corner and the direction being able to be altered by instructions.
Sample Programs
Hello, World!
98*d@91+3*1-+d@7+d@d@3+@92+4*d@93+-@92+8*1-@92+91+*1+d@3+d@6-d@8-@92+3*@E
Disan count
.0!/1-d0<!Ed\ \/!=0%2 / !\52*@\ / / d 0# \/
Truth Machine
.d#d0=!E0!/d\ \#/
XKCD Random Number
4#E chosen by fair dice roll. guaranteed to be random.
Fibonacci sequence
100d#25*@!/ drs+ \ \@*25#d/
Factorial
.0!/d1- \ /\!>0d/ \!/* \ E#d\!>1b/
Cat Program (String)
,0\E/! \ \!\d@/
Cat Program (Number)
.#E
Print "BEER"
\ ____ |____| \ \ | | | | / 9\ | 2 | | + | | 6 | | * | | d | | E@ | | @3 | |/+4+ /+ | |\9@@dd/ | __________
Instructions
Mirrors (/,\,_,|) The most important part of the language, mirrors the instruction pointer like you think a mirror would (Moving right into a / mirror? You get launched up. Moving right into a | mirror? You bounce off off it!)
0-9 Push a number onto the stack (e.g., 5 pushes 5). $ Pop the top value from the stack and discard it. d Duplicate the top value on the stack. s Swap the top two values on the stack. r Reverse stack. b Push stack size onto the stack ~ Pop the top value and push it back as a negative.
+ Pop the top two values, add them, and push the result. - Pop the top two values, subtract the second from the first, and push the result. * Pop the top two values, multiply them, and push the result. : Pop the top two values, divide the first by the second, and push the result. % Pop the top two values, compute the modulo, and push the result. = Pop the top two values, push 1 if they are equal, otherwise push 0. > Pop the top two values, push 1 if the first is greater, otherwise push 0. < Pop the top two values, push 1 if the first is smaller, otherwise push 0.
@ Pop the top value and output it as a character (e.g., ASCII). # Pop the top value and output it as a number. , Read a character from input and push its ASCII value onto the stack. . Read a number from input and push it onto the stack.
! Pop the top value; if it’s 0, skip the next command.
E End program execution.
Interpreters
The official interpreter written by User:QuantumV: https://github.com/QuantumV2/Reflecto