|Compiler Books? firstname.lastname@example.org (2003-10-27)|
|Re: Compiler Books? email@example.com (2003-10-31)|
|Re: Compiler Books? firstname.lastname@example.org (2003-11-01)|
|Re: Compiler Books? Jeffrey.Kenton@comcast.net (Jeff Kenton) (2003-11-21)|
|From:||email@example.com (Henry Spencer)|
|Date:||1 Nov 2003 12:02:25 -0500|
|Organization:||SP Systems, Toronto, Canada|
|Posted-Date:||01 Nov 2003 12:02:25 EST|
VBDis <firstname.lastname@example.org> wrote:
>IMO top-down parsers are easier to understand than bottom-up
>parsers. Even if both types can be used for C and Pascal, bottom-up
>parsers are commonly described and used for C, and top-down parsers
>for Pascal and other "Wirthian" languages.
>...if your language has to be somewhat compatible with C,
>you have to go the harder way.
Sorry, not so. C was designed for top-down parsing; the first C
compiler, Dennis Ritchie's own, used recursive descent with some
Even ANSI C is not that hard to parse top-down. It requires some work
and thought, not just a mechanical transcription of the standard's
grammar. There are a few places where it helps to peek ahead one
extra token, to decide which way to go in a timely way. And of course
you need some interaction with the symbol table to get typedefs right.
Some of this is annoying but none of it is prohibitive; I've done it.
Incidentally, Bjarne Stroustrup is on record as saying that letting
Aho and Johnson talk him out of writing a recursive-descent parser for
the early C++ was a major mistake. C++ is extremely difficult to
parse using pure bottom-up techniques, and needs a lot of kludges,
while doing it top-down is fairly straightforward and is common in
MOST launched 30 June; first light, 29 July; 5arcsec | Henry Spencer
pointing, 10 Sept; first science, early Oct; all well. | email@example.com
Return to the
Search the comp.compilers archives again.