This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: C++ lexer (GCC 3.1.1) requires knowledge of other C dialects

> -----Original Message-----
> From: Robert Dewar []
> Sent: Thursday, August 01, 2002 3:21 AM
> To: gary@Intrepid.Com;
> Cc:
> Subject: Re: C++ lexer (GCC 3.1.1) requires knowledge of other C
> dialects
> <<There are tricks to solve most of these problems, but a
> recursive-descent parser is just so much easier to understand, to debug,
> and to handle special quirks that I much prefer it.  Yes, the actual
> grammar isn't as cleanly separated, and the source is slightly more
> verbose, but I much prefer it.
> >>
> When we use the phrase "recursive descent" what we mean in practice is
> not a straight LL(1) parser. If we wanted a straight LL(1) parser, then
> we could use an appropriate parser generator (though why would we do this
> when LRK PG's are clearly preferable).
> The point about recursive descent is that it is hand written code that can
> use any techniques it likes to parse the source. It can do a bit of backup
> or extra look ahead if it wants, it can keep information on the side and
> roam around the tree etc. This is particularly use for two purposes:

Although this is a bit of philosophical debate (regarding the merits of
handbuilt vs. program-generated parsers), I'll point out that the ANTLR
parser generator ( generates LL(k) recursive descent
parsers with additional features which include: (1) syntactic and semantic
predicates which allow for arbitrary checks before an alternative is taken,
(2) approximate linear lookahead which accepts a larger class of LL(k)
grammars, (3) automated error recovery, and support manual, arbitrary error
recovery, (4) parsers built in C, C++, and Java, (5) builtin support for
building AST's (Abstract Syntax Trees).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]