eoc

Crates.ioeoc
lib.rseoc
version0.0.3
sourcesrc
created_at2022-02-19 06:41:39.464071
updated_at2022-02-28 10:14:39.684219
descriptionEO-to-binaries experimental compiler
homepagehttps://github.com/yegor256/eoc
repositoryhttps://github.com/yegor256/eoc
max_upload_size
id535054
size74,708
Yegor Bugayenko (yegor256)

documentation

README

EO principles respected here We recommend IntelliJ IDEA

make crates.io PDD status Hits-of-Code Lines of code License

It's an experimental compiler of EO to binaries.

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 terms and then pass them to Emu struct like this:

use eoc::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();
    print!("The result is: {}", emu.cycle());
}

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.

Commit count: 265

cargo fmt