tags:

views:

91

answers:

4

it appears the basic course I took at the university, is not nearly enough. is there a good basic practical book that would help me understand the principles of building a scanner/parser.

what I need is a down to earth book, heavy on examples and light on long winded theoretical-mathematical discussions

A: 

ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages.

.. The website contains plenty of documentation and examples. Including a course: http://www.antlr.org/wiki/display/CS652/CS652+Home

This course concerns itself specifically with the implementation and translation of computer languages, leaving an in-depth study of language design to another course. Students will learn the formalisms behind computer languages, but the focus will be on developing the ability to build languages and their translators.

The MYYN
A: 

I was able to build a parser for CSS, using the reference grammar at http://www.w3.org/TR/CSS21/grammar.html and the tool at http://www.devincook.com/goldparser/

To do this I needed to, just slightly:

  1. Adapt the reference grammar to match the syntax supported by the tool, described here: http://www.devincook.com/goldparser/doc/meta-language/index.htm

  2. Do something with the ouput from one of the run-time engines described at http://www.devincook.com/goldparser/doc/index.htm (i.e., process the abstract syntax tree produced by the parser)

By doing this I incidentally learned something about parsing.

Alternatively, you might want the user manual for ANTLR (which is a more popular and perhaps a less easy-to-learn parser).

ChrisW
+2  A: 

Back in 1983 I read Niklaus Wirth's paperback "Übersetzerbau", published in the Teubner Verlag. It described in a hands-on way building a compiler based on Recursive Descent. That's the book that really taught me compiler construction. Later on, in University, Aho/Sethi/Ullman became my favourite. I just searched Amazon, and it looks like in 1996 Wirth published an updated version in English. Look for Niklaus Wirth, "Compiler Construction", Addision Wesley, 1996, ISBN 978-0201403534. If it's as good as the German language predecessor, you should like it.

Carsten Kuckuk
Thanks for the book reference. Also there is an online version of this book available at: http://www-old.oberon.ethz.ch/WirthPubl/CBEAll.pdfI think this the revised version of book you have mentioned.
sateesh
Thank you for posting the link. Great find! If I can trust my memory, the German version that I read in 1983 also contained a small chapter on bootstraping, but that's a small omission.
Carsten Kuckuk
@Carsten Kuckuk :great book thank you for recommending it. @satees: thanks for the link!
Eli
+2  A: 

I recommend the dragon book or the book you used to learn compilers, plus a lex & yacc tutorial.

There are other books saying that they are more practical and have codes. But those codes are quite preliminary, there is no big gap between the principle and toy codes (although very big gap between principle and production codes)

Also I found the following course web page quite concise yet informative: http://flint.cs.yale.edu/cs421/

I read these slides when I was learning a compiler course.

Yin Zhu