This is the mail archive of the gcc@gcc.gnu.org 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: Hand-written rec-descent parser of GCC-4.1 is WRONG!!!


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.



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