Make-A-LISP

Chris Chapline

What is it?

  • A process for creating a LISP interpreter
  • Language agnostic
  • Each step is self contained and testable
  • Creates a self-hosting interpreter

What are the steps?

  1. REPL Skeleton
  2. Implementing the reader
  3. Evaluating expressions
  4. The REPL environment
  5. if, fn, and do
  6. Tail call optimization

7. Files and strings

8. Quoting

9. Macros

10. try and catch

11. Self hosting

1. Bash Shell

2. C

3. C#

4. Clojure

5. CoffeeScript

6. Forth

7. Go

8. Haskell

9. Java

10. JavaScript

Implementation Examples

11. Lua

12. GNU Make

13. mal

14. MATLAB

15. miniMAL

16. Nim

17. OCaml

18. Perl

19. PHP

20. Postscript

21. Python

22. R

23. Racket

24. Ruby

25. Rust

26. Scala

27. Swift

28. Visual Basic.NET

Step 1: The REPL Skeleton

Step 2: The Reader

Step 3: Expressions

Step 4: Environments

Step 5: if, fn*, do

Step 6: Tail Calls

Step 7: Files & Strings

Step 8: Quoting

Step 9: Macros

Step 10: Try/Catch

Step 11: Self Hosting

An Example Implementation

Some Example Code

defn macro:

(defmacro! defn 
  (fn* [name args impl]
    `(def! ~name (fn* (~@args) ~impl))))

(defn identity [a] a)

(macroexpand (defn identity [a] a)); (def! identity [a] a)

New flow of control structures:

(defmacro! unless 
  (fn* [test body] 
    `(if ~test nil ~body)))

(defmacro! while 
  (fn* [test body] 
    `(if ~test (do ~body (while ~test ~body)))))

Thanks :D

Github project page here

 

For those interested, Write Yourself a Scheme

Make-A-LISP

By gizmo385

Make-A-LISP

An overview of the make-a-lisp project, which provides a multi-step procedure for creating a LISP interpreter.

  • 1,114