Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: brainfuck interpreter #5

Merged
merged 30 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
630129e
feat: add brainfuck interpreter for M31
zmalatrax Oct 31, 2024
b0e372a
feat: add brainfuck programs
zmalatrax Oct 31, 2024
855e303
chore: add credits
zmalatrax Oct 31, 2024
b6db6db
chore: add fmt and clippy scripts
zmalatrax Oct 31, 2024
8eec8f3
chore: fmt
zmalatrax Oct 31, 2024
40ab20b
test: add compiler unit test
zmalatrax Oct 31, 2024
e8f468b
refactor: only use from_u8 for instruction type
zmalatrax Oct 31, 2024
a64eefb
test: add instruction unit tests
zmalatrax Oct 31, 2024
f3d710e
test: add registers unit tests
zmalatrax Oct 31, 2024
d65c58f
refactor: fix cli print display
zmalatrax Oct 31, 2024
1475f5e
refactor: make the machine input and output generic
zmalatrax Nov 4, 2024
17a6bd1
test: add machine unit tests
zmalatrax Nov 4, 2024
76ef3a4
test: verify trace correctness
zmalatrax Nov 4, 2024
68bd21c
feat: add trace padding to next power of two
zmalatrax Nov 4, 2024
7f99625
fix: execute program with a single instruction
zmalatrax Nov 4, 2024
ceb14c6
refactor: make brainfuck-vm a library and refactor binary
zmalatrax Nov 4, 2024
a3b8a95
test: add integration tests
zmalatrax Nov 4, 2024
3447153
chore: impl default TestWriter
zmalatrax Nov 4, 2024
48b9981
ci: add github actions
zmalatrax Nov 4, 2024
40f7519
ci: add trunk config to repo
zmalatrax Nov 4, 2024
328f45f
chore: shorten CI action name
zmalatrax Nov 5, 2024
cb4d9d1
feat: add configurable ram size
zmalatrax Nov 5, 2024
cec5be4
ci: add rustfmt and clippy to trunk
zmalatrax Nov 5, 2024
30a7827
chore: update trunk check action checkout to v4
zmalatrax Nov 5, 2024
5de1680
ci: remove clippy and rust_fmt as done by Trunk
zmalatrax Nov 5, 2024
13913fa
refactor: enforce snake_case on crate name and binaries
zmalatrax Nov 5, 2024
469193b
feat: add tracing to workspace
zmalatrax Nov 6, 2024
33092c9
refactor: use tracing with RUST_LOG instead of raw print
zmalatrax Nov 6, 2024
31fcdac
refactor: replace print-trace flag by trace and pad-trace
zmalatrax Nov 6, 2024
e40fb90
refactor: replace unwrap or panic! by expect
zmalatrax Nov 6, 2024
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
74 changes: 74 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on:
pull_request:
branches:
- "*"

permissions:
deployments: read
contents: read
pull-requests: write

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2024-01-04
- uses: Swatinem/rust-cache@v2
- run: scripts/rust_fmt.sh --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: nightly-2024-01-04
- uses: Swatinem/rust-cache@v2
- run: scripts/clippy.sh
zmalatrax marked this conversation as resolved.
Show resolved Hide resolved

machete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bnjbvr/cargo-machete@main
ClementWalter marked this conversation as resolved.
Show resolved Hide resolved

run-brainfuck-vm-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test --lib

run-brainfuck-vm-integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test --test '*'

all-tests:
runs-on: ubuntu-latest
needs:
- clippy
- format
- machete
- run-brainfuck-vm-unit-tests
- run-brainfuck-vm-integration-tests

steps:
- uses: re-actors/[email protected]
with:
jobs: ${{ toJSON(needs) }}
22 changes: 22 additions & 0 deletions .github/workflows/trunk-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Trunk
on: [pull_request]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions: read-all

jobs:
trunk_check:
name: Trunk Code Quality Runner
runs-on: ubuntu-latest
permissions:
checks: write # For trunk to post annotations
contents: read # For repo checkout

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Trunk Code Quality
uses: trunk-io/trunk-action@v1
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
4 changes: 4 additions & 0 deletions .trunk/configs/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See: https://rust-lang.github.io/rustfmt
normalize_comments = true
use_field_init_shorthand = true
edition = "2021"
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
31 changes: 31 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.7
plugins:
sources:
- id: trunk
ref: v1.6.4
uri: https://github.com/trunk-io/plugins
actions:
disabled:
- trunk-announce
- trunk-check-pre-push
enabled:
- trunk-fmt-pre-commit
- trunk-upgrade-available
lint:
enabled:
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
zmalatrax marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading