esolang

rEsKrIb!lo

String rewriting for a medieval computer, built from a loop of punched tape and 48 relays.

2014 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: current rule: GOOD----MORNING- current state: GOODYEAR current rule: GOOD----MORNING- current state: RMORNING current rule: GOOD----MORNING- current state: GRMORNIN current rule: GOOD----MORNING- current state: NGRMORNI current rule: GOOD----MORNING- current state: INGRMORN current rule: GOOD----MORNING- current state: NINGRMOR current rule: GOOD----MORNING- current state: RNINGRMO current rule: GOOD----MORNING- current state: ORNINGRM Turn 0 State MORNINGR

The idea

The specification imagines rewriting machines that could have been built in the 16th century, from punched tape or from two memory drums. In the simplest one a closed loop of tape 96 bits wide turns past 96 reading heads. Six bits make a character, so each row of the tape is a rule of 16 characters, a pattern of 8 and a replacement of 8. The 48 relays hold the state, 8 characters. When the pattern matches the relays, the replacement is written over them. A - in the pattern matches anything, and a - in the replacement leaves that character as it was.

Read the story

The shifted machine tries every rule at all 8 rotations of the state, so GOOD matches wherever it sits. The specification gives a C program for this machine, and this implementation follows it.

The machine

The source is the rule file, read up to its first q. Every 16 characters before the q are a rule.

The C program takes the state from its command line. The first line of the input is the state, and the rest of the input is what the program reads from the keyboard. A turn tries every rule at each rotation. Each try prints the rule and the state, waits for a key, writes the replacement if the pattern matched and rotates the state one place to the right. At the end of the turn the program reads one more key and prints the state, and a q there stops it.

Example

The specification says the rule GOOD----MORNING- turns GOODYEAR into MORNINGR, because the last - leaves…

The specification says the rule GOOD----MORNING- turns GOODYEAR into MORNINGR, because the last - leaves the R. The keys 12345678 answer the 8 rotations and q stops the machine.

The test program, on the input it suggests. The pattern --GOOD-- only matches at the third rotation, where GOOD has moved two places right, and GOODYEAR becomes THISYEAR.

Expected: current rule: --GOOD----THIS-- current state: GOODYEAR current rule: --GOOD----THIS-- current state: RGOODYEA current rule: --GOOD----THIS-- current state: ARGOODYE current rule: --GOOD----THIS-- current state: EARTHISY current rule: --GOOD----THIS-- current state: YEARTHIS current rule: --GOOD----THIS-- current state: SYEARTHI current rule: --GOOD----THIS-- current state: ISYEARTH current rule: --GOOD----THIS-- current state: HISYEART Turn 0 State THISYEAR

The C program never stops on its own. When the input runs out it goes on turning, and it only stops if the byte its last rotation moved happens to be a q. So a run ends at its step limit unless the keys end a turn with q.

Patterns it teaches

  • String rewriting: one pattern and one replacement per row of tape, with a wildcard.

Further

String-rewriting paradigm

Write your own in Run Convert a program from rEsKrIb!lo

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: reskrib-lo.

Command line

shib run reskrib-lo -e '--GOOD----THIS--q' --input 'GOODYEAR
12345678q'
shib manual reskrib-lo

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/reskrib-lo.js

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

Source esolangs.org (CC0) · Edit on esolangs.org