Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: rezigned
buy_me_a_coffee: rezigned
Binary file modified .github/tur-logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/tur-logo.free
Binary file not shown.
Binary file modified .github/tur-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# See https://book.leptos.dev/deployment/csr.html#github-pages
name: Release to Github Pages

on:
push:
branches: [main]
paths:
- 'platforms/web/**'
- '.github/workflows/github-pages.yml'
workflow_dispatch:

permissions:
contents: write # for committing to gh-pages branch.
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

env:
WASM_PATH: ./platforms/web

jobs:
Github-Pages-Release:
defaults:
run:
working-directory: ${{ env.WASM_PATH }}

timeout-minutes: 10

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4 # repo checkout

# Install Rust Nightly Toolchain, with Clippy & Rustfmt
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly

- name: Add WASM target
run: rustup target add wasm32-unknown-unknown

- name: Download and install Trunk binary
run: wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.21.14/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-

- name: Build with Trunk
# The behavior of the --public-url argument has changed: it no longer includes a leading '/'.
# We have to specify it explicitly. See https://github.com/trunk-rs/trunk/issues/668
run: ./trunk build --release --public-url "/${GITHUB_REPOSITORY#*/}"

# Deploy with Github Static Pages
- name: Setup Pages
uses: actions/configure-pages@v5
with:
enablement: true
# token:

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist dir
path: "${{ env.WASM_PATH }}/dist"

- name: Deploy to GitHub Pages 🚀
id: deployment
uses: actions/deploy-pages@v4
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Tur - Turing Machine Language

[![Crates.io](https://img.shields.io/crates/v/tur.svg)](https://crates.io/crates/tur) [![Docs.rs](https://docs.rs/tur/badge.svg)](https://docs.rs/tur) [![CI](https://github.com/rezigned/tur/actions/workflows/ci.yml/badge.svg)](https://github.com/rezigned/tur/actions/workflows/ci.yml)

<p align="center">
<img src=".github/tur-logo.png" width="400" />
</p>

**Tur** is a domain-specific language for defining and executing Turing machines, complete with parser, interpreter, and multi-platform visualization tools.
**Tur** is a language for defining and executing Turing machines, complete with parser, interpreter, and multi-platform visualization tools.

## Language Overview

Expand Down
205 changes: 0 additions & 205 deletions examples/README.md

Large diffs are not rendered by default.

37 changes: 22 additions & 15 deletions examples/multi-tape-addition.tur
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
name: Multi-Tape Addition
heads: [0, 0, 0]
name: Multi-Tape Addition (LSB)
tapes:
[1, 0, 1]
[1, 1, 0]
[-, -, -]
[1, 1]
[1, 0]
[_, _]
rules:
start:
[1, 1, -] -> [1, 1, 0], [R, R, R], carry
[1, 0, -] -> [1, 0, 1], [R, R, R], start
[0, 1, -] -> [0, 1, 1], [R, R, R], start
[0, 0, -] -> [0, 0, 0], [R, R, R], start
[-, -, -] -> [-, -, -], [S, S, S], halt
[1, 1, _] -> [1, 1, 0], [R, R, R], carry # 1+1=0 with carry
[1, 0, _] -> [1, 0, 1], [R, R, R], start # 1+0=1 no carry
[0, 1, _] -> [0, 1, 1], [R, R, R], start # 0+1=1 no carry
[0, 0, _] -> [0, 0, 0], [R, R, R], start # 0+0=0 no carry
[1, _, _] -> [1, _, 1], [R, R, R], start # 1+blank=1
[_, 1, _] -> [_, 1, 1], [R, R, R], start # blank+1=1
[0, _, _] -> [0, _, 0], [R, R, R], start # 0+blank=0
[_, 0, _] -> [_, 0, 0], [R, R, R], start # blank+0=0
[_, _, _] -> [_, _, _], [S, S, S], halt # All done
carry:
[1, 1, -] -> [1, 1, 1], [R, R, R], carry
[1, 0, -] -> [1, 0, 0], [R, R, R], carry
[0, 1, -] -> [0, 1, 0], [R, R, R], carry
[0, 0, -] -> [0, 0, 1], [R, R, R], start
[-, -, -] -> [-, -, 1], [S, S, S], halt
[1, 1, _] -> [1, 1, 1], [R, R, R], carry # 1+1+carry=1 with carry
[1, 0, _] -> [1, 0, 0], [R, R, R], carry # 1+0+carry=0 with carry
[0, 1, _] -> [0, 1, 0], [R, R, R], carry # 0+1+carry=0 with carry
[0, 0, _] -> [0, 0, 1], [R, R, R], start # 0+0+carry=1 no carry
[1, _, _] -> [1, _, 0], [R, R, R], carry # 1+blank+carry=0 with carry
[_, 1, _] -> [_, 1, 0], [R, R, R], carry # blank+1+carry=0 with carry
[0, _, _] -> [0, _, 1], [R, R, R], start # 0+blank+carry=1 no carry
[_, 0, _] -> [_, 0, 1], [R, R, R], start # blank+0+carry=1 no carry
[_, _, _] -> [_, _, 1], [S, S, S], halt # Just carry remaining
halt:
8 changes: 7 additions & 1 deletion platforms/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ struct Cli {
fn main() {
let cli = Cli::parse();

let program = ProgramLoader::load_program(Path::new(&cli.program)).unwrap();
let program = match ProgramLoader::load_program(Path::new(&cli.program)) {
Ok(p) => p,
Err(e) => {
eprintln!("Error loading program: {}", e);
std::process::exit(1);
}
};
let mut machine = TuringMachine::new(&program);

for (i, input_str) in cli.input.iter().enumerate() {
Expand Down
Loading