esolang

Finite-state mach... wait, WHAT!?

Brainfuck with a fixed number of cells, so a finite-state machine. Until it writes a bigger program and runs that.

Hakerh400, 2020 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: cat

The idea

Hakerh400 made FSMWW in 2020. A program says up front how many cells it gets, so on its own it is a finite-state machine. But its first character decides what happens to the output. After ; the output is printed. After : the output is run as the next FSMWW program, which can ask for as many cells as it likes. A small machine can write a bigger one. The specification lists its computational class as unknown.

The machine

A program is : or ;, a decimal number N and then brainfuck. The brainfuck runs on N cells of 8 bits that wrap, with the pointer at cell 0, and moving it to -1 or N is an error. Reading past the end of the input gives 0. Nothing is printed until the brainfuck halts. Then a ; program prints what it wrote, and a : program becomes what it wrote, with the input going on where it was.

Example

A cat program.

A cat program. One cell is enough, as the end of the input reads as 0 and ends the loop.

The second cat starts with :. On its one cell it walks up to ;, down to 1 and ,, then on to [, ., , and ], so it writes the first cat and runs it.

Expected: hello

The Hello, World!, again on a single cell that climbs and falls from letter to letter.

Expected: Hello, World!

Patterns it teaches

  • Code as data: the output of one stage is the source of the next.
  • Turing tarpit: brainfuck's eight commands and a promise about memory.

Further

Finite-state mach... wait, WHAT!? builds on Brainfuck.

Brainfuck derivatives

Write your own in Run Convert a program from Finite-state mach... wait, WHAT!?

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: finite-state-mach-wait-what.

Command line

shib run finite-state-mach-wait-what -e ';1,[.,]' --input 'cat'
shib manual finite-state-mach-wait-what

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/finite-state-mach-wait-what.js

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

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