esolang

Lines

/// with input. A \| is not a bar but the next character you type.

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

Tested with 4 known programs · Test method

Run it

Expected: a

The idea

Lines is /// with one exception. A /// program prints its plain characters and rewrites the rest of itself with /pattern/replacement/. In Lines the escape \| reads one character from the input at the moment the interpreter reaches it, and that character takes its place.

Read the story

In plain text, the character is printed. Inside a substitution it becomes part of the pattern or the replacement, and the substitution copies it through the rest of the program. Every /// program without a | runs the same in Lines.

The machine

The program is a string, read from the left.

Next charactersDoes
\|Read a character and use it here
\cThe character c, never a command
/pattern/replacement/Replace pattern in the rest of the program, again and again until it is gone
any other characterPrint it

The specification gives an interpreter in Java, and this implementation follows it. Each search starts again from the left, so a replacement that contains its own pattern never ends. The program stops when it runs out.

Example

The three programs from the specification.

The three programs from the specification. The first prints one character of the input.

Expected: xx
Expected: a

The second reads x while it reads the replacement of /~/\|/, so the rest of the program, ~~, becomes xx. The third turns the rest into /q// and the character it read. That substitution removes a q and leaves anything else, so on q it prints nothing. On ~ both freeze, because /~/~/ replaces ~ with itself forever.

One read can fill many places.

Expected: o-o-o

Patterns it teaches

Further

String-rewriting paradigm

Self-modifying

Write your own in Run Convert a program from Lines

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run lines -e '\|' --input 'a'
shib manual lines

Source

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

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

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