As the title says, the purpose of this repository is not to actually craft a useful Lisp variant, but to learn the basics of the C language, as well as some fundamentals on compiler design and the Lisp family of languages.
The code follows the book Build Your Own Lisp by Daniel Holden, which is available online for free at buildyourownlisp.com. For more information, check out the first couple of chapters online.
In order to be able to compile and run the project the following is needed. This project was developed on Ubuntu 21.04. For other distros look up the equivalent commands.
# Compiler (gcc) and debugger (dbg)
sudo apt install build-essential
# editline
sudo apt install libedit-dev
# mpc
# simply copy mpc.c and mpc.h from the repo onto your source folder
git clone git@github.com:orangeduck/mpc.git
cp mpc/{mpc.c,mpc.h} buildyourownlisp/src/
I've included a copy of MPC to keep the project simple and portable, but you'll likely want to get the latest version from upstream.
# compile and link against mpc, libedit and math
gcc -std=c99 -Wall repl.c mpc.c -ledit -lm -o lsp
# run resulting executable
./lsp
# compile debug executable and start debug session with dbg
# same as above plus -g flag
gcc -std=c99 -Wall -g repl.c mpc.c -ledit -lm -o lsp
gdb lsp