A LISP implemented as a Rust procedural macro!
I got inspired by the neat stuff people are doing with procedural macros in Rust, like yew
's html!
macro, and thought, could you write a programming language that's just a procedural macro?
As a proof of concept, I decided to implement an interperter for a basic LISP. The limitations of this LISP are:
- The entire program must be a single S-Expression
- The only functions available are
+
,-
,*
, and/
- Each expression is either an integer or a function apply
You must have rust installed.
# clone the repo
git clone https://github.com/MainShayne233/risp
# enter directory
cd risp
# call the executable
./bin/risp '(* 2 (- 5 2))'
6
Risp leans on the proc-macro-hack
crate to allow the risp!
macro to be invoked in statement or expression position.
proc-macro-hack crate
requires seperate crates for implementation, declaration, and use. You can read more about this here.
Due to this requirement, this project consists of the following crates:
risp
: Main crate that exports everythingrisp_ast
: Defines the AST for the the parsed risprisp_macro
: The implementation crate for the risp! macrorisp_test
: The crate for testing all of this code