#brainfuck #nom #interpreter #parser

bin+lib brainfuck_rs

Brainfuck parser and interpreter using nom

8 releases (4 stable)

2.0.0 Feb 5, 2019
1.1.1 Apr 27, 2017
1.1.0 Mar 20, 2017
1.0.0 Feb 7, 2017
0.1.0 Dec 1, 2016

#2023 in Parser implementations

MIT license

17KB
402 lines

brainfuck.rs

Build Status Coverage Status

Implementation of a brainfuck parser and interpreter written in rust using nom

Interpreter example

cargo run --bin bf examples/bottles.bf

Parser example

extern crate brainfuck;

use brainfuck::context::Context;
use brainfuck::parser;

fn main() {
    let hello_world = include_bytes!("hello_world.bf");
    let mut ctx     = Context::new();
    let block       = parser::parse(hello_world).expect("Failed parsing input file");
    ctx.run(&block);
}

You can run cargo run --example hello_world to try this

Dependencies

~1.5MB
~23K SLoC