cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Coccinelle <cocci@systeme.lip6.fr>
Subject: [Cocci] Using the same replacement for different source code
Date: Tue, 12 Nov 2019 13:15:11 +0100	[thread overview]
Message-ID: <59c2f820-af2b-030f-3f8e-1dc0fd23f4ba@web.de> (raw)

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

             reply	other threads:[~2019-11-12 12:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 12:15 Markus Elfring [this message]
2019-11-12 12:15 [Cocci] Using the same replacement for different source code 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59c2f820-af2b-030f-3f8e-1dc0fd23f4ba@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).