cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Dummy rule for simplifying "depends on" clauses?
@ 2018-10-09 22:30 Timur Tabi
  2018-10-10  5:43 ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: Timur Tabi @ 2018-10-09 22:30 UTC (permalink / raw)
  To: cocci

In my cocci script, I have several rules, only one of which will
match.  I then have a bunch of other rules that should be run only if
one of the first rules is run.  So I have something like this:

@rule1@
@@
...

@rule2@
@@
...

@rule3@
@@
...

@depends on rule1 || rule2 || rule3@
...

@depends on rule1 || rule2 || rule3@
...

How can I create a dummy rule so that I can do something like this:

@rule1@
@@
...

@rule2@
@@
...

@rule3@
@@
...

@depends on rule1 || rule2 || rule3@
@dummy@
...

@depends on dummy@
...

@depends on dummy@
...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
  2018-10-09 22:30 [Cocci] Dummy rule for simplifying "depends on" clauses? Timur Tabi
@ 2018-10-10  5:43 ` Julia Lawall
       [not found]   ` <9e5331dd-ca41-845b-3852-29941fde1652@users.sourceforge.net>
  2018-10-10 15:32   ` Timur Tabi
  0 siblings, 2 replies; 8+ messages in thread
From: Julia Lawall @ 2018-10-10  5:43 UTC (permalink / raw)
  To: cocci



On Tue, 9 Oct 2018, Timur Tabi wrote:

> In my cocci script, I have several rules, only one of which will
> match.  I then have a bunch of other rules that should be run only if
> one of the first rules is run.  So I have something like this:
>
> @rule1@
> @@
> ...
>
> @rule2@
> @@
> ...
>
> @rule3@
> @@
> ...
>
> @depends on rule1 || rule2 || rule3@
> ...
>
> @depends on rule1 || rule2 || rule3@
> ...
>
> How can I create a dummy rule so that I can do something like this:
>
> @rule1@
> @@
> ...
>
> @rule2@
> @@
> ...
>
> @rule3@
> @@
> ...
>
> @depends on rule1 || rule2 || rule3@
> @dummy@
> ...

@dummy depends on rule1 || rule2 || rule3@

I guess that the problem is that you have to give dummy a pattern that
will always match.  Maybe something generic that matches a function would
do?  Or something generic that has the form of what is matched in rule1
rule2 and rule3.

julia


>
> @depends on dummy@
> ...
>
> @depends on dummy@
> ...
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
       [not found]   ` <9e5331dd-ca41-845b-3852-29941fde1652@users.sourceforge.net>
@ 2018-10-10  8:11     ` Julia Lawall
  2018-10-10 15:33       ` Timur Tabi
  0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2018-10-10  8:11 UTC (permalink / raw)
  To: cocci



On Wed, 10 Oct 2018, SF Markus Elfring wrote:

> > @dummy depends on rule1 || rule2 || rule3@
> >
> > I guess that the problem is that you have to give dummy a pattern
> > that will always match.
>
> Can a software extension make sense for the semantic patch language
> so that the specification of an always matching source code search
> pattern can be omitted?
>
> How do you think about an additional key word in the SmPL rule header?

I think that there are enough keywords already.  Perhaps allowing no
pattern could be permitted, but the problem seems rare.

julia

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
  2018-10-10  5:43 ` Julia Lawall
       [not found]   ` <9e5331dd-ca41-845b-3852-29941fde1652@users.sourceforge.net>
@ 2018-10-10 15:32   ` Timur Tabi
  2018-10-10 15:36     ` Julia Lawall
  1 sibling, 1 reply; 8+ messages in thread
From: Timur Tabi @ 2018-10-10 15:32 UTC (permalink / raw)
  To: cocci

On Wed, Oct 10, 2018 at 12:43 AM Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>
> On Tue, 9 Oct 2018, Timur Tabi wrote:
>
> > In my cocci script, I have several rules, only one of which will
> > match.  I then have a bunch of other rules that should be run only if
> > one of the first rules is run.  So I have something like this:
> >
> > @rule1@
> > @@
> > ...
> >
> > @rule2@
> > @@
> > ...
> >
> > @rule3@
> > @@
> > ...
> >
> > @depends on rule1 || rule2 || rule3@
> > ...
> >
> > @depends on rule1 || rule2 || rule3@
> > ...
> >
> > How can I create a dummy rule so that I can do something like this:
> >
> > @rule1@
> > @@
> > ...
> >
> > @rule2@
> > @@
> > ...
> >
> > @rule3@
> > @@
> > ...
> >
> > @depends on rule1 || rule2 || rule3@
> > @dummy@
> > ...
>
> @dummy depends on rule1 || rule2 || rule3@
>
> I guess that the problem is that you have to give dummy a pattern that
> will always match.  Maybe something generic that matches a function would
> do?  Or something generic that has the form of what is matched in rule1
> rule2 and rule3.

