* [cocci] Fixing a parse error for a SmPL position variable constraint
@ 2024-02-13 13:08 Markus Elfring
2024-02-13 20:45 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2024-02-13 13:08 UTC (permalink / raw)
To: cocci
Hello,
I hope that you would like to take another look at a script variant
(like the following) for the semantic patch language also together with
the software combination “Coccinelle 1.1.1-00676-g99513ec1”.
@find@
position p1, p2;
statement s1, s2;
@@
if@p1 (...)
{
... when any
s1
s2
}
... when any
if@p2 (...)
{
... when any
s1
s2
}
@duplicated_code@
position find.p1, find.p2;
position pos != find.p2;
statement s1, s2;
@@
*if@p1@pos (...)
*{
... when any
* s1
* s2
*}
... when any
*if@p2 (...)
*{
... when any
* s1
* s2
*}
Temporary test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7z.cocci
…
meta: parse error:
File "show_same_statements7z.cocci", line 21, column 21, charpos = 226
around = 'p2',
whole content = position pos != find.p2;
Will more desirable analyses become possible by similar source code search approaches?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] Fixing a parse error for a SmPL position variable constraint
2024-02-13 13:08 [cocci] Fixing a parse error for a SmPL position variable constraint Markus Elfring
@ 2024-02-13 20:45 ` Julia Lawall
2024-02-14 17:38 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2024-02-13 20:45 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci
[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]
On Tue, 13 Feb 2024, Markus Elfring wrote:
> Hello,
>
> I hope that you would like to take another look at a script variant
> (like the following) for the semantic patch language also together with
> the software combination “Coccinelle 1.1.1-00676-g99513ec1”.
>
>
> @find@
> position p1, p2;
> statement s1, s2;
> @@
> if@p1 (...)
> {
> ... when any
> s1
> s2
> }
> ... when any
> if@p2 (...)
> {
> ... when any
> s1
> s2
> }
>
> @duplicated_code@
> position find.p1, find.p2;
> position pos != find.p2;
Try switching the above two lines.
julia
> statement s1, s2;
> @@
> *if@p1@pos (...)
> *{
> ... when any
> * s1
> * s2
> *}
> ... when any
> *if@p2 (...)
> *{
> ... when any
> * s1
> * s2
> *}
>
>
> Temporary test result:
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7z.cocci
> …
> meta: parse error:
> File "show_same_statements7z.cocci", line 21, column 21, charpos = 226
> around = 'p2',
> whole content = position pos != find.p2;
>
>
> Will more desirable analyses become possible by similar source code search approaches?
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] Fixing a parse error for a SmPL position variable constraint
2024-02-13 20:45 ` Julia Lawall
@ 2024-02-14 17:38 ` Markus Elfring
2024-02-14 17:49 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2024-02-14 17:38 UTC (permalink / raw)
To: Julia Lawall, cocci
>> position find.p1, find.p2;
>> position pos != find.p2;
>
> Try switching the above two lines.
Did you try this SmPL code adjustment out already in your test environment?
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7w-20240214.cocci
…
Variable find.p2 in duplicated_code cannot be used as both a position and a constraint
How does this error message (from the software combination “Coccinelle 1.1.1-00687-g0df3efff”)
fit to the discussed data processing intention?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] Fixing a parse error for a SmPL position variable constraint
2024-02-14 17:38 ` Markus Elfring
@ 2024-02-14 17:49 ` Julia Lawall
2024-02-14 18:08 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2024-02-14 17:49 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci
[-- Attachment #1: Type: text/plain, Size: 896 bytes --]
On Wed, 14 Feb 2024, Markus Elfring wrote:
> >> position find.p1, find.p2;
> >> position pos != find.p2;
> >
> > Try switching the above two lines.
>
> Did you try this SmPL code adjustment out already in your test environment?
>
>
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7w-20240214.cocci
> …
> Variable find.p2 in duplicated_code cannot be used as both a position and a constraint
OK, I guess it is not allowed. Actually, the semantics of positive an
negative uses of a position variable is quite different, so it seems that
it is not allowed to use both at once.
But it should be possible to use two position variables at the original
place.
julia
>
>
> How does this error message (from the software combination “Coccinelle 1.1.1-00687-g0df3efff”)
> fit to the discussed data processing intention?
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] Fixing a parse error for a SmPL position variable constraint
2024-02-14 17:49 ` Julia Lawall
@ 2024-02-14 18:08 ` Markus Elfring
0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2024-02-14 18:08 UTC (permalink / raw)
To: Julia Lawall, cocci
>> Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7w-20240214.cocci
>> …
>> Variable find.p2 in duplicated_code cannot be used as both a position and a constraint
>
> OK, I guess it is not allowed. Actually, the semantics of positive an
> negative uses of a position variable is quite different, so it seems that
> it is not allowed to use both at once.
Do we stumble on a target conflict here?
> But it should be possible to use two position variables at the original place.
Would you like to adjust affected software components accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-14 18:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 13:08 [cocci] Fixing a parse error for a SmPL position variable constraint Markus Elfring
2024-02-13 20:45 ` Julia Lawall
2024-02-14 17:38 ` Markus Elfring
2024-02-14 17:49 ` Julia Lawall
2024-02-14 18:08 ` 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).