This repository implements a Lisp interpreter in SQL, leveraging Materialize's support for mutual recursion and iterative dataflows. It evaluates Lisp expressions encoded as JSON arrays, pushing the boundaries of what SQL can achieve while showcasing Materialize's unique capabilities.
This project interprets Lisp expressions entirely in SQL. By combining recursive CTEs with Materialize's fixed-point iteration, it provides a functional interpreter capable of handling arithmetic operations, conditionals, list manipulation, and user-defined functions.
The interpreter operates by iteratively decomposing and evaluating Lisp expressions using recursive SQL queries. Materialize's engine ensures efficient, incremental computation by propagating changes through the dataflow until a fixed point is reached.
- Arithmetic Operators:
+,-,*,/ - Comparisons:
=,>,<,>=,<= - Logical Operators:
and,or,not - Conditionals:
ifexpressions - List Manipulation:
cons,car,cdr - User-Defined Functions:
defunand function calls - Lexical Scoping: Maintains proper variable environments across nested expressions through
letbindings. - Recursion and Mutual Recursion: Supports recursive function definitions and their evaluation.