tags:

views:

194

answers:

5

I am looking for a compiler design book. I am learning it at college; but lectures were never meant for me. Moreover, at my college they don't do much practical and I believe even if I sincerely do the course about finite automata and compiler design, I will not know how to implement a compiler. So, I am looking for books about implementing a compiler. I find "Modern Compiler Implementation" good. It had three options of language and I chose the C book because C being a small language there will be more for me to do and more to learn during doing. However, I wanted to learn the course designing a compiler for Lisp or python [may be in the same language too]; but I could not find much material available. Lisp is an old language and there should be some documentation about designing a compiler for it. I need your suggestions regarding this.

Thank you.

+2  A: 

This isn't exactly for Lisp, but for Scheme (a lisp derivative), but we used this free (as in beer) text in my programming languages class. Here's the link:

http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/

Keep in mind, however, that they're teaching how to write an Scheme interpreter in none other than Scheme. It kind of twists you mind in knots at first, but it gets clearer after a while. I'm not exactly sure if this is what you are looking, but it's a start and illustrates some of the more important things to think about.

Eric
+3  A: 

I never read it, but at one time there was a book called "Lisp in Small Pieces" that was supposed to be pretty good for your purposes.

David Thornley
+6  A: 

Lisp in small pieces is probably the best book on implementing Lisp. Highly recommended. Probably available through some used book service. It might be expensive, even as a used book. It is a translation from the French original. There is also a revised version in French, which hasn't been translated to English - unfortunately.

I would also recommend Paradigms of Artificial Intelligence Programming, Case Studies in Common Lisp by Peter Norvig. It contains the description of a Scheme compiler written in Common Lisp. Generally this is an outstanding book.

Also see this Biblography on Scheme implementation techniques.

For Common Lisp there are articles available and some Common Lisp compilers are coming with a little bit of documentation of implementation and compiler internals. Usually the compiler can't be seen in isolation, but should be seen in combination with the runtime it compiles to (GC, instruction sets, memory management in general, threading, FFI interfaces, ...). See for example the Design of CMU Common Lisp.

Rainer Joswig
+4  A: 

Here is a great overview of a compiler design for Scheme: An Incremental Approach to Compiler Construction. It's a quite short article that describes how to build a machine code compiler for Scheme "from scratch".

dmitry_vk
+2  A: 

Study these books in order:

  1. Essentials of Programming Languages
  2. Lisp in Small Pieces

Once your basic Lisp system is working, probably you may want to implement 'specialized languages' on top of that. Then books like The Art of Metaobject Protocol becomes an essential reference.

Vijay Mathew