Expand description
§FCK
A simple Brainfuck lexer, parser, and interpreter.
§Examples
Using run
and run_file
.
use fck::{run, run_file};
fn main() -> fck::Result<()> {
run("+++++++++.[->+<]")?;
run_file("path/to/file")?;
}
Using the individual modules.
use fck::lexer::lex;
use fck::parser::parse;
use fck::interpreter::Interpreter;
fn main() -> fck::Result<()> {
let tokens = lex("source code")?;
let ast = parse(&tokens)?;
let mut interpreter = Interpreter::new();
interpreter.run(&ast)?;
}
Re-exports§
Modules§
- error
- Contains data structures for error handling in a Brainfuck program.
- interpreter
- Contains structs and functions for interpreting and running a Brainfuck AST.
- lexer
- Contains utilities for lexing a string of brainfuck source code into a vector of tokens.
- parser
- Contains utilities for parsing a string of Brainfuck tokens into an Abstract Syntax Tree (AST).