[antlr-interest] Parsing complex languages like C++
Paul Johnson
gt54-antlr at cyconix.com
Fri Nov 18 01:20:27 PST 2005
software.au at gmail.com wrote:
> Does anyone know how to parse complex languages like C++? Can it only
> be done with significant hacks to an LALR or LR parser? Can it be
> done at all recursive descent? Any type of algorithm that works for
> this language, and other complex/difficult to parse languages?
g++ is still, I think, LALR(1). They switched from Bison to a hand-coded
recursive-descent parser sometime around 3.3, and it made a vast
improvement in the language conformance.
I can't immediately see that using LR makes it intrinsically difficult
to parse C++, but I haven't tried it. The gcc team did blame a lot of
bugs on Bison, but I think that's probably just down to Bison's
shortcomings. In particular, I think a much tighter coupling between
Bison and Flex would make it a lot more useful and generally applicable.
Bison has been GLR for a couple of years at least; it supports unlimited
(?) lookahead.
Paul
More information about the antlr-interest
mailing list