Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Configuring CDT(Configuring CDT to parse c code with specified grammar and rules)
icon5.gif  Configuring CDT [message #1431225] Thu, 25 September 2014 11:20 Go to next message
Praveen Dharmaraj is currently offline Praveen DharmarajFriend
Messages: 7
Registered: August 2013
Junior Member
Hello,
Is it possible to customise the CDT plug-in to add grammars and rules according to our needs? I want to be able to give a list of rules to the parser for parsing c files. Is that possible ? And how?
Re: Configuring CDT [message #1432311 is a reply to message #1431225] Fri, 26 September 2014 23:58 Go to previous message
Jeff Hopkins is currently offline Jeff HopkinsFriend
Messages: 5
Registered: July 2014
Junior Member
I hope someone with a little more experience also answers, but I thought I'd share my team's experience...

The short answer is clearly "yes, it is possible". Since it understands C, it can certainly be made to understand something almost like C (where "almost like" might even mean "very different" Smile ). Is it easy? That depends on your viewpoint. As far as we could establish, there wasn't a way to write a plug-in-to-the-plug-in by just dropping in, for example, our own independently written flex/bison-type lexicon and grammar, but the practical application wasn't much different, unsurprisingly. That may relate to what our grammar required (though most was very very straightforward, some was more involved) rather than the mechanisms available to accomplish the tasks. Or, easier mechanisms may have just been hidden by our ignorance.

We downloaded the core CDT source, read a few instructions, found the core parser project where the standard C syntax was identified (keywords, tokens) and were able to glue our own symbols and lexical interpretations in and around the existing rules. As I said, the practical application of that work looked very much like what we would have had to write externally anyway. The extra work was finding where to put it without perturbing the existing parsing beyond our needs. In the end it still works for our special syntax as well as all our standard C and C++ projects. I think we touched 7 files:
org/eclipse/cdt/internal/core/parser/scanner/Token.java
org/eclipse/cdt/internal/core/parser/scanner/Lexer.java
org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
org/eclipse/cdt/core/parser/Keywords.java
org/eclipse/cdt/core/parser/IToken.java
org/eclipse/cdt/core/parser/IPreprocessorDirective.java

Would I want to do it again from scratch? Not myself, but it wasn't so onerous that I would discourage anyone else from trying it if they are so motivated. I highly recommend the getting started page (wiki.eclipse.org/Getting_started_with_CDT_development). It is short, but there are tips that would have shortcut a lot our early struggles with plug-in development in general. I also recommend the developer FAQs (wiki.eclipse.org/CDT/Developer/FAQ).

I can secretly (not so secretly now) wish that someone would step in and answer "you did it the hard way" and show me how to do it with a simpler "list of rules" as you originally asked; but, I thought it was worthwhile to let you know our experience regardless.
Previous Topic:#ifdef Symbol are not responding to -Dsymbol settings through Properties
Next Topic:eclipse c/c++ developer IDE c11 _Generic
Goto Forum:
  


Current Time: Tue Oct 15 00:16:18 GMT 2024

Powered by FUDForum. Page generated in 0.04660 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top