Skip to main content

Crate lambda_throw_cat

Crate lambda_throw_cat 

Source
Expand description

§lambda-throw-cat

Lambda calculus with records, prototype chains, ref cells, a tracing GC, and non-local control flow via throw and try/catch. Spike 4 of a comp-cat-rs web-engine reformulation targeting Tauri.

§Quick start

use lambda_throw_cat::run;

let source = r"
    try
        throw (\msg. msg)
    catch e. e
";
let value = run(source).run()?;
assert_eq!(format!("{value}"), "\\msg. msg");

§Grammar

expr        ::= seq_expr
seq_expr    ::= right_expr (";" right_expr)*
right_expr  ::= lambda | let | fix | extend | throw_expr | try_expr | assign_expr
lambda      ::= "\" ident "." expr
let         ::= "let" ident "=" expr "in" expr
fix         ::= "fix" ident "." expr
extend      ::= "extend" atom object_lit
throw_expr  ::= "throw" right_expr
try_expr    ::= "try" right_expr "catch" ident "." right_expr
assign_expr ::= app_expr (":=" right_expr)?
app_expr    ::= atom atom*
atom        ::= base_atom ("." ident)*
base_atom   ::= ident | "(" expr ")" | "ref" atom | "!" atom | object_lit
object_lit  ::= "{" props? "}"
props       ::= property ("," property)*
property    ::= ident "=" right_expr

Modules§

env
Persistent lexical environments.
error
Project-wide error type.
eval
Tree-walking interpreter with heap-threading, prototype-walking field access, and throw/try-catch non-local control flow.
gc
Mark-sweep garbage collection.
heap
Persistent heap of mutable cells.
lexer
Tokenizer for the object-extended lambda calculus surface syntax.
parser
Recursive-descent parser for the throw-extended lambda calculus.
syntax
Abstract syntax and source-position newtypes.
value
Runtime values.

Constants§

DEFAULT_FUEL
Default step budget used by run.

Functions§

run
Lex, parse, and evaluate source with the default fuel budget.
run_inspecting
Lex, parse, and evaluate source, returning both the value and the final heap. Useful for tests that need to verify GC behaviour.
run_with_fuel
Lex, parse, and evaluate source with a caller-supplied fuel budget.