2D-Reversable

From Esolang
Jump to navigation Jump to search

2D-Reversable is an esoteric programming language created by User:Dulph on April 1st, 2026. It is inspired by Reversable, with the main difference being that the script is written in 2D, instead of a single line. As such, all Reversable programs can be run in 2D-Reversable. It was used as a base for 2D-Reversable 2.

Syntax

Programs can be single lined or multilined. A single-line program that only uses Reversable commands can be compiled into reversable. When running, a program will run as Reversable until it reaches a 2D-Reversable command. The program read direction always starts at RIGHT.

Example :

GET-SX 	DOWN 	NOP 	NOP 	NOP
OUT-SX 	RIGHT 	SKIP 	NOP 	REVERSE

This program runs as such :

  • GET-SX : Asks the user to input a string and stores the first character into variable SX
  • DOWN : Changes the read direction to DOWN.
  • RIGHT : Changes the read direction to RIGHT.
  • SKIP : Skips the next instruction (the NOP)
  • REVERSE : Since the current read direction is RIGHT, sets the read direction to LEFT.
  • NOP : Since it's a NOP, it's ignored
  • SKIP : Skips next instrucion (the RIGHT)
  • OUT-SX : Outputs the content of SX

Commands

Program ends itself upon attempting to reach an out of bound instruction. Commands are separated with a single space. During execution, any tabs are ignored

Instruction Desc
NOP Does nothing
SKIP Skips next instruction
REVERSE Reverses the read direction
REVERSE<IA Reverses the read direction if IA > 0 (IA being of type integer)
REVERSE<SA Reverses the read direction if SA is not an empty string (SA being of type empty string)
GET-PX Asks for input and stores it in var PX as P type
OUT-PX Prints the value of var PX
IA+IB Sets IA to IA + IB
IA-IB Sets IA to IA - IB
IA*IB Sets IA to IA * IB
IA%IB Sets IA to the remainder of IA divided by IB
UP Changes the read direction to read up
DOWN Changes the read direction to read down
RIGHT Changes the read direction to read right
LEFT Changes the read direction to read left

Variable types

Only 2 variable types are supported by 2D-Reversable :

  • Integers, named with prefix I
  • Characters, named with prefix S

Examples

Cat

Cat in default Reversable (that can be ran in 2D-Reversable) :

 SKIP REVERSE GET-SA SKIP OUT-SA REVERSE<SA

Cat in 2D-Reversable :

DOWN 	LEFT
GET-SA 	UP 	NOP 	NOP 		LEFT
RIGHT 	SKIP 	DOWN 	REVERSE<SA 	UP

(equivalent to :)

DOWN 	LEFT 	NOP 	NOP 		NOP
GET-SA 	UP 	NOP 	NOP 		LEFT
RIGHT 	SKIP 	DOWN 	REVERSE<SA 	UP

Implementations