[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.cdt] Understanding the DOM AST

Hello,

as mentioned before im trying to parse some C++ classes and im not sure if my current solution is good/correct.

What i want to achieve is to get all public class declarations (i.e. their names) and template classes (i.e. their names) for a particular namespace (no inner classes) and all public method declarations for these classes.


Right now the only way i have found is to visit all IASTNames and gather the required information from their bindings (as shown below).


public int visit(IASTName name) {
  IBinding binding = name.resolveBinding();
  if (name.isDefinition() && binding instanceof ICPPClassType) {
    ICPPClassType type = (ICPPClassType) binding;
    if(type.getKey() == ICPPClassType.k_class)
      ICPPMethod[] methods = type.getDeclaredMethods();
  }
}


So right now i get the required information from the semantic IBinding hirarchy. However i would expected that i can get the information from the syntactic IASTNode hirarchy as well since i think im just searching some syntactic structure (for instance by visiting IASTDeclarations, but an IASTDeclaration seems not to provide usefull methods for this).


Hence my question is wether my current approach is the right one for my problem or if there is a better solution.

Additionally is there any documentation or paper describing the AST architecture (looking at other posts i think not) or maybe extern papers which describe C++ AST implementations similar to the CDT DOM?

thanks in advance,
David