[antlr-interest] How to use ANTLR to find function pointers
Johannes Luber
jaluber at gmx.de
Thu Jul 19 03:16:50 PDT 2007
amol Bhagavat wrote:
> 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?
Well, once you have the knowledge that variable X is a function pointer,
you need only to track the use of the variable. That can be done by a
simple lookup in assignments, etc. Keep in mind that you can not only
assign a function to a pointer variable, but other pointer variables as
well. Or even casting a function pointer to an int. Nasty stuff.
Best regards,
Johannes Luber
>
> */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 free account today
> <http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html>.
>
More information about the antlr-interest
mailing list