New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagating values back from Python script to SmPL rule with other metavariable type than “identifier” #86
Comments
|
I would appreciate another constructive comment for this issue. |
|
On Fri, 21 Oct 2016, Markus Elfring wrote:
The problem is here. When you construct the value of a metavariable in It's not clear at all why you want to put a term of the form Test 1 in a If you change the metavariable type of generation.text to identifier, If you want to leave the type of generation.text as constant, then in the coccinelle.text = cocci.make_expr("Test " + str(count)) But that will not work because Test 1, with the space in the middle, is julia
|
|
Thanks for your constructive explanation (which happened not together with the closing action for this clarification request).
Unfortunately, I was not really aware of this software detail before.
I can not completely understand this aspect at the moment.
I tried to achieve something different then.
My knowledge was incomplete for your SmPL programming interface. I tried to construct a string literal in the Python script.
May expressions contain extra white-space characters?
How can a literal be created including a desired space character? |
|
On Wed, 26 Oct 2016, Markus Elfring wrote:
It happened before. I responded to the email and then went to github and
Which part don't you understand?
A string literal would be a value that has quotes around it. You would
It depends on where they occur. foo bar is not a valid subterm of a C
See above. WIth " julia
|
I have tried another SmPL script variant out. enumerate_single_string_parameters-20161026-b.cocci: Test result: diff =
--- ../Probe/puts1.c
+++ /tmp/cocci-output-5978-0d97b7-puts1.c
@@ -2,7 +2,7 @@
int main(void)
{
- puts("first");
- puts("second");
+ puts("Test 1");
+ puts("Test 1");
return 0;
}This display looks only partly in the way that I expected. Should each matched function call get a string with a higher number in such an use case? |
|
On Wed, 26 Oct 2016, Markus Elfring wrote:
Does a string have a value? Yes. Therefore it is an expression.
For the SmPL rule, you could have figured this out yourself using the
No. The script is run exactly once per file, because it doesn't depend on julia
|
Thanks for another useful information. The following SmPL approach shows the desired data display finally. enumerate_single_string_parameters-20161026-c.cocci: Test result: diff =
--- ../Probe/puts1.c
+++ /tmp/cocci-output-9286-21b87a-puts1.c
@@ -2,7 +2,7 @@
int main(void)
{
- puts("first");
- puts("second");
+ puts("Test 1");
+ puts("Test 2");
return 0;
} |
I find that this information is also worth for further considerations after a desired transformation result was achieved by a test script.
|
|
On Wed, 26 Oct 2016, Markus Elfring wrote:
No idea what "its" refers to.
Yes.
No. If you want one call per possible value of pos, then you have to julia
|
The variable “pos” which was specified in the definition area of the SmPL rule “generation”.
Yes, of course. How do you think about to use a special syntax for this purpose so that such a dependency variant can be expressed independent from an assignment to a variable in a programming language script? |
|
On Thu, 27 Oct 2016, Markus Elfring wrote:
Why? To make Coccinelle hundreds of times more efficient? julia
|
|
The following thread was helpful while writing this script:
coccinelle/coccinelle#86
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20170718045540.16322-3-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
The following thread was helpful while writing this script:
coccinelle/coccinelle#86
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20170718045540.16322-3-f4bug@amsat.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
I tried the following small script out for the semantic patch language of the software combination “Coccinelle 1.0.6-00006-gc8025ac (OCaml 4.03.0)” on another tiny source code example.
enumerate_single_string_parameters-20161021.cocci:
puts1.c:
Test result:
The text was updated successfully, but these errors were encountered: