On Mon, 13 Jan 2020, Timur Tabi wrote:

> On Mon, Jan 13, 2020 at 4:33 PM Julia Lawall <[email protected]> wrote:
> >
> > Sorry, I don't follow what you are trying to do here.  Could you send an
> > example of the desired before after C code?  I see what you have above,
> > but I don't see the connection to the rule you have tried to write.
> >
> > I have the feeling that you will want to use some python code to do
> > something with the ##s, but I'm not sure.
>
> I'm hoping to avoid Python.
>
> I'm basically trying to recreate the ## feature of C macros.  For
> example, given:
>
> #define MACRO(a, b)   a##b
>
> I'm looking for a cocci script that replaces
>
>    x = 1 << MACRO(HELLO, _THERE);
>
> with
>
>   x = 1 << HELLO_THERE;

It might be possible to use

@@
identifier a,b;
fresh identifier x = a ## "_" ## b;
@@

- MACRO(a,b)
+ x

julia

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

Reply via email to