esolang

UFSA

Universal Finite State Automaton. Write down the states and the moves between them, and the machine runs.

PythonshellDebugwindow, 2020 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

PythonshellDebugwindow made UFSA in 2020 to describe any finite-state automaton. There are no variables, no stack and no arithmetic. A program is a list of moves between states, each move taking one character of input and printing on the way. The only memory is the state the machine is in.

The machine

The first line names the initial state and then the halt states. Each further line is one transition.

TokenMeans
firstThe state the move starts from
secondThe state it goes to
thirdThe input character that triggers it; empty means the end of the input
the restPrinted on the way, with a space between tokens

Tokens are split by single spaces, so two spaces in a row leave the trigger empty. In printed tokens \N with N in octal is that character and \\ is a backslash. The run halts on reaching a halt state and stops with an error when no transition fits.

Example

Hello, World! has one state besides the halt state.

Hello, World! has one state besides the halt state. Its only transition fires at the end of the input, which comes at once, and prints two tokens.

The binary cat copies 0s and 1s and halts when they run out. A 2 has no transition, so the run stops there with an error.

Expected: 0110

The truth machine on 1 moves to state o, which prints 1 at the end of the input and stays where it is, for ever. On 0 it prints 0 and halts.

Expected: 0

The repeating cat has a transition for each character from ! to ~ and from ¡ to ÿ, 188 in all, and halts at the end of the input. It writes its quote as \", which this implementation reads as an escaped quote.

Further

Meta-languages

Write your own in Run Convert a program from UFSA

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run ufsa -e 'i h
i h  Hello, World!'
shib manual ufsa

Source

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

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

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