Crates.io | fck |
lib.rs | fck |
version | 0.1.2 |
source | src |
created_at | 2024-11-24 22:06:09.871913 |
updated_at | 2024-12-07 01:26:25.830987 |
description | A simple Brainfuck parser, lexer and interpreter. |
homepage | |
repository | |
max_upload_size | |
id | 1459650 |
size | 28,807 |
Fck is a simple Brainfuck lexer, parser, and interpreter. It includes a library crate that exports most of the functionality, and an executable that provides a CLI for lexing, parsing, and executing Brainfuck programs.
To see a list of all commands, use:
fck --help
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)?;
}