Mang

From Esolang
Jump to navigation Jump to search

Mang is an esoteric language created by wolfmitchell for no reason at all. The language uses Lua to parse it, as data is stored as Lua tables. The instructions are numbers in tables, and the tables instructions are stored in are nested.

Instruction set

Copy-pasted directly from the interpreter's source:

 00 - next cell, basically a blank space.
 01 - previous cell
 02 - add to cell
 03 - subtract from cell
 04 - increment program counter
 05 - decrement program counter
 06 - if cell = 0 then go up
 07 - if cell = 0 then go down
 08 - if cell = 0 then go left
 09 - if cell = 0 then go right
 10 - exit program
 11 - print value in current cell
 12 - do nothing
 13 - debugger
 14 - if cell != 0 then go up
 15 - if cell != 0 then go down
 16 - if cell != 0 then go left
 17 - if cell != 0 then go right
 18 - if cell = 0 then go to beginning of next line
 19 - if cell != 0 then go to beginning of next line
 20 - if cell = 0 then go to beginning of next line at col 2
 21 - if cell != 0 then go to beginning of next line at col 2

Hello world

Generated by a generator I wrote, source at http://wolfmitchell.com/p/EU4rdeUlZR

return {
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,11,18,20,17,03,16,09,18},
{09,02,02,02,02,02,02,02,02,02,02,11},
}

Explanation

This is generated, so it follows a static format. The chunks of 02s set the value of the current cell to the ASCII value of the desired character. 11 prints the character.

The 18,20,17,03,16,09,18 code at the end of every line sets the value of the current cell to 0, then jumps to the next line. How it does it:

  • 18 - Just in case the cell is already 0, jump to the next line immediately.
  • 20 - This is where it is because when the program counter exits the loop going right-to-left, it will hit this, making it go to the next line. It has to start at column 2 so when it goes right again, it hits 09 making it go left.
  • 17 - If the cell still has a value other than 0, go right.
  • 03 - Subtract 1 from the cell.
  • 16 - If the cell has a value other than 0, go left.
  • 09 - Make sure we are going left, just in case.
  • 18 - Jump to next line.

Interpreter download

How to use

  1. Write your code to a file.
  2. Make sure Lua is installed.
  3. lua mang-interpreter.lua <file code is in>