Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Question about CDT Parser behaviour and subsequent usage
Question about CDT Parser behaviour and subsequent usage [message #144608] Wed, 04 May 2005 15:54 Go to next message
Eclipse UserFriend
Originally posted by: fliao2.yahoo.ca

To the best of my understanding, after creating a CDT parser and calling
the parse() function as cited in the FAQ, an AST is generated with the
root pointed by the callback.compilationUnit. So then it's a process of
traversing the tree and extracting the information I need. Looking at the
IASTNode interface, I guessed that the lookup function returns all the
nodes, or a selective set of them. So as an example, I tried to get all
the classes in my program by something like:

IASTNode astNode = (IASTNode)callback.getCompilationUnit();
IASTNode.LookupKind[] luk = new IASTNode.LookupKind[1];
luk[0] = IASTNode.LookupKind.CLASSES;
IASTNode.ILookupResult lr = astNode.lookup(null, luk, astNode, null);

which threw an ASTNotImplementedException exception. For the lookup
function, I left "String prefix" and "IASTExpression functionParameters"
null since I didn't know what was supposed to go in there (is this the
problem?).

What am I doing wrong? And once I get the nodes, how would I differentiate
between say, a node that represents a variable as opposed to a node that
represents a function (looking at the IASTNode interface, nothing obvious
popped out). Any help is greatly appreciated.
Re: Question about CDT Parser behaviour and subsequent usage [message #144616 is a reply to message #144608] Thu, 05 May 2005 08:58 Go to previous message
Eclipse UserFriend
When you instantiate a parser/scanner you give it a ParserMode.
ParserMode.QUICK_PARSE is a faster implementation that does not provide
cross-reference/lookup information.
If you create an AST using QUICK_PARSE and you try and call a method that it
does not support, it will throw an ASTNotImplementedException.

"Felix" <fliao2@yahoo.ca> wrote in message
news:625179daa92c46d13e13028ddc208334$1@www.eclipse.org...
> To the best of my understanding, after creating a CDT parser and calling
> the parse() function as cited in the FAQ, an AST is generated with the
> root pointed by the callback.compilationUnit. So then it's a process of
> traversing the tree and extracting the information I need. Looking at the
> IASTNode interface, I guessed that the lookup function returns all the
> nodes, or a selective set of them. So as an example, I tried to get all
> the classes in my program by something like:
>
> IASTNode astNode = (IASTNode)callback.getCompilationUnit();
> IASTNode.LookupKind[] luk = new IASTNode.LookupKind[1];
> luk[0] = IASTNode.LookupKind.CLASSES;
> IASTNode.ILookupResult lr = astNode.lookup(null, luk, astNode, null);
>
> which threw an ASTNotImplementedException exception. For the lookup
> function, I left "String prefix" and "IASTExpression functionParameters"
> What am I doing wrong? And once I get the nodes, how would I differentiate
> between say, a node that represents a variable as opposed to a node that
> represents a function (looking at the IASTNode interface, nothing obvious
> popped out). Any help is greatly appreciated.

> null since I didn't know what was supposed to go in there (is this the
> problem?).
> >
Previous Topic:Capturing stderr
Next Topic:Outline View
Goto Forum:
  


Current Time: Wed May 07 17:27:21 EDT 2025

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

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

Back to the top