* [cocci] Development challenges for handling of selected code repetitions (with SmPL)?
@ 2024-12-11 12:20 Markus Elfring
2024-12-11 13:05 ` Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2024-12-11 12:20 UTC (permalink / raw)
To: cocci
Hello,
I hope that some software development concerns can be clarified also together
with a script variant (like the following) for the semantic patch language.
@adjustment@
expression call;
expression * pointer;
statement action;
@@
if (pointer)
+{
action
<+... when != puts("Hello");
call(pointer);
...+>
+}
Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci move_call_into_if_branch2.cocci
…
12: no available token to attach to
A) Can any collateral evolution become possible according to the shown error message?
B) The information “Dots may be modified with a when clause,
indicating a pattern that should not occur anywhere within the matched sequence.”
is provided in the documentation.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/ff57802f2bd1ab1bca063810dbeacf6fdce08b95/docs/manual/cocci_syntax.tex#L1030
Such when clauses influence extra code which may eventually appear around
the searched code pattern.
But I would appreciate here if only selected repetitions of the specified code
will be taken into account for this use case.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/ff57802f2bd1ab1bca063810dbeacf6fdce08b95/docs/manual/cocci_syntax.tex#L797
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [cocci] Development challenges for handling of selected code repetitions (with SmPL)?
2024-12-11 12:20 [cocci] Development challenges for handling of selected code repetitions (with SmPL)? Markus Elfring
@ 2024-12-11 13:05 ` Julia Lawall
2024-12-11 13:20 ` Markus Elfring
2024-12-12 12:30 ` Markus Elfring
0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2024-12-11 13:05 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
On Wed, 11 Dec 2024, Markus Elfring wrote:
> Hello,
>
> I hope that some software development concerns can be clarified also together
> with a script variant (like the following) for the semantic patch language.
>
>
> @adjustment@
> expression call;
> expression * pointer;
> statement action;
> @@
> if (pointer)
> +{
> action
> <+... when != puts("Hello");
> call(pointer);
> ...+>
> +}
As noted, there is nothing to attach the } to. The ... goes to the end of
the function unless there is the when.
julia
>
>
> Questionable test result:
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci move_call_into_if_branch2.cocci
> …
> 12: no available token to attach to
>
>
> A) Can any collateral evolution become possible according to the shown error message?
>
> B) The information “Dots may be modified with a when clause,
> indicating a pattern that should not occur anywhere within the matched sequence.”
> is provided in the documentation.
> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/ff57802f2bd1ab1bca063810dbeacf6fdce08b95/docs/manual/cocci_syntax.tex#L1030
>
> Such when clauses influence extra code which may eventually appear around
> the searched code pattern.
> But I would appreciate here if only selected repetitions of the specified code
> will be taken into account for this use case.
> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/ff57802f2bd1ab1bca063810dbeacf6fdce08b95/docs/manual/cocci_syntax.tex#L797
>
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [cocci] Development challenges for handling of selected code repetitions (with SmPL)?
2024-12-11 13:05 ` Julia Lawall
@ 2024-12-11 13:20 ` Markus Elfring
2024-12-12 12:30 ` Markus Elfring
1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-12-11 13:20 UTC (permalink / raw)
To: Julia Lawall, cocci
>> @adjustment@
>> expression call;
>> expression * pointer;
>> statement action;
>> @@
>> if (pointer)
>> +{
>> action
>> <+... when != puts("Hello");
>> call(pointer);
>> ...+>
>> +}
>
> As noted, there is nothing to attach the } to.
I suggest to reconsider the software situation a bit more.
> The ... goes to the end of
> the function unless there is the when.
I might be looking for other variations of indicated system functionality.
* May any statement combinations (also behind an if check) be converted to
a compound statement (by adding extra curly brackets)?
* Can the possible code repetition ever be expressed in better ways
besides the usage of the SmPL ellipses so far?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [cocci] Development challenges for handling of selected code repetitions (with SmPL)?
2024-12-11 13:05 ` Julia Lawall
2024-12-11 13:20 ` Markus Elfring
@ 2024-12-12 12:30 ` Markus Elfring
1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-12-12 12:30 UTC (permalink / raw)
To: Julia Lawall, cocci
> As noted, there is nothing to attach the } to.
Would you like to help more to enable such a connection
even if code filter repetitions get involved?
> The ... goes to the end of
> the function unless there is the when.
Will such information influence any imaginations for possible software documentations?
I see further design options.
1. Additional notations for indicating code repetitions
2. It is demonstrated already how something can be selected by the means of when clauses.
Further settings can become relevant. They should probably not be confused with when clauses.
Thus I imagine that additional parameters can be specified behind a key word like “config”
for SmPL ellipses.
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-12 12:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 12:20 [cocci] Development challenges for handling of selected code repetitions (with SmPL)? Markus Elfring
2024-12-11 13:05 ` Julia Lawall
2024-12-11 13:20 ` Markus Elfring
2024-12-12 12:30 ` Markus Elfring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.