Skip to content

creativcoder/brainfcuk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brainfcuk

An optimizing brainfuck interpreter written in Rust

This implementation preprocess the source code with following optimizations:

  1. Performs run length encoding (RLE) of the source text. This obviously shows best results when source has more repeated characters, which are folded into constant arithmetic operations.

  2. Eliminates [-] which basically turns into an expression which sets the current cell to zero, replacing it with | symbol, which is handled by the interpreter appropriately.

  3. Precomputes brace indices on the RLE source for close to constant time loop jumps.

The interpreter builds up its own custom IR and evaluates that IR to compute the end results from the cell.

TODO:

  • Add LLVM backend to compile to native code.
  • Optimize code to minimize string allocations.
  • Better Error messages

About

A brainfuck interpreter written in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published