Skip to content

didac-94/buildyourownlisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published