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§
- Compiled
JitModule - A compiled program that can be executed
- Interpreter
- Interpreter to execute a program
- Optimize
Config - Configuration to control optimization of the program
- Program
- An executable program
- Warning
- Warning found in a call to analyze
Enums§
- Compiler
Error - Jit compilation error
- Parser
Error - Error type for parser related errors
- Runtime
Error - Runtime errors for interpreter invocations
- Warning
Type - WarningType found in a call to analyze
Traits§
- Crane
Fack Error - Trait all internal errors must implement
Functions§
- analyze
- Analyze program for possible errors
- compile_
to_ rust - Compile program into a rust file that can be compiled with rustc
- optimize
- Optimize program with level 2
- optimize_
with_ config - Optimize program
- parse
- Parse the input source file into an abstract representation