UFSA

From Esolang
Jump to navigation Jump to search

UFSA (Universal Finite State Automaton) is an esolang by User:PythonshellDebugwindow. It can be used to describe any finite-state automaton.

Syntax

The first line has a list of space-separated tokens. The first of these tokens is the initial state, and the rest of these tokens are the halt (accept) states. The program's state is then set to the initial state. If the state is ever a halt/accept state, then the machine will halt successfully, but if there is ever no available transition out of a state with the given input, then the program will raise an error and halt.

The rest of the lines are a series of state transitions. Each of these transitions is made up of three tokens: the original state, the transition state, and the trigger symbol. A transition will transition to the transition state iff the current state is the original state and the current character of the input is the trigger symbol (the program is supplied with an input string at the beginning). If the trigger symbol is empty, that transition will run if the input has been exhausted. Optionally, there can be more tokens, which will all be output during the state transition (here, \N for base-8 N represents an ASCII escape code and \\ represents a single backslash).

Examples

Hello, World!

i h
i h  Hello, World!

Truth-machine

i z
i z 0 0
i o 1 1
o o  1

Description of PlusOrMinus

See UFSA/PlusOrMinus.