|KDM Model Creation from C++ code? [message #990924]
||Fri, 14 December 2012 17:27
| Bill White
Registered: September 2012
I'm trying to understand a big C++ program. I'm wondering if I can build a tool which parses the C++ and generates an ecore model. I'm pretty sure I can parse the C++, using either clang or a commercial C++ parser I have available. But I'm not sure what the format the model should take.|
I could generate an ecore model directly, using what seems to be the ecore schema. It's not clear to me if there is a specification for the serialized from of ecore models, and this seems somewhat dubious. I know that Modisco has no C++ discoverer, but it has a KDM discoverer, and that KDM is some very abstract knowledge representation scheme. So maybe it would be possible to traverse the C++ code and write a KDM model, and then extract that with Modisco. But I'm not sure what the steps to create this would be. Clang makes is pretty easy to parse and process the C++, and that seems like it would be the easy part.
I don't need to generate C++ or Java code, or translate it. I just want to
be able to understand the C++ code.
So, I guess my questions are:
- Is there documentation for the serialized format of an ecore model? Could I just write an XML file with the model? If I did that, would I need Modisco at all?
- Does it make sense to write a KDM model, then use Modisco's KDM discoverer to extract the ecore model. Is there something which will do this?
- Does it make even more sense to create a simple XSD schema for my simple-minded C++ model, and dump the C++ data model to my XML schema, then use the EMF schema reading tools somehow (unknown to me) to turn this into an ecore model. I'd have to specify the translation from my XSD schema to ecore, but presumably this is well understood.
Thanks. Hope this is not too confusing.
|Re: KDM Model Creation from C++ code? [message #991347 is a reply to message #990924]
||Tue, 18 December 2012 10:57
| Hugo Bruneliere
Registered: July 2009
Thanks for looking to our MoDisco project.
I encourage you to take a deeper look into the MoDisco Reference Documentation in order to have a more complete vision of what is provided.
If your purpose is about (better) understanding C++ code by getting a model out of it, you can get inspired by the already provided support for Java.
The MoDisco Java Discoverer basically allows automatically obtaining a Java model (which conforms to a Java metamodel) out of any Java project.
Technically, this generic Java discoverer has been implemented by using the Eclipse JDT features (notably the provided AST).
In addition to the Java Model Discoverer, transformations from the Java metamodel to the KDM metamodel and then to the UML metamodel have also bee implemented allowing to also produce corresponding models.
Finally, all these models can be navigated efficiently thanks to the generic MoDisco Model Browser and related Customization features.
Following this approach, you could provide exactly the same type of support for C++.
Notably, there is the Eclipse CDT project that could be used as a base to implement a C++ Model Discoverer.
I hope this helps.
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
Powered by FUDForum
. Page generated in 0.01594 seconds