Skip to contentSkip to conversation

Checking the parsing for a specific SmPL disjunction

Cocci Markus Elfring 2 participants 3 messages Jun 25, 2020 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,

I know that the following SmPL script example gets accepted by the Coccinelle software.

@display@
expression x, y;
@@
*y = ... *(x) ...

I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00131-g675b9670”).

@display@
expression action, x, y;
@@
(
*y = ... *(x) ...
|
*action(..., x, ...)
)

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_pointer_dereferences3.cocci
init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
minus: parse error:
File "show_pointer_dereferences3.cocci", line 5, column 14, charpos = 54
around = '...',
whole content = *y = ... *(x) ...

Should such SmPL disjunctions work in the future?

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

#1 lore raw
Quoted 9 lines · Markus Elfring

Hello,

I know that the following SmPL script example gets accepted by the Coccinelle software.

@display@
expression x, y;
@@
*y = ... *(x) ...

This is probably not what you think. It is an assignment of y to a multiplication followed by some other code (the second ...).

julia

Quoted 23 lines

I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00131-g675b9670”).

@display@
expression action, x, y;
@@
(
*y = ... *(x) ...
|
*action(..., x, ...)
)

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_pointer_dereferences3.cocci
init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
minus: parse error:
File "show_pointer_dereferences3.cocci", line 5, column 14, charpos = 54
around = '...',
whole content = *y = ... *(x) ...

Quoted 9 lines

Should such SmPL disjunctions work in the future?

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

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 15 lines · Markus Elfring
Quoted 7 lines
Quoted 4 lines

@display@
expression x, y;
@@
*y = ... *(x) ...

This is probably not what you think. It is an assignment of y to a multiplication followed by some other code (the second ...).

I would interpret such a source code search approach in the way that a varying expression which contains one known (?) operation is assigned to an other target.

Can the ambiguity for the asterisk (before the parentheses) be avoided?

Quoted 8 lines

Should the following script variant for the semantic patch language match only code with pointer dereferences?

@display@
expression* x;
expression y;
@@
*y = ... *(x) ...

There is no ... like this at the expression level. You can say <+... *(x) ...+> if you want *(x) to be a subexpression of the right hand side.

julia

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

@display@
expression action, x, y;
@@
(
*y = ... *(x) ...
|
*action(..., x, ...)
)

Quoted 5 lines

May I expect that such SmPL disjunctions should also work?

Regards,
Markus

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