Various versions of the Lisp In Small Pieces interpreter -- in Coffeescript! #complete
Go to file
Elf M. Sternberg db2e93b2f3 [refactor] Is this the functor/applicative/monadic life?
This is a big change.  For chapter 5, I ripped out all line/column
tracking and most error handling from the parser; it's now a plain
ol' Lisp parser, and if it's not close to CL 22.1.1, it's a hell of
a lot closer than it used to be.

In doing so, I reduced the size of the parser by about 40 lines.

TrackingReader takes every function in a Reader and puts that
debugging information *back*.  It turns out that all that information
was prelude and postlude to the act of parsing; by wrapping each
function in a decorator I was able to restore all that information,
and I only had to get it right exactly *once*.

In functional programming terms, this lifts:

	IO -> (atom | list)

to:

	IO with tracking -> Node (atom | list) with tracking

It's a totally free win without having to do much extra work.

Now, this check-in isn't perfect.  The tracking reader is still
tossing on some things, and because I don't have a robust type
system (it is Coffeescript, after all), I'm having to do the
decorating and wrapping by hand.  But I'm definitely on my way
to understanding the issues, and having a grasp on functors and
monoids.
2015-08-20 08:50:52 -07:00
bin Coffeescript attempt. 2015-05-13 22:28:55 -07:00
chapter-lambda-1 [feat] The interpreter works and all the tests run without crashing. 2015-08-03 07:31:22 -07:00
chapter1 [feat] Chapter 4 is done. 2015-08-16 22:21:10 -07:00
chapter3 [feat] The interpreter works and all the tests run without crashing. 2015-08-03 07:31:22 -07:00
chapter3g Beginning Chapter 4. 2015-08-15 09:43:48 -07:00
chapter4 [feat] Chapter 4 is done. 2015-08-16 22:21:10 -07:00
chapter5 [refactor] Is this the functor/applicative/monadic life? 2015-08-20 08:50:52 -07:00
docs [feat] The interpreter works and all the tests run without crashing. 2015-08-03 07:31:22 -07:00
extras [docs] Including Jenkins configuration file 2015-07-07 20:27:11 -07:00
test [refactor] Is this the functor/applicative/monadic life? 2015-08-20 08:50:52 -07:00
.gitignore [feat] Lambda-only interpreter. NOT WORKING. 2015-08-15 18:53:24 -07:00
LICENSE Coffeescript attempt. 2015-05-13 22:28:55 -07:00
Makefile [refactor] Struggling to get self-evaluating components working. 2015-07-26 14:59:49 -07:00
README.md [docs] Updating the README to be more... well, just *more* 2015-07-07 20:19:04 -07:00
coffeelint.json [test] Coffeelint configuration file. 120 character line length is okay by me. 2015-07-08 15:06:06 -07:00
package.json [test] Added Coffeelint to list to of features. 2015-07-08 15:04:32 -07:00

README.md

A Collection of Interpreters from Lisp In Small Pieces, written in Coffeescript

Purpose

I don't know Lisp, so I figured the correct place to start was to write my own interpreter. After buying five different textbooks (The Structure and Interpretation of Computer Programs, aka "The Wizard Book", Friedman's The Essentials of Programming Languages, Let over Lambda, On Lisp, and one more) I decided Christian Quinnec's Lisp In Small Pieces gave the clearest step-by-step introduction.

Since I didn't know Lisp, my task was to translate what Quiennec wrote in his book into a language I did know: Javascript. Well, Coffeescript, which is basically Javascript with a lot of the syntactical noise removed, which is why I liked it.

Usage

I don't know if you're going to get much out of it, but the reader (which I had to write by hand, seeing as I didn't have a native Lisp reader on hand in my Javascripty environment), and each interpreter has a fairly standard test case that demonstrates that each language does what it says it does: you can do math, set variables, name and create functions, and even do recursion.

Notes

chapter-lambda-1 is not from Lisp In Small Pieces. It is a primitive CPS interpreter built on top of the interpreter from LiSP Chapter 1, using techniques derived from a fairly facile reading of Lisperator's "Implement A Programming Language in Javascript." But it was fun.

See the LICENSE file.