Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » How to get a preprocess IASTTRanslationUnit
How to get a preprocess IASTTRanslationUnit [message #218513] Fri, 04 July 2008 01:54 Go to next message
Eclipse UserFriend
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
Re: How to get a preprocess IASTTRanslationUnit [message #219001 is a reply to message #218513] Wed, 09 July 2008 10:02 Go to previous message
Eclipse UserFriend
Originally posted by: toulemont_florian.hotmail.com

#define MACRO() CallAFunction();
case VALEUR:
MACRO()
if (.....) For parsing this code, i am using this solution

You get a CASTProblemStatement certainely because the source code that
you test may be false, and for me there certainly miss a semilocon at the
end of MACRO()
You should try to compile your code and see errors, and when you wont have
any error, then parse it, your java code seems to be good.

For preprocessor, try with the AST => IASTPreprocessorStatement and his
interfaces =>
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. cdt.doc.isv/reference/api/org/eclipse/cdt/core/model/package -summary.html
Previous Topic:Global Toolchain Settings
Next Topic:Dont want to run autogen.sh everytime
Goto Forum:
  


Current Time: Tue Jul 22 12:09:03 EDT 2025

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

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

Back to the top