2 unstable releases
0.2.0 | Sep 19, 2022 |
---|---|
0.1.0 | May 6, 2022 |
#1726 in Command line utilities
80KB
1.5K
SLoC
It's an experimental emulator of a processor that understands π-calculus expressions, which is the formalism behind EO programming language.
To build it, install Rust and then:
$ cargo build --release
If everything goes well, an executable binary will be in target/release/fibonacci
:
$ target/release/fibonacci 7 40
This will calculate the 7th Fibonacci number 40 times. Don't try to play with much larger numbers, this binary code is very slow. It's just an experiment.
To compile your own program instead of this primitive recursive Fibonacci calculator, you have to
convert EO code into π-calculus expressions and then pass them to Emu
struct like this:
use phie::emu::Emu;
pub fn main() {
let emu: Emu = "
Ξ½0 β¦ β¦ π β¦ Ξ½3 β§
Ξ½1 β¦ β¦ Ξ β¦ 0x002A β§
Ξ½2 β¦ β¦ Ξ» β¦ int-add, Ο β¦ π.πΌ0, πΌ0 β¦ π.πΌ1 β§
Ξ½3 β¦ β¦ π β¦ Ξ½2(ΞΎ), πΌ0 β¦ Ξ½1, πΌ1 β¦ Ξ½1 β§
Ξ½5 β¦ β¦ π β¦ Ξ½3(ΞΎ) β§
".parse().unwrap();
let dtz = emu.dataize();
print!("The result is: {}", dtz.0);
}
This code is equivalent to the following EO code:
[] > foo
42 > x
x.add x > @
But in a more "functional" way:
[] > foo
42 > x
int-add > @
x
x
More tests are in src/emu.rs
file.
Run and fix Clippy lints issues before committing changes:
- Install Rustup. If Rustup was already installed, update to ensure have the latest Rustup and compiler.
$ rustup update
- Install Clippy.
$ rustup component add clippy
- Run Clippy.
$ cargo clippy
- Automatically applying Clippy suggestions (Not all issues will be fixed automatically. Also, Clippy has some bugs with false-positive cases for some lints, so better to check automaticall fixes as well).
$ cargo clippy --fix
Dependencies
~5β15MB
~170K SLoC