Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/objectionary/phie
Experimental Emulator of a Machine that Understands π-calculus
https://github.com/objectionary/phie
compiler eolang rust
Last synced: 4 days ago
JSON representation
Experimental Emulator of a Machine that Understands π-calculus
- Host: GitHub
- URL: https://github.com/objectionary/phie
- Owner: objectionary
- Created: 2022-01-13T03:10:51.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T17:20:08.000Z (23 days ago)
- Last Synced: 2024-10-26T01:07:47.310Z (22 days ago)
- Topics: compiler, eolang, rust
- Language: Rust
- Homepage: https://www.eolang.org
- Size: 344 KB
- Stars: 9
- Watchers: 3
- Forks: 4
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)[![cargo](https://github.com/objectionary/phie/actions/workflows/cargo.yml/badge.svg)](https://github.com/objectionary/phie/actions/workflows/cargo.yml)
[![crates.io](https://img.shields.io/crates/v/phie.svg)](https://crates.io/crates/phie)
[![PDD status](http://www.0pdd.com/svg?name=objectionary/phie)](http://www.0pdd.com/p?name=objectionary/phie)
[![codecov](https://codecov.io/gh/objectionary/phie/branch/master/graph/badge.svg)](https://codecov.io/gh/objectionary/phie)
[![Hits-of-Code](https://hitsofcode.com/github/objectionary/phie)](https://hitsofcode.com/view/github/objectionary/phie)
![Lines of code](https://img.shields.io/tokei/lines/github/objectionary/phie)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/objectionary/phie/blob/master/LICENSE.txt)It's an experimental emulator of a machine that understands
[π-calculus](https://arxiv.org/abs/2111.13384) expressions,
which is the formalism behind [EO](https://www.eolang.org) programming language.To build it, install [Rust](https://www.rust-lang.org/tools/install) and then:
```bash
$ cargo build --release
```If everything goes well, an executable binary will be in `target/release/fibonacci`:
```bash
$ 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:```rust
use phie::emu::Emu;
pub fn main() {
let mut emu: Emu = "
Ξ½0(π) β¦ β¦ π β¦ Ξ½3(π) β§
Ξ½1(π) β¦ β¦ Ξ β¦ 0x002A β§
Ξ½2(π) β¦ β¦ Ξ» β¦ int-add, Ο β¦ π.πΌ0, πΌ0 β¦ π.πΌ1 β§
Ξ½3(π) β¦ β¦ π β¦ Ξ½2(ΞΎ), πΌ0 β¦ Ξ½1(π), πΌ1 β¦ Ξ½1(π) β§
".parse().unwrap();
let dtz = emu.dataize();
print!("The result is: {}", dtz.0);
}
```This code is equivalent to the following EO code:
```text
[] > foo
42 > x
x.add x > @
```But in a more "functional" way:
```text
[] > foo
42 > x
int-add > @
x
x
```More tests are in `src/emu.rs` file.
## How to Contribute
First, install [Rust](https://www.rust-lang.org/tools/install) and then:
```bash
$ cargo test -vv --release
```If everything goes well, an executable binary will be in `target/release/phie`:
```bash
$ target/release/phie --help
```Then, fork repository, make changes, send us a [pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).
We will review your changes and apply them to the `master` branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run `cargo test` again. Also,
run `cargo fmt` and `cargo clippy`.