On Wed, 5 Dec 2018, Timur Tabi wrote:
> 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, ...)
You need to attach p1 to something. For example, you could say c@p1 or
x@p1 or )@p1
julia
>
> @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