Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Objective-C (was: How to extend the C99 / GCC LR Parser)

As a "fly on the wall", I'll also chime in with do not forget about "Objective-C++" where we mix Objective C and C++ in the same file, and sometimes in the same line of code. Not sure how much that muddies the waters but I expect that to be a challenging scenario for any parser.
___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson@xxxxxxxxxxxxxx 
BlueQuartz Software               Dayton, Ohio

On Jul 11, 2011, at 10:17 AM, Mike Kucera wrote:

> I agree with Markus. Adapting the LR-Parser doesn't get you very far because at the end of the day CDT needs to know about new AST node types. 
> 
> The hand written parsers are also faster and use less memory.
> <ecblank.gif>
> Mike Kucera	<ecblank.gif>	
> <18452675.gif>
> Rational Multicore Tooling	<ecblank.gif>
> UI Team Lead	<ecblank.gif>
> IBM Toronto Lab	<ecblank.gif>	<ecblank.gif>
> mkucera@xxxxxxxxxx	<ecblank.gif>	<ecblank.gif>
> 
> 
> <graycol.gif>"Schorn, Markus" ---07/11/2011 03:12:58 AM---Hi Doug, Objective-C has extensions above C that need to be represented in AST. My recommendation is
> 
> From:	"Schorn, Markus" <Markus.Schorn@xxxxxxxxxxxxx>
> To:	"CDT General developers list." <cdt-dev@xxxxxxxxxxx>
> Date:	07/11/2011 03:12 AM
> Subject:	Re: [cdt-dev] Objective-C (was: How to extend the C99 / GCC LR Parser)
> Sent by:	cdt-dev-bounces@xxxxxxxxxxx
> 
> 
> 
> Hi Doug,
> Objective-C has extensions above C that need to be represented in AST. My recommendation is, to handle it similar to C and C++:
> * Create AST interfaces + implementation for the ObjectiveC specific constructs.
> * Derive parser from GNUCSourceParser.
> * Provide an Objective-C variant of IASTName (like CASTName and CPPASTName) and an Objective-C specific name resolution (similar to what we have in CVisitor).
> * All the features on top of the AST have to be reviewed for whether they can be reused directly or with some work for Objective-C (i.e. Refactoring, Navigation, Formatter, ....).
> 
> --> I cannot think of a solution that is not an integral part of the core-cdt. The tooling will not be able to handle an extension it is not aware of.  (At least the AST interfaces need to be part of the core).
> 
> For the parser you can alternatively derive from the LR-Parser, however our hand-written parsers are superior in handling the syntactic ambiguities of C and C++.
> 
> Markus.
> 
> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Schaefer, Doug
> Sent: Friday, July 08, 2011 17:11
> To: CDT General developers list.
> Subject: [cdt-dev] Objective-C (was: How to extend the C99 / GCC LR Parser)
> Importance: Low
> 
> Hi Markus,
> 
> Any thoughts about handling Objective-C this way, or is it just too big a change? There is interest in the community to pursue it, how would you recommend they proceed?
> 
> Thanks,
> Doug.
> 
> > -----Original Message-----
> > From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
> > On Behalf Of Schorn, Markus
> > Sent: Friday, July 08, 2011 2:22 AM
> > To: CDT General developers list.
> > Subject: Re: [cdt-dev] How to extend the C99 / GCC LR Parser
> > 
> > Hi Sebastian,
> > While extending the parser is a valid option, it will be much easier, 
> > if you manage to configure the existing parser.
> > Clearly, it is not possible to handle every language extension in that 
> > way, but it may work in your case.
> > For instance, depending on what __data16 does, I would try to map it 
> > to either 'short' or to the empty token.
> > 
> > To configure the existing parser you need to subclass GCCLanguage and 
> > provide a customized IScannerExtensionConfiguration and/or 
> > ICParserExtensionConfiguration.
> > 
> > Markus.
> > 
> > -----Original Message-----
> > From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
> > On Behalf Of Sebastian Wagner
> > Sent: Thursday, July 07, 2011 17:11
> > To: cdt-dev@xxxxxxxxxxx
> > Subject: [cdt-dev] How to extend the C99 / GCC LR Parser
> > Importance: Low
> > 
> > Hello all,
> > 
> > I am working on a parser for a C based language which contains some 
> > small extensions, e.g. special type qualifiers. Therefore I would like 
> > to extend the
> > C99 or GCC LR Parser.
> > 
> > I read a lot of content in the web and CDT source code. I managed to 
> > generate the Parser from the grammar file and I'm able to compile the 
> > generated files. I also understood that today the lexer is not 
> > generated using the LPG, but is a part of the preprocessor.
> > 
> > Now, nevertheless I didn't get the complete overview where I need to 
> > do changes if for instance I want to add a new type qualifier 
> > "__data16". Do I have to do modifications on the preprocessor and do I 
> > do that? I think keywords can be added using the 
> > ScannerExtensionConfiguration, but I don't know how to do this correctly. Do I also need to do adaptations to the AST?
> > 
> > It would be great if one of you could give me a short overview in 
> > which modules I need to do modifications, so that I understand the 
> > behavior better.
> > 
> > Thanks in advance!!
> > 
> > 
> > Sebastian Wagner
> > 
> > __________________________________________________________
> > _
> > Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die Toolbar 
> > eingebaut! http://produkte.web.de/go/toolbar 
> > _______________________________________________
> > cdt-dev mailing list
> > cdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/cdt-dev
> > _______________________________________________
> > cdt-dev mailing list
> > cdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/cdt-dev
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top