views:

338

answers:

8

Are there ANY books (maybe even long tutorials) which cover making a basic, interpreted language?

+5  A: 

Despite the name, this one:

alt text

Ignacio Vazquez-Abrams
Are you sure?Looks like it's about compilers rather than interpreters. =P
Matt H
Matt - you still need to parse the language, convert it to some form, and then do something with it. This book covers a lot o good stuff.
SB
milan1612
How much difference is there between the 1985 edition and the second one?
Matt H
The second edition uses Java instead of a Pascal-like pseudocode, and has an errata list the length of your arm. Avoid if possible.
Ignacio Vazquez-Abrams
Sigh. As usual, people who haven't read it vote up a bad answer about a bad book. The question is about writing INTERPRETERS.
anon
"Matt - you still need to parse the language, convert it to some form, and then do something with it. This book covers a lot o good stuff. – SB 56 mins ago"
advs89
the Terrance Parr books are the ones you want, avoid this old crusty relic.
fuzzy lollipop
+2  A: 

You should say target environment, language, and OS you're using.

If you want to learn about implementing your own VM and scripting language, get the book Game Scripting Mastery. Despite its title, it is actually about implementing your own virtual machine and scripting language. The source code is for Win32, but the concepts can be applied to Mac OS or Linux.

As a bonus, when you're done you will have a playable, scriptable, 2D adventure game.

Dour High Arch
A: 

Don't do it. There are lots of good interpreted language like Python, javascript out there already. You can always embed them into your application. To design a good programming language need a lot of theory and deliberation plus a community to support it. Every time I see someone design their own "light-weight scripting language", it is inevitably crappy and hard to use beyond a few toy examples.

If you do this for academic interest, have fun with the dragon book. If you want something with practical use, embed one of the popular interpreter.

Wai Yip Tung
Don't worry, this is all for academic purposes. :)It's just something that I've always wanted to do.
Matt H
+9  A: 

Take a look at the book below. The author is the creator of ANTLR.

Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages.

alt text

Taylor Leese
I didn't know he published another book! Thanks!
egarcia
I'm not a huge Parr fan, but the table of contents of this book looks like exactly what OP is looking for. **Not** the bloody dragon book!+1
Norman Ramsey
Absolutely! I'll probably give this one a go.
Matt H
+4  A: 

If you want to build compilers in an old, C-with-macros way, the Red Dragon Book is all you need.

If you want to build interpreters in a modern, structured, simpler way, use this other book: The definitive ANTLR reference

Seriously, ANTLR takes interpreter and compiler generation to the 21st century.

egarcia
+1  A: 
Norman Ramsey
+2  A: 

By far, the best book for this is Writing Compilers and Interpreters by Ronald L. Mak.

The book explores basically everything you will need to develop a working interpreter from scratch. It explores object- oriented languages and writing a debugger. as well.

This book really helped me along when I was developing my own language.

George Edison
This one looks good! Thanks. :)
Matt H
+1  A: 

The best book about writting an interpreter I'd read is Lisp in Small Pieces.

"This is a comprehensive account of the semantics and the implementation of the whole Lisp family of languages, namely Lisp, Scheme and related dialects.

It describes 11 interpreters and 2 compilers, including very recent techniques of interpretation and compilation. The book is in two parts.

The first starts from a simple evaluation function and enriches it with multiple name spaces, continuations and side-effects with commented variants, while at the same time the language used to define these features is reduced to a simple lambda-calculus. Denotational semantics is then naturally introduced.

The second part focuses more on implementation techniques and discusses precompilation for fast interpretation: threaded code or bytecode; compilation towards C. Some extensions are also described such as dynamic evaluation, reflection, macros and objects.

This will become the new standard reference for people wanting to know more about the Lisp family of languages: how they work, how they are implemented, what their variants are and why such variants exist. The full code is supplied (and also available over the Net). A large bibliography is given as well as a considerable number of exercises. Thus it may also be used by students to accompany second courses on Lisp or Scheme."

http://www.amazon.com/Lisp-Small-Pieces-Christian-Queinnec/dp/0521562473

Pedro