I can't seem to get it to work.  I came up with this:

@rules depends on rule1 || rule2 || rule3 || rule4 || rule5@
expression list x;
@@
-NV_PRINTF(x);
+NV_PRINTF(x);

But then I get an error later in the file:
File "/home/ttabi/nv_printf.cocci", line 112, column 0,  charpos = 2343
    around = '@', whole content = @r@
Fatal error: exception Lexer_cocci.Lexical("metavariables:
unrecognised symbol in metavariable_decl_token rule: @")

Line 112 is:

// Use Python to clean up the string literals.
// Comments are still C-style though
@depends on rules@
@r@             <--- line 112
constant char[] c;
expression list[n] es;
@@

I can email you the entire cocci file if you want.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
  2018-10-10  8:11     ` Julia Lawall
@ 2018-10-10 15:33       ` Timur Tabi
  0 siblings, 0 replies; 8+ messages in thread
From: Timur Tabi @ 2018-10-10 15:33 UTC (permalink / raw)
  To: cocci

On Wed, Oct 10, 2018 at 3:11 AM Julia Lawall <julia.lawall@lip6.fr> wrote:
> I think that there are enough keywords already.  Perhaps allowing no
> pattern could be permitted, but the problem seems rare.

Allowing no pattern would be nice, and would make compound booleans
easier to implement.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
  2018-10-10 15:32   ` Timur Tabi
@ 2018-10-10 15:36     ` Julia Lawall
  2018-10-10 16:02       ` Timur Tabi
  0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2018-10-10 15:36 UTC (permalink / raw)
  To: cocci

> Line 112 is:
>
> // Use Python to clean up the string literals.
> // Comments are still C-style though
> @depends on rules@
> @r@             <--- line 112
> constant char[] c;
> expression list[n] es;
> @@

You can't put multiple @@'s at the beginning of a rule.  This should be
just:

@r depends on rules@
...
@@

julia

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
  2018-10-10 15:36     ` Julia Lawall
@ 2018-10-10 16:02       ` Timur Tabi
  2018-10-10 16:10         ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: Timur Tabi @ 2018-10-10 16:02 UTC (permalink / raw)
  To: cocci

On Wed, Oct 10, 2018 at 10:37 AM Julia Lawall <julia.lawall@lip6.fr> wrote:
> You can't put multiple @@'s at the beginning of a rule.  This should be
> just:
>
> @r depends on rules@
> ...
> @@

I'll admit, I don't really understand any of the @ syntax.  I must
have copy/pasted too aggressively.  Thanks, it works now.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Cocci] Dummy rule for simplifying "depends on" clauses?
  2018-10-10 16:02       ` Timur Tabi
@ 2018-10-10 16:10         ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2018-10-10 16:10 UTC (permalink / raw)
  To: cocci



On Wed, 10 Oct 2018, Timur Tabi wrote:

> On Wed, Oct 10, 2018 at 10:37 AM Julia Lawall <julia.lawall@lip6.fr> wrote:
> > You can't put multiple @@'s at the beginning of a rule.  This should be
> > just:
> >
> > @r depends on rules@
> > ...
> > @@
>
> I'll admit, I don't really understand any of the @ syntax.  I must
> have copy/pasted too aggressively.  Thanks, it works now.

You have one @@ before the metavariables and one after.  The one before
can contain some other information.  The grammar is not completely
correct, but youcan get an idea of what you can put between the initial @@
on page 2 here: docs/manual/main_grammar.pdf

julia

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-10 16:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09 22:30 [Cocci] Dummy rule for simplifying "depends on" clauses? Timur Tabi
2018-10-10  5:43 ` Julia Lawall
     [not found]   ` <9e5331dd-ca41-845b-3852-29941fde1652@users.sourceforge.net>
2018-10-10  8:11     ` Julia Lawall
2018-10-10 15:33       ` Timur Tabi
2018-10-10 15:32   ` Timur Tabi
2018-10-10 15:36     ` Julia Lawall
2018-10-10 16:02       ` Timur Tabi
2018-10-10 16:10         ` Julia Lawall

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).