Ring-around-the-Rosie

From Esolang
Jump to navigation Jump to search

Designed by User:Salpynx so that all source code is represented by a ring surrounding a single unbounded register; a wikipedia:Wheel graph Wn, which is always embeddable in a 2D plane. Inspired by Wire-crossing_problem, Minsky machines, and User:Salpynx/Braneflage.

It is designed to be Turing complete and show that control flow and memory access can be arbitrarily simplified when diagrammed if the mechanics of the language compensate. The control flow "sequential" ring allows for arbitrary addressing with skips, and the "single" register simulates any finite number of prime encoded registers, including one to store the current active node address.

Syntax

The first three columns of a source file represent the 'ring'. * characters are the nodes, and R is the central (unbounded) register.

Nodes are labelled clockwise, with the node closest to the register designated 1. For the purposes of simplifying the source representation: R must be on the same row as exactly one node. R cannot occur on the first or last lines since these represent edges of the ring. R can only occur in the second column, inside the ring.

Non-register lines can contain more than one node (2 on the opposite sides of the ring, or up to 3 on the top and bottom edges). They will share the same code body, but their trigger ids will differ.

Symbols after the first three columns represent the node commands. Nodes can be empty, but executing an empty node will cause the program to enter an infinite loop.

Node Commands

  • :digits: ([1-9][0-9]*) : If R Mod :digits: is not equal to zero, execute the following super and/or subscripts, otherwise proceed to the next :digits:
  • :superscript: (([1-9][0-9]*([0-9]+)))+ : Multiply R by :superscript: (a series of concatenated exponents)
  • :subscript: (([1-9][0-9]*([0-9]+)))+ : Divide R by :subscript: (a series of concatenated exponents)
  • i  : read one byte of input and multiply R by 2**(byte value)
  • 0  : set R to 0 (i.e. Halt condition)
  • .  : output characters following . to EOL (no newline). This is done regardless of other commands at the node, even if there is a halt.
  • :  : output characters following : to EOL + a newline. This is done regardless of other commands at the node, even if there is a halt.

Program execution

  • The register is initialised to 2.
  • The instruction pointer proceeds around the ring in order.
  • If R/2**n results in an odd integer (where n is the current node number), the commands at the current node are executed, otherwise the pointer moves to the next node.
  • If R is zero, execution halts.

Examples

Hello World

*

 R* 0:Hello, World!

 *