On Wed, Mar 9, 2011 at 10:09 AM, Julia Lawall <[email protected]> wrote: > The solution is not to actually perform any transformations on the > subexpressions a and b. The example works fine with the following > semantic patch: > > @ oper_add @ > expression a, b; > @@ > - oper_add( > a > - , > + + > b > - ) > > The only small unfortunate bit is that the pretty printing is not very > nice. It doesn't realize that + is a binary operator, and so there is no > space before it, although there is a space after it. It should be > possible to fix this.
Thanks for the hint here- I ended up finding something that did work closer to expected and formats it relatively nicely as it seems to recognize the binary operator: @@ expression a, b; @@ - oper_add(a, + a + b - ) One more question. I'm looking now at a follow-on transform to the above to simplify things more, and this works for the simple case, but not the follow-on cases. a = a + 1; --> a+= 1; b = b + a + 1 --> does not get transformed. expression a, b; @@ - a = ((a) + (b)); + a += b; -Dan _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
