* [Cocci] Easy search for elements besides binary operators with SmPL
@ 2017-05-12 13:09 SF Markus Elfring
[not found] ` <alpine.DEB.2.20.1705122137090.3416@hadrien>
0 siblings, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2017-05-12 13:09 UTC (permalink / raw)
To: cocci
Hello,
I would like to check also the application of elements which are used together
with binary operators like the following.
@find@
expression target;
identifier action;
@@
target = action(...,
...
* | __GFP_NOFAIL
| ...,
...);
elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt drivers/md/dm-region-hash.c ~/Projekte/Coccinelle/janitor/show_use_of_nofail1.cocci
?
minus: parse error:
File "/home/elfring/Projekte/Coccinelle/janitor/show_use_of_nofail1.cocci", line 6, column 17, charpos = 87
around = '...',
whole content = ...
How should I improve my search pattern?
A metavariable can already be used for the search of a function parameter at an
undetermined position within a bigger list. Can similar functionality work also
for binary operators?
Regards,
Markus
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <alpine.DEB.2.20.1705122137090.3416@hadrien>]
* [Cocci] Easy search for elements besides binary operators with SmPL [not found] ` <alpine.DEB.2.20.1705122137090.3416@hadrien> @ 2017-05-12 14:42 ` SF Markus Elfring 2017-05-12 14:49 ` Julia Lawall 0 siblings, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-05-12 14:42 UTC (permalink / raw) To: cocci > Maybe put parentheses around the second argument. An isomorphism will > drop them and you will avoid whatever parsing issue is being encountered. I do not observe a desired improvement after such a SmPL code adjustment. @find@ expression target; identifier action; @@ target = action(..., ... * | __GFP_NOFAIL | (...), ...); The Coccinelle software does also not like a reduced script variant so far. @find@ expression target; identifier action; @@ target = action(..., ... * | __GFP_NOFAIL ); elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt drivers/md/dm-region-hash.c ~/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci ? minus: parse error: File "/home/elfring/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci", line 6, column 17, charpos = 87 around = '...', whole content = ... Do you get further ideas? Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Easy search for elements besides binary operators with SmPL 2017-05-12 14:42 ` SF Markus Elfring @ 2017-05-12 14:49 ` Julia Lawall 2017-05-12 15:02 ` SF Markus Elfring 0 siblings, 1 reply; 6+ messages in thread From: Julia Lawall @ 2017-05-12 14:49 UTC (permalink / raw) To: cocci On Fri, 12 May 2017, SF Markus Elfring wrote: > > Maybe put parentheses around the second argument. An isomorphism will > > drop them and you will avoid whatever parsing issue is being encountered. > > I do not observe a desired improvement after such a SmPL code adjustment. Your change is not what I suggested either. The second argument starts to the right of one comma and ends to the left of the next one. julia > @find@ > expression target; > identifier action; > @@ > target = action(..., > ... > * | __GFP_NOFAIL > | (...), > ...); > > > > The Coccinelle software does also not like a reduced script variant so far. > > @find@ > expression target; > identifier action; > @@ > target = action(..., > ... > * | __GFP_NOFAIL > ); > > > elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt drivers/md/dm-region-hash.c ~/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci > ? > minus: parse error: > File "/home/elfring/Projekte/Coccinelle/janitor/show_use_of_nofail_as_last_option1.cocci", line 6, column 17, charpos = 87 > around = '...', > whole content = ... > > > Do you get further ideas? > > Regards, > Markus > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Easy search for elements besides binary operators with SmPL 2017-05-12 14:49 ` Julia Lawall @ 2017-05-12 15:02 ` SF Markus Elfring 2017-05-12 15:15 ` Julia Lawall 0 siblings, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-05-12 15:02 UTC (permalink / raw) To: cocci >>> Maybe put parentheses around the second argument. An isomorphism will >>> drop them and you will avoid whatever parsing issue is being encountered. >> >> I do not observe a desired improvement after such a SmPL code adjustment. > > Your change is not what I suggested either. The second argument starts to > the right of one comma and ends to the left of the next one. I interpreted the ?second one? as belonging to the ellipsis in the binary operator specification (for a moment). Now I observe that the following SmPL script variants work as desired in principle. @find_last_option@ expression target; identifier action; @@ target = action(..., ( ... * | __GFP_NOFAIL ) ); @find_flag@ expression target; identifier action; @@ target = action(..., ( ... * | __GFP_NOFAIL | ... ), ...); I find it just strange that extra parentheses are needed in such an use case at the moment. Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Easy search for elements besides binary operators with SmPL 2017-05-12 15:02 ` SF Markus Elfring @ 2017-05-12 15:15 ` Julia Lawall 2017-05-12 15:38 ` SF Markus Elfring 0 siblings, 1 reply; 6+ messages in thread From: Julia Lawall @ 2017-05-12 15:15 UTC (permalink / raw) To: cocci On Fri, 12 May 2017, SF Markus Elfring wrote: > >>> Maybe put parentheses around the second argument. An isomorphism will > >>> drop them and you will avoid whatever parsing issue is being encountered. > >> > >> I do not observe a desired improvement after such a SmPL code adjustment. > > > > Your change is not what I suggested either. The second argument starts to > > the right of one comma and ends to the left of the next one. > > I interpreted the ?second one? as belonging to the ellipsis in the binary > operator specification (for a moment). > > Now I observe that the following SmPL script variants work as desired > in principle. > > @find_last_option@ > expression target; > identifier action; > @@ > target = action(..., > ( ... > * | __GFP_NOFAIL > ) > ); > > > @find_flag@ > expression target; > identifier action; > @@ > target = action(..., > ( ... > * | __GFP_NOFAIL > | ... > ), > ...); > > > I find it just strange that extra parentheses are needed in such an use case > at the moment. ... is used in a number of contexts in SmPL, and sometimes its use has to be restricted to avoid parsing ambiguities. I'm a bit surprised also that it is a problem in this case. julia ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Easy search for elements besides binary operators with SmPL 2017-05-12 15:15 ` Julia Lawall @ 2017-05-12 15:38 ` SF Markus Elfring 0 siblings, 0 replies; 6+ messages in thread From: SF Markus Elfring @ 2017-05-12 15:38 UTC (permalink / raw) To: cocci >> I find it just strange that extra parentheses are needed in such an use case >> at the moment. > > ... is used in a number of contexts in SmPL, and sometimes its use has to > be restricted to avoid parsing ambiguities. I tried to use extra parentheses for other source code search patterns. I left them ?accidentally? out with undesired consequences this time. > I'm a bit surprised also that it is a problem in this case. I find such a feedback interesting then if it will influence corresponding software evolution. Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-12 15:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 13:09 [Cocci] Easy search for elements besides binary operators with SmPL SF Markus Elfring
[not found] ` <alpine.DEB.2.20.1705122137090.3416@hadrien>
2017-05-12 14:42 ` SF Markus Elfring
2017-05-12 14:49 ` Julia Lawall
2017-05-12 15:02 ` SF Markus Elfring
2017-05-12 15:15 ` Julia Lawall
2017-05-12 15:38 ` SF 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.