Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Extending GCC parser

On 7 Apr 2009, at 17:05, Mike Kucera wrote:

Hi Alex,

I'm curious to know why you have chosen to extend the DOM parser instead of the LR parser. The LR parser is new but it was designed specifically to be easily extended to add support for new C-based languages like ObjectiveC. If you have run into problems or concerns with the LR parser I would like to know what they are.

Plus with the LR parser all the API you need to create the parser is public (although all the API is "provisional" meaning we can change it anytime if needed).

Hi Mike,

I'm still finding (stumbling?) my way through CDT at the moment, and I'm still confused by the array of parsers (for different variants of C, like C99 and GNUC and .... not to mention the whole DOM vs LR issue :-)

I spent a bit of time at EclipseCon talking with Markus Schorn about the Objective C support, and how the whole CDT was put together. In the course of a quick run-through of how it fits together, we stepped through the DOM parser and thought that e.g. the parseDeclaration and expression() would be good injection points for the Objective-C syntax. As it happens, I've got a bit of code that detects Objective-C calls in a C expression now, although it constructs a placeholder ASTNode rather than anything specific at the moment.

I'm not sure how to get started with the LRParser or how to extend it. The RuleAction code looks like it's being automatically generated from something, but I don't know where the rule number or rules are being defined. I also don't have a grammar for objective c files :-) In fact, I don't think there is a standard grammar - it's mostly defined by its implementation.

So, if you have any pointers on how to get started with the LR parser then I could take a look; but the reason I've not run into problems is I can't find the starting line :-)

Alex


Back to the top