Discussion:
[Cocci] Automatic generation of SmPL rules by a script rule
SF Markus Elfring
2018-01-06 16:57:07 UTC
Permalink
Hello,

Is it possible to generate additional rules for a specific execution environment
of the semantic patch language by an advanced script rule?

Can a special rule generation be avoided from external software tools?

Regards,
Markus
Julia Lawall
2018-01-06 17:01:59 UTC
Permalink
Post by SF Markus Elfring
Hello,
Is it possible to generate additional rules for a specific execution environment
of the semantic patch language by an advanced script rule?
Can a special rule generation be avoided from external software tools?
The simplest thing would be to just print the rule you want in a
python/ocaml script rule. Some support was added at one point for
generating rules based on matches from other rules, but that code has not
been maintained, and I don't think it is likely to be updated in the
future.

julia
Julia Lawall
2018-01-06 17:26:17 UTC
Permalink
Post by Julia Lawall
The simplest thing would be to just print the rule you want in a
python/ocaml script rule.
I would like to adjust a SmPL execution environment for special use cases somehow.
How would “printing” be useful here?
Well, I was thinking that you could eg make a script like:

@script:ocaml@
e << r.e;
@@

Printf.printf "@@\n";
Printf.printf "expression f;\n";
Printf.printf "@@\n\n";
Printf.printf "-f(%s);\n" e

But I'm not sure that the parser of script code would be happy with a @ in
the script code, so you would have to do some trick to get around that.
Post by Julia Lawall
Some support was added at one point for generating rules based on matches
from other rules,
Such information sounds promising.
Post by Julia Lawall
but that code has not been maintained, and I don't think it is likely
to be updated in the future.
I am curious if there are still any chances to revive corresponding
approaches.
I'm not interested in spending time on it in the foreseeable future. If
anyone else wants to, the code is there... Maybe you put something like
generated in the header of the semantic patch rule, like you might put
script:ocaml.

julia
Is it safer therefore to generate advanced SmPL script files by external
software tools (at the moment)?
Regards,
Markus
Julia Lawall
2018-01-06 17:59:20 UTC
Permalink
Post by Julia Lawall
@script:ocaml@
e << r.e;
@@
Printf.printf "expression f;\n";
Printf.printf "-f(%s);\n" e
I would prefer to use the available programming languages directly
instead of starting the spatch program for such file generation.
Post by Julia Lawall
the script code, so you would have to do some trick to get around that.
Would you like to continue the clarification for the topic “Configuration
https://github.com/coccinelle/coccinelle/issues/36
Post by Julia Lawall
I'm not interested in spending time on it in the foreseeable future.
But I imagine that I would like to show related update suggestions
around SmPL scripts because of other approaches then.
Will alternatives become useful?
Post by Julia Lawall
If anyone else wants to, the code is there...
Would you like to point any specific source files out for the current
intermediate development status?
Files that contain the word Generated. The file
parsing_c/unparse_hrule.ml.

julia

Loading...