cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Using the same replacement for different source code
@ 2019-11-12 12:15 Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2019-11-12 12:15 UTC (permalink / raw)
  To: Coccinelle

Hello,

The following change specification gets accepted by the Coccinelle software.

@replacement@
expression x, y;
@@
(
-x + y
+compute(x, y)
|
-x * y
+compute(x, y)
)


I would appreciate if the specification of duplicate SmPL code
can be avoided also for such an use case.
Thus I have tried further code variants out for the semantic patch language.

@replacement@
expression x, y;
@@
(
-x + y
|
-x * y
)
+compute(x, y)


An error message is reported then.

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci replacement_for_two_cases2.cocci
…
9: no available token to attach to


@replacement@
expression x, y;
@@
- \( x + y \| x * y \)
+compute(x, y)

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci replacement_for_two_cases3.cocci
…
5: no available token to attach to


Can such a transformation approach ever work for similar source code?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [Cocci] Using the same replacement for different source code
@ 2019-11-12 12:15 Markus Elfring
  2019-11-12 13:24 ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2019-11-12 12:15 UTC (permalink / raw)
  To: Coccinelle

Hello,

The following change specification gets accepted by the Coccinelle software.

@replacement@
expression x, y;
@@
(
-x + y
+compute(x, y)
|
-x * y
+compute(x, y)
)


I would appreciate if the specification of duplicate SmPL code
can be avoided also for such an use case.
Thus I have tried further code variants out for the semantic patch language.

@replacement@
expression x, y;
@@
(
-x + y
|
-x * y
)
+compute(x, y)


An error message is reported then.

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci replacement_for_two_cases2.cocci
…
9: no available token to attach to


@replacement@
expression x, y;
@@
- \( x + y \| x * y \)
+compute(x, y)

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci replacement_for_two_cases3.cocci
…
5: no available token to attach to


Can such a transformation approach ever work for similar source code?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-11-14 16:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 12:15 [Cocci] Using the same replacement for different source code Markus Elfring
2019-11-12 12:15 Markus Elfring
2019-11-12 13:24 ` Julia Lawall
2019-11-14  7:12   ` Markus Elfring
2019-11-14 15:35     ` Julia Lawall
2019-11-14 16:12       ` Markus Elfring
2019-11-14 16:14         ` Julia Lawall
2019-11-14 16:34           ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).