libbf

Brainfuck-like language library.

This library can define a variant of Brainfuck-like language parser and can run parsed program.

Examples

Use predefined Brainfuck interpreter

`bf' feature flag is needed to compile this example.

```rust use libbf::{predefined::bf, runtime}; use std::io;

fn main() { let source = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."; let program = bf::parser() .parse_str(source) .expect("Failed to parse"); runtime::run(&program, io::stdin(), io::stdout()).expect("Failed to run"); } ```

Define Brainfuck interpreter

```rust use libbf::{parser::Parser, runtime, token::simple::SimpleTokenSpec}; use std::io;

fn main() { // Create parser with token specification. let parser = Parser::new( SimpleTokenSpec { // You can specify tokens with ToString (char, &str, String, etc.) ptrinc: '>', // char ptrdec: "<", // &str datainc: "+".tostring(), // String datadec: '-', output: '.', input: ',', loophead: '[', looptail: ']', } .totokenizer(), );

let source = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
let program = parser.parse_str(source).expect("Failed to parse");
runtime::run(&program, io::stdin(), io::stdout()).expect("Failed to run");

} ```

Feature flags