esolang

ABCstr

One string that starts as abc. Each line looks for a piece of it, and a piece that is missing is a jump.

ChuckEsoteric08 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello, World!

The idea

ChuckEsoteric08 made ABCstr after Novice. The only memory is a string, and it starts as abc. Every line names a piece of that string. If the piece is there, the line replaces it. If it is not, the line jumps to a label with the same name. So the search is also the only test and the only branch.

Read the story

The specification says ABCstr is the only one of ChuckEsoteric08's string rewriting languages that reads input.

The machine

LineDoes
x=yReplace the first x with y; if there is no x, jump to the label x
x-yThe same, and print x when it is there
:xThe same, with a line of input in place of y
xA label, which does nothing

The operator is the first = or - after the first character, so -=- looks for - and puts - back. The program ends after its last line.

Example

The first line turns abc into Hello, World!bc.

The first line turns abc into Hello, World!bc. The last line finds Hello, World!, prints it and puts a back.

A loop needs a jump that always happens. The line !=! looks for !, which is never in the string, and so it jumps back to the label !. When the three x are gone, x- jumps to the label x on the last line.

Expected: xxx

The specification proves ABCstr Turing complete with a 35 line interpreter for cyclic tag. It reads a program and then the data, a line each, and prints every data bit it deletes after a g. With the program ; and the data 10 it prints g1g0. One of its labels is written ;e where its jump looks for e;, so in this implementation a program with a 0 or a 1 in it stops at that jump with an error.

Patterns it teaches

Further

String-rewriting paradigm

Write your own in Run Convert a program from ABCstr

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run abcstr -e 'a=Hello, World!
a
Hello, World!-a'
shib manual abcstr

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/abcstr.js

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

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