Re: compiler books, was Looking for Compiler Design in C, by Holub

Chris F Clark <compres@world.stc.com>
29 Nov 1999 00:19:41 -0500

          From comp.compilers

Related articles
Looking for Compiler Design in C, by Holub lojedaortiz@interlink.com.ar (Nicolás) (1999-11-20)
Re: Looking for Compiler Design in C, by Holub vween@gdi.net (Wayne) (1999-11-23)
Re: Looking for Compiler Design in C, by Holub lojedaortiz@interlink.com.ar (Nicolás) (1999-11-28)
Re: compiler books, was Looking for Compiler Design in C, by Holub compres@world.stc.com (Chris F Clark) (1999-11-29)
Re: Re: compiler books, was Looking for Compiler Design in C, by Holub qjackson@wave.home.com (Quinn Tyler Jackson) (1999-12-01)
Re: compiler books, was Looking for Compiler Design in C, by Holub rkrayhawk@aol.com (1999-12-15)
Re: Re: compiler books, was Looking for Compiler Design in C, by Holub doug@netcom.com (1999-12-24)
Re: making a production quality parsing tool qjackson@wave.home.com (Quinn Tyler Jackson) (1999-12-24)
| List of all articles for this month |

From: Chris F Clark <compres@world.stc.com>
Newsgroups: comp.compilers
Date: 29 Nov 1999 00:19:41 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 99-11-121 99-11-141 99-11-167
Keywords: books, comment

Nicolás wrote:


> I've got myself a copy of the Dragon Book, but, unfortunately, I find
> it very dificult to transalte the info shown and explained there to
> actual code. I've been told that 'Compiler Design' is far more
> 'practical', and that it is useful as a bridge between the Dragon and
> the very basic books.


It is indeed quite practical if what you want to learn how to do is
write a parser generator. It contains sources for at least 3
different tools (a YACC-clone, a LEX-clone, and an LL parser
generator).


Now, if you will pardon my soapbox:


However, it is not clear to me that learning to write a parser
generator teaches one very much about writing a compiler or even about
how to write a parser. Unfortunately, I have yet to find a book that
does a good job of teaching one how to write a grammar. (There are
some books that at least give a good rough draft of how to build a
compiler provided that one has a grammar.)


Perhaps, there is a common mis-conception that if you understand the
mechanics of how the grammar matches the input that one will magically
intuit how to write correct, readable, and succinct grammars that do
what one wants. Or perhaps learning to write grammars is like
learning to write in general and it is just hard to teach.


Finally, a word of caution about writing parser generators. Once you
get the hang of it, it is easy--too easy. It is quite possible to
write a working parser generator as an undergrad student (say as a
course project). As a result, every semester several new parser
generators get released. Some of them even incorporate novel and
worthwhile contributions. At the same time most of them lack polish
and almost all of them are abandoned before becoming useful in any
meaningful sense.


Just to illustrate the point. A quick proof-of-concept version of
Yacc++(r) took us only a few days to write (in Pascal on an Atari
1040ST). It took us about a year before we had something that we felt
was worth releasing to the public and even then we had things that
were unusable by anyone other than us. About 2 years later, we had
learned enough that it was worth rewriting into essentially its
current form. That rewrite eliminated most (but not all) of the
things which made it difficult to use. Even today, years later, there
are still edges that are rough and need sanding. If you ask Terence
about ANTLR, you'll find that story is similar.


-Chris


*****************************************************************************
Chris Clark Internet : compres@world.std.com
Compiler Resources, Inc. CompuServe : 74252,1375
3 Proctor Street voice : (508) 435-5016
Hopkinton, MA 01748 USA fax : (508) 435-4847 (24 hours)
------------------------------------------------------------------------------
Web Site in Progress: Web Site : http://world.std.com/~compres
[I agree. It's useful to understand enough about LALR and such to understand
what they can and cannot parse, but that's utterly separate from how you
write a usable grammar. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.