MiniLisp
Star 1.1k Watch 28 Fork 150
A readable lisp in less than 1k lines of C.
One day I wanted to see what I can do with 1k lines of C and decided to write a Lisp interpreter. That turned to be a fun weekend project, and the outcome is a mini lisp implementation.
It supports
- integers, symbols, cons cells,
- global variables,
- lexically-scoped local variables,
- closures,
- if conditional,
- primitive functions, such as +, =, <, or list,
- user-defined functions,
- a macro system,
- and a copying garbage collector.
All those in 1000 lines of C. I didn't sacrifice readability for size. The code is in my opinion heavily commented to help the reader understand how all these features work.
(println 3) ; prints "3"
(+ 1 2 3) ; -> 6
(define a (+ 1 2))
(+ a a) ; -> 6
No GC Branch
There is a MiniLisp branch from which the code for garbage collection has been stripped. The accepted language is the same, but the code is simpler than the master branch's one. The reader might want to read the nogc branch first, then proceed to the master branch, to understand the code step by step.
The nogc branch is available at nogc
. The original is available at master
.
Top comments (0)