cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Specifying that an expression is a string constant?
@ 2019-02-19 20:12 Timur Tabi
  2019-02-19 21:48 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Timur Tabi @ 2019-02-19 20:12 UTC (permalink / raw)
  To: cocci

The following rule fails with an error on the last line:

@rule3@
expression x, y, z;
@@
-DBG_PRINT_STRING_VALUE(x, y, z);
+NV_PRINTF2(x, y "0x%x\n", z);

Presumably, cocci doesn't know that "y" is a string constant and so
the resulting expression is valid.  I'm guessing that I need to
specify that "y" is a string constant, but even after reading
http://coccinelle.lip6.fr/docs/main_grammar.html, I can't figure out
what that could be.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Specifying that an expression is a string constant?
  2019-02-19 20:12 [Cocci] Specifying that an expression is a string constant? Timur Tabi
@ 2019-02-19 21:48 ` Julia Lawall
  2019-02-20 15:43   ` Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2019-02-19 21:48 UTC (permalink / raw)
  To: Timur Tabi; +Cc: cocci



On Tue, 19 Feb 2019, Timur Tabi wrote:

> The following rule fails with an error on the last line:
>
> @rule3@
> expression x, y, z;
> @@
> -DBG_PRINT_STRING_VALUE(x, y, z);
> +NV_PRINTF2(x, y "0x%x\n", z);
>
> Presumably, cocci doesn't know that "y" is a string constant and so
> the resulting expression is valid.  I'm guessing that I need to
> specify that "y" is a string constant, but even after reading
> http://coccinelle.lip6.fr/docs/main_grammar.html, I can't figure out
> what that could be.

SmPL doesn't support this.  The only solution I can see is to use python
code to construct an identifier variable that actually has the form of y
"0x%x\n".  You can see examples of how to use python to initialize
identifier metavariables in demos/pythontococci.cocci

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Specifying that an expression is a string constant?
  2019-02-19 21:48 ` Julia Lawall
@ 2019-02-20 15:43   ` Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2019-02-20 15:43 UTC (permalink / raw)
  To: cocci; +Cc: Timur Tabi

>> The following rule fails with an error on the last line:
>>
>> @rule3@
>> expression x, y, z;
>> @@
>> -DBG_PRINT_STRING_VALUE(x, y, z);
>> +NV_PRINTF2(x, y "0x%x\n", z);
>>
>> Presumably, cocci doesn't know that "y" is a string constant and so
>> the resulting expression is valid.  I'm guessing that I need to
>> specify that "y" is a string constant, but even after reading
>> http://coccinelle.lip6.fr/docs/main_grammar.html, I can't figure out
>> what that could be.
>
> SmPL doesn't support this.

Will any users (or contributors) become motivated enough to adjust involved
software limitations also for wider applications of the semantic patch language?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, other threads:[~2019-02-20 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 20:12 [Cocci] Specifying that an expression is a string constant? Timur Tabi
2019-02-19 21:48 ` Julia Lawall
2019-02-20 15:43   ` 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).