λ-calculus Parser (using LALRPOP)
Write lambda calculus with ease, and evaluate it. There are a number of ways to use this library (each interchangeable with another):
Expression
AST variantsAbs
,App
, andVar
- Macros
abs!
/λ!
,app!
/γ!
, andvar!
- Parsed λ-calculus strings
λx.x (\a.\b.a)
- Native types:
u64
,bool
,fn
(WIP)
let id = λ!;
let one = λ!;
println!;
assert_eq!;
Usage (JS)
import.;
Usage (Rust)
use ExpressionParser;
let parser = new;
// Parse a single free variable.
let x = parser.parse;
// Parse the identity function.
let id = parser.parse;
// f ∘ g
let compose = parser.parse );
// Print the free variable in this expression.
let unbound_y = parser.parse;
println!;
// No need for parsing strings at all.
let id = λ!;
let one = λ!;
// Identity application.
let id = λ!;
println!;
// Make the Y combinator.
let ω = parser.parse;
let Ω = parser.parse;
let W = parser.parse;
let Y = parser.parse;
Development
This assumes you have an updated and working copy of [rustup
][rustup].
WASM
First make sure you have wasm-pack
installed. Then:
wasm-pack build