[antlr-interest] How to use ANTLR to find function pointers

amol Bhagavat amol_bhagavat at yahoo.co.uk
Wed Jul 18 19:02:34 PDT 2007


Ok if i get a proper c grammer, i can easily find out function pointers in that ...
  Is it possible to find the different assignments done to function pointers in source code?
  
Johannes Luber <jaluber at gmx.de> wrote:
  amol Bhagavat wrote:
> Hi,
> 
> I am developing a tool where i need to parse a c project code and find
> out all occurances of function pointers along with all assignments. Also
> i need to create a output where i can specify the files where
> the function pointers and functions are defined.While finding function
> pointers i also need to aware of variable scope, since there can be
> occurance of local variable with same name.
> I am very new to ANTLR ...
> Please let me know can i use ANTLR ? how i can use it?
> My intention is to find out all the possibilities of function call
> through a function pointer.
> 
> Thanks in advance...
> 
> Regards,
> Amol

At first, I would recommend to buy the ANTLR book
. It is really
helpful, especially, because it contains an example, on which you can
build upon. Alternatively you can look at the source code of the CMinus
example on the same website. That's for understanding only. You'd need a
C grammar, too. Maybe it has been posted one on the grammar site
(somewhere on antlr.org).

On your special I would then generate an AST containing only the
functions and function pointers and then a tree grammar, which can
output the required information. Sorry I can't be more specific at this
stage!

Best regards,
Johannes Luber


       
---------------------------------
 Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your freeaccount today.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070719/c442a1a9/attachment.html 


More information about the antlr-interest mailing list