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!

One-time binary cat

c e
c c 0 0
c c 1 1
c e

Repeating cat program

The following repeating cat program recognizes the ASCII characters whose codes span the range [33, 255]. It ceases if either no character or a space has been entered.

origin end
origin end
origin origin ! !
origin origin \" \"
origin origin # #
origin origin $ $
origin origin % %
origin origin & &
origin origin ' '
origin origin ( (
origin origin ) )
origin origin * *
origin origin + +
origin origin , ,
origin origin - -
origin origin . .
origin origin / /
origin origin 0 0
origin origin 1 1
origin origin 2 2
origin origin 3 3
origin origin 4 4
origin origin 5 5
origin origin 6 6
origin origin 7 7
origin origin 8 8
origin origin 9 9
origin origin : :
origin origin ; ;
origin origin < <
origin origin = =
origin origin > >
origin origin ? ?
origin origin @ @
origin origin A A
origin origin B B
origin origin C C
origin origin D D
origin origin E E
origin origin F F
origin origin G G
origin origin H H
origin origin I I
origin origin J J
origin origin K K
origin origin L L
origin origin M M
origin origin N N
origin origin O O
origin origin P P
origin origin Q Q
origin origin R R
origin origin S S
origin origin T T
origin origin U U
origin origin V V
origin origin W W
origin origin X X
origin origin Y Y
origin origin Z Z
origin origin [ [
origin origin \ \\
origin origin ] ]
origin origin ^ ^
origin origin _ _
origin origin ` `
origin origin a a
origin origin b b
origin origin c c
origin origin d d
origin origin e e
origin origin f f
origin origin g g
origin origin h h
origin origin i i
origin origin j j
origin origin k k
origin origin l l
origin origin m m
origin origin n n
origin origin o o
origin origin p p
origin origin q q
origin origin r r
origin origin s s
origin origin t t
origin origin u u
origin origin v v
origin origin w w
origin origin x x
origin origin y y
origin origin z z
origin origin { {
origin origin | |
origin origin } }
origin origin ~ ~
origin origin ¡ ¡
origin origin ¢ ¢
origin origin £ £
origin origin ¤ ¤
origin origin ¥ ¥
origin origin ¦ ¦
origin origin § §
origin origin ¨ ¨
origin origin © ©
origin origin ª ª
origin origin « «
origin origin ¬ ¬
origin origin ® ®
origin origin ¯ ¯
origin origin ° °
origin origin ± ±
origin origin ² ²
origin origin ³ ³
origin origin ´ ´
origin origin µ µ
origin origin ¶ ¶
origin origin · ·
origin origin ¸ ¸
origin origin ¹ ¹
origin origin º º
origin origin » »
origin origin ¼ ¼
origin origin ½ ½
origin origin ¾ ¾
origin origin ¿ ¿
origin origin À À
origin origin Á Á
origin origin  Â
origin origin à Ã
origin origin Ä Ä
origin origin Å Å
origin origin Æ Æ
origin origin Ç Ç
origin origin È È
origin origin É É
origin origin Ê Ê
origin origin Ë Ë
origin origin Ì Ì
origin origin Í Í
origin origin Î Î
origin origin Ï Ï
origin origin Ð Ð
origin origin Ñ Ñ
origin origin Ò Ò
origin origin Ó Ó
origin origin Ô Ô
origin origin Õ Õ
origin origin Ö Ö
origin origin × ×
origin origin Ø Ø
origin origin Ù Ù
origin origin Ú Ú
origin origin Û Û
origin origin Ü Ü
origin origin Ý Ý
origin origin Þ Þ
origin origin ß ß
origin origin à à
origin origin á á
origin origin â â
origin origin ã ã
origin origin ä ä
origin origin å å
origin origin æ æ
origin origin ç ç
origin origin è è
origin origin é é
origin origin ê ê
origin origin ë ë
origin origin ì ì
origin origin í í
origin origin î î
origin origin ï ï
origin origin ð ð
origin origin ñ ñ
origin origin ò ò
origin origin ó ó
origin origin ô ô
origin origin õ õ
origin origin ö ö
origin origin ÷ ÷
origin origin ø ø
origin origin ù ù
origin origin ú ú
origin origin û û
origin origin ü ü
origin origin ý ý
origin origin þ þ
origin origin ÿ ÿ

Truth-machine

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

Description of PlusOrMinus

See UFSA/PlusOrMinus.

Interpreter

  • Common Lisp implementation of the UFSA programming language.