Compiles a LISP dialect into regular binaries using LLVM.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Clyne fe904e47f2 Report on caught syntax errors 2 years ago
.gitignore Report on caught syntax errors 2 years ago
LICENSE initial code upload 2 years ago
Makefile initial code upload 2 years ago
README.md Update 'README.md' 2 years ago
ast.cpp Report on caught syntax errors 2 years ago
ast.hpp initial code upload 2 years ago
main.cpp Report on caught syntax errors 2 years ago
parser.cpp Report on caught syntax errors 2 years ago
parser.hpp Report on caught syntax errors 2 years ago
state.hpp initial code upload 2 years ago

README.md

lisp-compiler

This is an experimental implementation of a LISP dialect, using LLVM to produce executable binaries. The objective of this project is to allow for the use of LISP in compiled contexts, accompanying other compiled code from languages like C and C++.
In particular, this would allow for the use of LISP in embedded or other low-resource applications that require native execution speed.

The compiler is being designed according to the R7RS-small standard for the Scheme dialect of LISP. Complete compliance is the goal, though the priority of producing compiled binaries with low overhead may require some deviations from the standard.

Compilation

This project requires the LLVM development libraries and a compiler that supports C++20. Simply run make to produce the compiler binary main.

Usage

main takes the LISP code in its arguments and attempts to compile it. If successful, an out.o object file will be produced; this can be executed if linked using a compiler like gcc: gcc out.o -o out.

Statements are processed in order, and command statements are placed inside a main function. For example:

./main "(define myvariable 13) (define getmyvariable (lambda () myvariable)) (getmyvariable)"

The above code defines a global variable, a function that returns that variable's value, and then puts a call to that function in main. Soon, that return value will be returned through main as one would expect.

Support for reading source code from files or stdin will be added in the future.