This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Hand-written rec-descent parser of GCC-4.1 is WRONG!!!
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: jc-nospam at jr-pizarro dot jazztel dot es
- Cc: Joe dot Buck at synopsys dot COM, gcc at gcc dot gnu dot org
- Date: Tue, 15 Mar 2005 23:41:58 -0500
- Subject: Re: Hand-written rec-descent parser of GCC-4.1 is WRONG!!!
- References: <1110945415.4237ae879831e@webmail.jazznet.es>
On Wed, 2005-03-16 at 04:56 +0100, jc-nospam@jr-pizarro.jazztel.es
> | > | Bison remains a good solution in many cases, especially for languages
> | > | specifically designed to be easy to parse with an LALR parser (that is,
> | > | languages that don't look like C).
> | >
> | > Why don't we develop a "LR(k) / k small" functions-written parser for this
> | > complex grammar?
> |
> | Because C++ is not LR(k) for any k. It really does require unbounded
> | lookahead.
>
> It's possible that C++ doesn't require unbounded lookahead
No, it's not.
In fact, if you'd read the language grammar definition, you'd discover
you could pretty produce the anti-program with some work.
That given any k, it produces a C++ program that cannot be parsed with
an LR(k) parser.
Unless you are going to refute that this is possible (and it has been
done before, so trying to refute it would just make you look sily), this
proves that C++ is not an LR(k) language.