Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tbonelaforge/lambda

An interpreter for a programming language based on the Lambda Calculus.
https://github.com/tbonelaforge/lambda

Last synced: 3 months ago
JSON representation

An interpreter for a programming language based on the Lambda Calculus.

Awesome Lists containing this project

README

        

Getting Started:

1. git clone [email protected]:tbonelaforge/lambda.git
2. cd lambda
3. make
4. ./lambda ./examples/my_first_namespace.lc > output.html
5. Open output.html in a web browser.

Typing "make" in the top-level directory produces the **lambda** interpreter, which is an executable file. The interpreter was built for educational purposes, and produces a detailed representation of the program, before and after evaluation.
If the lambda executable is given a filename as command-line argument, e.g.

lambda ./examples/my_first_namespace.lc

it will parse the specified file,
and execute the resulting program.
This process will produce **HTML** output which, when viewed in a web browser,
shows a graphical representation of the operator trees before evaluation of the program,
and the final operator trees after evaluation is all finished.

Programs written in the language resemble something like the following:

two:((plus,one),one);
one:\f\x(f,x);
plus:\m\n\f\x((m,f),((n,f),x));

Each semicolon-terminated line of input establishes an entry in a namespace ( symbol table ). For example, after parsing the first line above,
the operator tree for "((plus,one),one)" will be
stored in the namespace under the name "two".

The backslashes in the second and third lines each mark a bound variable in a lambda (function) definition.
The parentheses show the application of one expression to another.
For example, the expression:

\f\x(f,x)

Defines a function which takes two arguments ( 'f' and 'x', in that order ),
and applies the first argument to the second.

The program defined in **my_first_namespace.lc** defines the [Church Numeral](https://en.wikipedia.org/wiki/Church_encoding) for the number 1,
and a function to add two church numerals together.
Then, it calculates the church numeral for the number 2 by adding 1 + 1.