esolang

xeraph

The source code is the data. A 2D program walks its own grid and edits it as it goes.

Conor O'Brien · Turing complete: with unbounded memory · ●●○ moderate

Tested with 4 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

Conor O'Brien made xeraph so that memory and program are one grid. The instruction pointer moves over the grid like in Befunge. A second pointer, the memory pointer, walks the same cells in reading order, so every cell is both a command and a number. Adding one to a cell that holds + turns it into ,.

Read the story

Comparisons go through a head register, which starts as ~. Two branches turn the instruction pointer by comparing the cell with the head, and ? skips one command when they differ.

The machine

CodeDoes
+ -Cell plus one, minus one
l rMemory pointer left, right, wrapping over the whole grid
a s * / %Cell plus, minus, times, divided by, modulo the head
0…9 n ; :Head becomes the digit, -1, the cell, the next grid cell
hCell becomes the head
. #Print the cell as a byte, as a number
, @Read a byte (-1 at the end), read an integer
^ v < >Go up, down, left, right
\| _Down or up, left or right: the first when the cell equals the head
! ?Skip the next command, skip it when the cell differs from the head
$Stop

Cells are 32-bit integers. The grid is a torus, padded with spaces to its longest line. The reference is xeraph.c in github.com/ConorOBrien-Foxx/xeraph.

Example

The first line runs over and over.
Expected: 59
Expected: 31

The first line runs over and over. l steps the memory pointer back through the reversed text on the second line, and . prints each letter. When it reaches ~, the cell equals the head, ? does not skip, and $ stops. The second program writes 5 into its own second cell, then turns its fourth cell, #, into 3 and multiplies it to 9.

Patterns it teaches

The grid has a fixed size and cells are bounded, so it is a finite machine.

The grid has a fixed size and cells are bounded, so it is a finite machine.

Further

Also in Spatial (2D and up)

Write your own in Run Convert a program from xeraph

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: xeraph.

Command line

shib run xeraph -e ',.$' --input 'Q'
shib manual xeraph

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/xeraph.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language