esolang

SPL

Brainfuck with one more register, and loops that only look at it.

StelK, 2005 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello World

The idea

StelK made SPL around December 2005, as a hobby. It keeps brainfuck's tape and its moves, but its loops do not test the current cell. They test an accumulator, which ^ loads from the cell. So brainfuck's [...] becomes ^[...^], which also makes SPL Turing complete.

Read the story

The accumulator does arithmetic too. The specification's table says . and , work on bytes, but its countdown and 99 bottles print numbers, so this implementation has them write and read numbers. Text goes out as string literals between double quotes.

The machine

CommandDoes
> <Move the pointer
+ -Add or take 1 from the current cell
. ,Print the cell as a number; read a number into it
^ $Load the cell into the accumulator; read a number into it
[ ]Skip past ] if the accumulator is 0; go back to [ unless it is 0
a s m d %Add, subtract, multiply, divide or take the remainder of the cell by the accumulator
"text"Print the text, line breaks included
#text#A comment
&Halt

Everything else does nothing. Cells hold whole numbers of any size, and the end of input reads as 0.

Example

The countdown from the specification reads a number into the cell, then prints and lowers it until the…
Expected: 49

The countdown from the specification reads a number into the cell, then prints and lowers it until the accumulator reads 0.

Expected: n: 5 4 3 2 1

The truth machine prints its input once on 0 and forever on 1.

Expected: 0

The 99 bottles of beer program counts a cell down from 97 and prints two more than it on each round. The last two verses are spelled out in one string.

Patterns it teaches

  • Turing tarpit: brainfuck, with the loop test moved to a second register.

Further

SPL builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from SPL

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run spl -e ',.^[.]' --input '0'
shib manual spl

Source

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

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

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