Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » [AST] Distinguishing between type and variable declaration(AST Interpretation)
[AST] Distinguishing between type and variable declaration [message #761326] Tue, 06 December 2011 09:47
Olivier Parisy is currently offline Olivier ParisyFriend
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.
Previous Topic:Eclipse won't find MinGW Includes
Next Topic:Timing issues with cross-debug and cross-run
Goto Forum:
  


Current Time: Sat Apr 20 03:07:07 GMT 2024

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

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

Back to the top