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

Johannes Luber jaluber at gmx.de
Wed Jul 18 01:43:13 PDT 2007


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
<http://pragmaticprogrammer.com/titles/tpantlr/index.html>. 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


More information about the antlr-interest mailing list