Skip to contentSkip to conversation

Automatic generation of SmPL rules by a script rule

Cocci SF Markus Elfring 2 participants 6 messages Jan 6, 2018

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 6 lines · 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

#2 lore raw
Quoted 2 lines

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?

Quoted 2 lines

Some support was added at one point for generating rules based on matches from other rules,

Such information sounds promising.

Quoted 2 lines

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.

Is it safer therefore to generate advanced SmPL script files by external software tools (at the moment)?

Regards,
Markus

#3 lore raw
Quoted 5 lines · SF Markus Elfring
Quoted 2 lines

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.

Quoted 5 lines
Quoted 4 lines

Some support was added at one point for generating rules based on matches from other rules,

Quoted 8 lines

Such information sounds promising.

Quoted 2 lines

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

Quoted 8 lines

Is it safer therefore to generate advanced SmPL script files by external software tools (at the moment)?

Regards,
Markus

#4 lore raw
Quoted 10 lines

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

I would prefer to use the available programming languages directly instead of starting the spatch program for such file generation.

Quoted 2 lines

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.

Would you like to continue the clarification for the topic ?Configuration or escaping of @ characters for embedded programming language scripts??
https://github.com/coccinelle/coccinelle/issues/36

Quoted 1 line

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?

Quoted 1 line

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?

Regards,
Markus

#5 lore raw
Quoted 30 lines · SF Markus Elfring
Quoted 10 lines

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

I would prefer to use the available programming languages directly instead of starting the spatch program for such file generation.

Quoted 2 lines

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.

Would you like to continue the clarification for the topic ?Configuration or escaping of @ characters for embedded programming language scripts??
https://github.com/coccinelle/coccinelle/issues/36

Quoted 1 line

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?

Quoted 4 lines
Quoted 1 line

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