On Wed, Dec 5, 2018 at 12:44 AM Julia Lawall <[email protected]> wrote:
>
> > > In the example, p1 will store the position of n.  In the python rule, you
> > > can then access p1[0].current_element to get the name of the function in
> > > which n occurs.
> >
> > What do you mean by "position of n"?
>
> The code that n matches is in some file, within some function, at some
> line number, and at some column offset.  All of that information is
> collected in p1.

I'm having trouble figuring out how to access p1[0].  I tried this

// Use Python to clean up the string literals.
// Comments are still C-style though
@r depends on rules@
expression x;
position p1;
constant char[] c;
@@
NV_PRINTF2(x, c, ...)

@script:python s@
c << r.c;
c2;
p1 << r.p1;
@@
import re

print p1

But that gave me this error:

warning: r: metavariable p1 not used in the - or
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to