Skip to main content

Module parser

Module parser 

Source
Expand description

Recursive-descent parser for the lambda calculus surface syntax.

The grammar is:

expr     ::= lambda | let | fix | app_expr
lambda   ::= "\" ident "." expr
let      ::= "let" ident "=" expr "in" expr
fix      ::= "fix" ident "." expr
app_expr ::= atom atom*                  (left-associative application)
atom     ::= ident | "(" expr ")"

Application binds tighter than abstraction and let/fix, so \x. x y parses as \x. (x y) and let id = \x. x in id id parses as let id = (\x. x) in (id id).

Functionsยง

parse
Parse a full expression from a token slice.