Skip to content

ficnawode/tiny-lisp-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny Lisp 2

Subset of the lisp programming language to x86_64 assembly compiler.

The dialect

  • 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-debug function (see tests) or just plain gdb

Why?

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.

Setup

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.

About

LISP dialect to x86_64 assembly compiler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published