ll
lalrpop-lambda
cargo install lalrpop-lambda
ll

lalrpop-lambda

A λ-calculus grammar/interpretor written using LALRPOP and `λ!`.

by Nathan Lilienthal

0.6.1 (see all)License:MIT
cargo install lalrpop-lambda
Readme

λ-calculus Parser (using LALRPOP)

Build Status Crates.io Version docs.rs

Write lambda calculus with ease, and evaluate it. There are a number of ways to use this library (each interchangeable with another):

  • Expression AST variants Abs, App, and Var

  • Macros abs!/λ!, app!/γ!, and var!

    let id = λ!{x.x};
    let one = λ!{f.λ!{x.γ!(f,x)}};
    assert_eq!(1u64, u64::from(app!({id},{one})));
    
  • Parsed λ-calculus strings

    let parser = ExpressionParser::new();
    parser.parse(r"\a b.a");
    parser.parse(r"\f x.(f (f x))");
    parser.parse(r"\\\x y z");
    
  • Native types: u64, bool, fn (WIP)

    assert_eq!(λ!{f.λ!{x.γ!(f,γ!(f,x))}}, Expression::from(2u64));
    assert_eq!(true, bool::from(λ!{a.λ!{b.a}}));
    assert_eq!(1, λ!{x.x}(1));
    

The above is generated with wasm-pack, see example/site.

Usage (Rust)

[dependencies]
lalrpop_lambda = "*"

Read the Rust documentation for more information.

Usage (WASM/JS)

An Exp structure is provided through WASM for use in JS. This allows cross platform, client-side, web based interfaces to be built for the λ-calculus.

Read the WASM documentation for more information.

Development

This assumes you have an updated and working copy of [rustup][rustup].

cargo +nightly [build | test | bench | doc | run --example <>]
WASM

First make sure you have wasm-pack installed. Then:

wasm-pack build

GitHub Stars

74

LAST COMMIT

2yrs ago

MAINTAINERS

1

CONTRIBUTORS

2

OPEN ISSUES

4

OPEN PRs

0
VersionTagPublished
0.6.1
3yrs ago
0.5.0
3yrs ago
0.4.1
3yrs ago
0.4.0
3yrs ago
No alternatives found
No tutorials found
Add a tutorial