| Crates.io | tur |
| lib.rs | tur |
| version | 0.1.0 |
| created_at | 2025-08-10 14:55:02.774946+00 |
| updated_at | 2025-08-10 16:23:20.881232+00 |
| description | Turing Machine Language - Parser, interpreter, and execution engine |
| homepage | https://github.com/rezigned/tur |
| repository | https://github.com/rezigned/tur |
| max_upload_size | |
| id | 1788981 |
| size | 154,550 |
Tur is a domain-specific language for defining and executing Turing machines, complete with parser, interpreter, and multi-platform visualization tools.
Tur (.tur files) provides a clean, readable syntax for defining both single-tape and multi-tape Turing machines. The language includes:
name: Binary Counter
tape: 1, 0, 1, 1
rules:
start:
0 -> 0, R, start
1 -> 1, R, start
_ -> _, L, inc # Reached end, go back to start incrementing
inc:
0 -> 1, S, done # 0 becomes 1, no carry needed
1 -> 0, L, inc # 1 becomes 0, carry to next position
_ -> 1, S, done # Reached beginning with carry, add new 1
done:
name: Copy Tape
tapes:
[a, b, c]
[_, _, _]
rules:
copy:
[a, _] -> [a, a], [R, R], copy
[b, _] -> [b, b], [R, R], copy
[c, _] -> [c, c], [R, R], copy
[_, _] -> [_, _], [S, S], done
done:
Every .tur program consists of:
name: Program Name
# Single-tape configuration
tape: symbol1, symbol2, symbol3
head: 0 # optional, defaults to 0
# OR multi-tape configuration
tapes:
[tape1_symbol1, tape1_symbol2]
[tape2_symbol1, tape2_symbol2]
heads: [0, 0] # optional, defaults to [0, 0, ...]
# Optional blank symbol (defaults to ' ')
blank: ' '
# Transition rules
rules:
state_a:
input -> output, direction, next_state
# ... more transitions
state_b:
# ... transitions
[!NOTE] The first state defined in the
rules:section is automatically considered the start state. In the examples above,startis the initial state because it appears first.
Single-tape format:
current_symbol -> write_symbol, direction, next_state
Multi-tape format:
[sym1, sym2, sym3] -> [write1, write2, write3], [dir1, dir2, dir3], next_state
L or < - Move leftR or > - Move rightS or - - Stay (no movement)# This is a comment
state:
a -> b, R, next # Inline comment
"_") is a special symbol used to represent a blank character.# Run a program
cargo run --package tur-cli -- examples/binary-addition.tur
# Interactive TUI with program selection
cargo run --package tur-tui
examples/ directory for sample .tur programs