Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] RE: CDT Parser

Hi Matt,
CDT is an open project and discussions must be lead in the public, please direct use the cdt-dev list.
 
Regarding your question:
CDT uses a custom preprocessor (CPreprocessor) and stores information about macro expansions. IASTTranslationUnit provides acess to both the syntax-tree (of the preprocessed code) and to preprocessing statements. Furthermore, for each node in the AST you can determine it's origin via IASTNode.getNodeLocations(): A node location can either be a file-location or a macro-expansion location. I pretty much reworked the location concept in CDT 5.0, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202459
 
To search for macro expansions via an offset in the file, you can use IASTTranslationUnit.getNodeSelector(). There may be missing functionality in the IASTNodeSelector class, but that could be added easily.
 
Markus. 
 


From: pingu219@xxxxxxxxx [mailto:pingu219@xxxxxxxxx]
Sent: Monday, April 21, 2008 4:53 AM
To: Schorn, Markus
Subject: CDT Parser

Hi Markus,

I was wondering if I could ask you a few questions regarding Eclipse's CDT parser. The biggest problem I've encountered so far trying to build a graphical refactoring tool for C is C's preprocessor directives as it's not really ideal to try to refactor already preprocessed code yet at the same time the preprocessor directives aren't legal, syntactic C code. How does the CDT parser handle this, does it have its own custom preprocessor which preserves all the preprocessor directives information in its own internal structure? That way the user doesn't see a different set of already-preprocessed code and the program is able to check to see if a macro definition may interfere with a refactoring or vice versa. Thanks alot in advance and hope to hear from you whenever you're free.

Cheers,
Matt

Back to the top