On Tue, 22 Jan 2019, Timur Tabi wrote:

> On Tue, Jan 22, 2019 at 12:44 PM Julia Lawall <[email protected]> wrote:
> >
> > You can use List.hd (Coccilib.files()) in OCaml.  I guess some similar
> > function exists for python.
>
> Can you expand on that?  I took at look at
> https://github.com/coccinelle/coccinelle/tree/master/python/coccilib,
> which I presume is the coccilib that you're talking about.  I don't
> see a files() anywhere in there.  I tried to instantiate the Location
> object:
>
> import coccilib
> cocci = coccilib.Location()
> print >>sys.stderr, cocci
>
> But that just gave me:
>
> Traceback (most recent call last):
>   File "<string>", line 44, in <module>
> AttributeError: 'module' object has no attribute 'Location'
> Error in Python script, line 130, file "/home/ttabi/nv_printf.cocci":
> Python failure
>
> The "import" statement didn't fail, so I presume that coccilib is a
> real library, but I think I'm calling it wrong.  My Python isn't good
> enough to read a library implementation and know how to use it.

It could be cocci.XXX and there is no need to import it.  But files
doesn't seem to exist.  I have asked for it to be added.  In the meantime,
perhas you can just record the file names earlier in the semantic patch,
before there is any transformation.

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to