Skip to content

nixpulvis/lalrpop-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

λ-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
cd examples/site
npm run serve

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published