Subset of the lisp programming language to x86_64 assembly compiler.
- Functions are first class citizens: closures are fully implemented so they can be returned, passed as arguments, have an unlimited amount of arguments and so on
- Two-pass compilation so mutual function recursion is allowed
- No global set, global variables cannot be changed inside a scope (borrowed from functional programming)
- No strings (yet) so if you want to verify the result of an operation you need to use either the
print-debugfunction (see tests) or just plaingdb
I am a physics major, we never had a compilers class, I hold an interest in this subject. I once wrote an interpreter for a basic-like language, but my skills have improved since and this time around I wanted to brush up on my assembly.
If you want to run this, you will need cmake, nasm, and a glib implementation on your computer.
mkdir build && cd build
configure:
cmake ..
build:
make
The tests should build automatically.
If you want to compile your own lisp programs:
<path-to-compiled-compiler-exec-main> <path-to-your-program>.lisp
then the compiler will produce a .asm file which needs to be assembled (I use nasm), and then linked against the runtime.o library (which you will also find in the build directory) using either gcc or ld. The compiler should print an instruction in the terminal on how to do these steps. If you manage to get this far, congratulations, you should have an executable binary.