> > I am trying to move local variable initialization of some variable to
> > first statement. …

I find such a source code transformation task also interesting.
But it points some software development challenges out also for the safe 
application
of the semantic patch language for this use case.


> put \(<+...a...+>\&E\) in place of E

How do you think about the following SmPL script variant?

@movement@
expression E;
identifier V1, V2, Vx;
statement S;
type T1, T2;
@@
 T1 V1;
 ... when any
 T2 V2
-      = \( <+... Vx ...+> \& E \)
 ;
 ... when any
     when != S
++ V2 = E;


elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci 
convert_variable_initialisation_to_assignment.cocci
…
plus: parse error:
  File "convert_variable_initialisation_to_assignment.cocci", line 10, column 
9, charpos = 117
  around = '\(',
  whole content = -      = \( <+... Vx ...+> \& E \)


I have tried another SmPL code variation out then.

-T2 V2 = \( <+... Vx ...+> \& E \)
+T2 V2
 ;

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci 
convert_variable_initialisation_to_assignment2.cocci
…
14: no available token to attach to


How will the software evolution be continued here?

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

Reply via email to