Expand description
Basic usage
Run program with interpreter
use cranefack::{parse, optimize_with_config, OptimizeConfig, Interpreter};
// Parse program
let mut program = parse("++[<].")?;
// Optimize with optimization level 2
optimize_with_config(&mut program, &OptimizeConfig::o2());
// Create new interpreter reading from stdin and writing to stdout
let mut interpreter = Interpreter::new(std::io::stdin(), std::io::stdout());
// Execute program
interpreter.execute(&program);
Run program with jit
use cranefack::{parse, optimize_with_config, OptimizeConfig, CompiledJitModule};
// Parse program
let mut program = parse("++[<].")?;
// Create optimization config for level 2
let opt_level = OptimizeConfig::o2();
// Optimize with optimization level 2
optimize_with_config(&mut program, &opt_level);
// Compile program into module
let module = CompiledJitModule::new(&program, &opt_level)?;
// Execute compiled module reading from stdin and writing to stdout
module.execute(std::io::stdin(), std::io::stdout());
Structs
A compiled program that can be executed
Interpreter to execute a program
Configuration to control optimization of the program
An executable program
Enums
Jit compilation error
Error type for parser related errors
Runtime errors for interpreter invocations
WarningType found in a call to analyze
Traits
Trait all internal errors must implement
Functions
Analyze program for possible errors
Compile program into a rust file that can be compiled with rustc
Optimize program with level 2
Optimize program
Parse the input source file into an abstract representation