Skip to content
/ bfcc Public

Brainfuck interpreter, transpiler and debugger written in Rust

Notifications You must be signed in to change notification settings

valtyr/bfcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bfcc

A Brainfuck interpreter, transpiler and inspector written in Rust

Usage

Installation

You can install the newest published version of the binary by running:

cargo install bfcc

Commands

  • bfcc transpile - a Brainfuck to C optimizing transpiler
  • bfcc run - a Brainfuck interpreter
  • bfcc spy - a runtime inspector and soon to be debugger

Optimization

During transpilation the AST gets converted into an intermediary representation that gets optimized in multiple passes.

Although I haven't tested these optimizations enough to provide any sort of guarantee, these optimizations all seem to generate functionally equivalent programs.

Implementation status

Strategy File
Fusing increment/decrement commands fuse_add.rs
Fusing movements fuse_movements.rs
Deferring movements defer_movements.rs
Unrolling zero/clear loops unroll_zero_loops.rs
Unrolling copy loops
Unrolling multiplication loops

All transforms can be found under src/transpiler/transforms

References

These websites have served as great references during development:

Todo

  • Start implementing optimizations
  • Implement breakpoints, single stepping and register peeking in debugger
  • Add a command that generates LLVM IR, and compiles to a binary

🧠 🦀



# 𝖆𝖉𝖉𝖊𝖓𝖉𝖚𝖒

+ By the way yes I've seen bfc (https://bfc.wilfred.me.uk),
+ and it's totally amazing

- but I didn't see it until after I had written most of this project
- and picked a name on crates.io

@@ Sue me @@

! 😓

About

Brainfuck interpreter, transpiler and debugger written in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published