[AST] Distinguishing between type and variable declaration [message #761326] |
Tue, 06 December 2011 09:47 |
Olivier Parisy Messages: 15 Registered: June 2011 |
Junior Member |
|
|
Hi,
Let us say I am parsing the following constructs using CDT:
struct str {
int a,b;
};
struct str var1;
typedef struct str type1;
In the resulting AST, I see little difference between the subtrees associated with the last two lines:
IASTSimpleDeclatation
ICASTElaboratedTypeSpecifier
IASTDeclarator
But their meanings are different: one line declares a variable var1, while the other defines an aliased type type1.
Is there a way to distinguish between those constructs using the AST (perhaps through some property)? Or do I have to manually scan the tokens associated with the DeclSpecifier (by using getSyntax), to search for a "typedef" keyword?
In the same vein, do have have to use the tokens to distinguish between a struct and an union when I meet an ICASTCompositeTypeSpecifier?
I know the C-Model is of a higher level than the AST, but I need to parse the full code and not only types, so I would like to stick to the AST as much as possible.
Regards,
Olivier.
|
|
|
Powered by
FUDForum. Page generated in 0.03064 seconds