Crates.io | phie |
lib.rs | phie |
version | 0.2.0 |
source | src |
created_at | 2022-05-06 13:50:30.618945 |
updated_at | 2022-09-19 18:37:54.48235 |
description | Experimental emulator of a processor that understands π-calculus expressions |
homepage | https://github.com/objectionary/phie |
repository | https://github.com/objectionary/phie |
max_upload_size | |
id | 581700 |
size | 99,142 |
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:
$ rustup update
$ rustup component add clippy
$ cargo clippy
$ cargo clippy --fix