Examples
- Simple term: (\x y.x) y
- Non-terminating: (\x.x x) (\x. x x)
- You can define aliases: let Id = \x. x
- And use them: Id k
- Church booleans: True a b
- Church numerals: 0 a b
Grammar
// Input of prompt
<input>
:= <assignment>
| <lambda-expr>
<assignment>
:= let <alias-identifier> = <lambda-expr>
<lambda-expr>
:= <abstraction>
| <applications>
<applications>
:= <identifier>
| <number>
| <alias-identifier>
| ( <applications> )
| ( <abstraction> )
| <applications> <applications>
<number> := 0 | 1 | ...
// You can also use "\" instead of "λ"
<abstraction>
:= λ <abstraction'>
<abstraction'>
:= <identifier> <abstraction-bindings>
| <identifier> . <lambda-expr>
// <alias-identifier> must start with an uppercase char
Source code on github