views:

554

answers:

2

I'd like to implement a Lisp interpreter in a Lisp dialect mainly as a learning exercise. The one thing I'm thrown off by is just how many choices there are in this area. Primarily, I'm a bit more interested in learning about some of the Lisps that have been around a while (like Scheme or Common Lisp). I don't want to use Clojure to do this for the sheer fact that I've already used it. :-)

So is one of the flavors any better than the others at parsing? And do you think it's a good idea to say implement Scheme in Common Lisp (or vice versa)? Or will there be enough differences between the two to throw me off?

And if it makes any difference, I'd like something that's cross-platform. I have a Windows PC, a Mac, and a Linux box, and I could end up writing this on any of them.

+15  A: 

There are some books about that:

All of the above books are highly recommended, though Anatomy of Lisp is oldish, hard to get and hard to read.

Both Scheme and Common Lisp are fine for your task.

Implementing Common Lisp is a larger task, since the language is larger. Usually one implements Common Lisp better in Common Lisp, since there are Common Lisp libraries that can be used for new Common Lisp implementations. ;-)

Rainer Joswig
I've read PAIP and SICP's chapters on writing lisp interpreters in lisp, and I think that the former is better for someone new to Common Lisp, although both are highly recommended.
justinhj
It's worth mentioning that PAIP's Scheme interpreter and compiler are both written in Common Lisp, which answers another aspect of the question.
Pillsy
Does anyone else see the irony here, or is it just me? =)
Erik Forbes
+2  A: 

PLT Scheme is an excellent platform for experimenting with programming languages, especially Lispy languages. PLT has an extensible parser (usually called a reader in Scheme) that provides reader macros to manipulate the built in syntax; or you can completely replace the reader with your own. If you'd rather use traditional lex/yacc style parsers and lexers, PLT comes with a parser-tools module that provides those, too. As a bonus, it has comprehensive documentation and a repository for third-party packages (two things that are missing from a lot of Schemes).

The reference implementation of Arc (arclanguage.org) is a fairly simple and readable example of building a language that compiles to Scheme. It uses PLT's reader mostly, with a couple of reader macros to change the bits of Scheme syntax that differ from Arc's. There's also a JavaScript implementation available from PLT's package repository (planet.plt-scheme.org) if you want to see how to implement a non-Lisp language.