didac-94 / buildyourownlisp

My following of the book Build Your Own Lisp by Daniel Holden

Home Page:http://buildyourownlisp.com/

Repository from Github https://github.comdidac-94/buildyourownlispRepository from Github https://github.comdidac-94/buildyourownlisp

Learning C by Building a Lisp-like Interpreter

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.

Setup

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.

Tools

# Compiler (gcc) and debugger (dbg)
sudo apt install build-essential

Dependencies

# 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.

Compiling, running and debugging

# 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

About

My following of the book Build Your Own Lisp by Daniel Holden

http://buildyourownlisp.com/

License:GNU General Public License v3.0


Languages

Language:C 97.3%Language:NewLisp 2.7%