EmojiStack

From Esolang
Jump to navigation Jump to search

Mojifunge is a programming language invented by User:LEOMOK It is stack-based and uses emojis as commands. All values on the stack are arbitrary-precision integers. All characters except the 553 emojis in the codepage are ignored.

Commands

   Literals
   ๐Ÿ˜€ - Push 0.
   0๏ธโƒฃ1๏ธโƒฃ2๏ธโƒฃ3๏ธโƒฃ4๏ธโƒฃ5๏ธโƒฃ6๏ธโƒฃ7๏ธโƒฃ8๏ธโƒฃ9๏ธโƒฃ - Multiply by 10 and add corresponding digit.
   ๐Ÿ”ก - Push the next emoji's value in the codepage.
   ๐Ÿ”ค - Push the values of everything between it and the next ๐Ÿ”ค.
   Operators
   โž• - Pop a, b, push a+b.
   โž– - Pop a, b, push b-a.
   โœ–๏ธ - Pop a, b, push a*b.
   โž— - Pop a, b, push b/a (integer division).
   ๐Ÿšฎ - Pop a, b, push b%a.
   ๐Ÿ”ผ - Pop a, b, push a**b. Negative exponents are truncated to 0.
   โ›” - Pop a, push -a.
   โญ• - Pop a, b, push b&a.
   ๐Ÿ’ข - Pop a, b, push b|a.
   โŒ - Pop a, b, push b^a.
   โฃ๏ธ - Pop a, push ~a.
   โช - Pop a, b, push a<<b.
   โฉ - Pop a, b, push a>>b.
   ๐Ÿ™ - Pop a, b, push a==b (true is -1, false is 0).
   โ—€๏ธ - Pop a, b, push b<a.
   โ–ถ๏ธ - Pop a, b, push b>a.
   Stack manipulation
   ๐Ÿ’• - Duplicate.
   ๐Ÿ’” - Drop.
   ๐Ÿ’ž - Swap.
   ๐Ÿ’˜ - Rot.
   ๐Ÿ’‘ - Over.
   ๐Ÿ‘ˆ - Move to previous stack.
   ๐Ÿ‘‰ - Move to next stack.
   ๐Ÿ˜ - Reverse the stack.
   ๐Ÿ˜Ž - Push length of stack.
   Control flow
   ๐Ÿค›๐Ÿคœ - Codeblock. Used for if-statements and loops. (No codeblocks needed for single instructions)
   โ†ช๏ธ - Pop a, if a != 0 then (codeblock)
   โคต๏ธ - Else condition in if statements. Use โคต๏ธโ†ช๏ธ for else if.
   ๐Ÿ” - While loop. At the end of each iteration, pop a. If a == 0, end the loop immediately.
   โŽ - Break out of loop.
   โ†ฉ๏ธ - Loop continue.
   ๐Ÿ’ฉ - End program execution.
   Functions
   Anything not mentioned - If followed by a codeblock, define a function. Else, run that function. 
   They will be run in a seperate "function stack", and the โ”โ“โ•โ— commands will input/output to the current stack, not the standard I/O)
   I/O
   โ” - Input a line, parse into arithmetic expression with +, -, *, /, %, **, &, |, ^, << and >> then push result. Error if the line cannot be parsed.
   โ“ - Input a character, push Unicode value.
   โ• - Print top of stack, followed by a space.
   โ— - Print top of stack as Unicode character.

Examples

Hello World:

   ๐Ÿ”คโคต๏ธ๐Ÿฆ๐Ÿป๐Ÿป๐Ÿš“๐Ÿ˜๐Ÿณ๐Ÿš“๐Ÿš™๐Ÿป๐Ÿ’ฏ0๏ธโƒฃ๐Ÿ”ค๐Ÿ˜
   ๐Ÿ”๐Ÿค›
   โ—
   ๐Ÿคœ
   ๐Ÿ’ฉ