How to get a preprocess IASTTRanslationUnit [message #218513] |
Fri, 04 July 2008 01:54  |
Eclipse User |
|
|
|
Originally posted by: bpy1401.yahoo.fr
Hie,
I would like to parse a C projet for create a function call graph. My
problem is du to the fact that some functions are call by the mean of
macros like this example:
#define MACRO() CallAFunction();
case VALEUR:
MACRO()
if (.....)
For parsing this code, i am using this solution
@Override
protected void extractElements(ITranslationUnit translation) {
IResource resource = translation.getResource();
if (resource instanceof File) {
IASTTranslationUnit ast;
try {
ast = CDOM.getInstance().getTranslationUnit((IFile) resource,true);
FunctionNavigator navigator = new FunctionNavigator();
navigator.parseFile((CASTTranslationUnit) ast,functionCollector);
} catch (UnsupportedDialectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
System.out.println("I can't get the translation unit of " +
resource);
}
}
In this case, the parser generate a CASTProblemStatement because it
performs MACRO() as a function and it say that it is missing the semi
colon after this call.
For solve this problem, i think that the best way is to parse a preprocess
file. So my question is : What is the way for parse an preprocess c file.
Thanks for advance, i sorry for bad english
Best regards
|
|
|
|
Powered by
FUDForum. Page generated in 0.03345 seconds