Skip to contentSkip to conversation

Using inherited input data for SmPL script rules?

cocci Markus Elfring 2 participants 5 messages Feb 23, 2024

lore
Share & tools
lore
#0 lore raw

Hello,

I tried another script variant out for the semantic patch language also together with the software combination “Coccinelle 1.1.1-00739-g68c580f1”.

@first_search@
identifier id;
@@
my_work(id);

@second_search@
identifier first_search.id;
@@
my_log(id, ...);

@script:python selection@
x << second_search.id;
@@
if x == "apples":
cocci.include_match(False)

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci test-inherited_input_for_script_rule.cocci …
scriptmeta: semantic error: bad rule second_search or bad variable id
File "test-inherited_input_for_script_rule.cocci", line 12, column 21, charpos = 161
around = ';',
whole content = x << second_search.id;

Can the application of input data become supported for SmPL script rules even if such data would be inherited by longer SmPL rule chains?

See also:
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/68c580f1f1abf9979d591371e5b2e474f97dac90/docs/manual/cocci_syntax.tex#L655

Regards,
Markus

#1 lore raw
Quoted 23 lines · Markus Elfring

Hello,

I tried another script variant out for the semantic patch language also together with the software combination “Coccinelle 1.1.1-00739-g68c580f1”.

@first_search@
identifier id;
@@
my_work(id);

@second_search@
identifier first_search.id;
@@
my_log(id, ...);

@script:python selection@
x << second_search.id;
@@
if x == "apples":
cocci.include_match(False)

Quoted 6 lines

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci test-inherited_input_for_script_rule.cocci …
scriptmeta: semantic error: bad rule second_search or bad variable id
File "test-inherited_input_for_script_rule.cocci", line 12, column 21, charpos = 161
around = ';',
whole content = x << second_search.id;

You should have inherited it from where it was defined, ie first_search.

julia

Quoted 11 lines

Can the application of input data become supported for SmPL script rules even if such data would be inherited by longer SmPL rule chains?

See also:
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/68c580f1f1abf9979d591371e5b2e474f97dac90/docs/manual/cocci_syntax.tex#L655

Regards,
Markus

#2 lore raw
Quoted 8 lines
Quoted 6 lines

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci test-inherited_input_for_script_rule.cocci …
scriptmeta: semantic error: bad rule second_search or bad variable id
File "test-inherited_input_for_script_rule.cocci", line 12, column 21, charpos = 161
around = ';',
whole content = x << second_search.id;

You should have inherited it from where it was defined, ie first_search.

…

Quoted 2 lines
Quoted 2 lines

Can the application of input data become supported for SmPL script rules even if such data would be inherited by longer SmPL rule chains?

I am looking for extended data processing support.

The second rule could also specify additional SmPL constraints, couldn't it?

May SmPL script rules depend then on search results from a previous rule which references also inherited metavariables?

Regards,
Markus

#3 lore raw
Quoted 8 lines · Markus Elfring
Quoted 8 lines
Quoted 6 lines

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci test-inherited_input_for_script_rule.cocci …
scriptmeta: semantic error: bad rule second_search or bad variable id
File "test-inherited_input_for_script_rule.cocci", line 12, column 21, charpos = 161
around = ';',
whole content = x << second_search.id;

You should have inherited it from where it was defined, ie first_search.

Quoted 8 lines

…

Quoted 2 lines
Quoted 2 lines

Can the application of input data become supported for SmPL script rules even if such data would be inherited by longer SmPL rule chains?

I am looking for extended data processing support.

The second rule could also specify additional SmPL constraints, couldn't it?

I don't know.

Quoted 2 lines

May SmPL script rules depend then on search results from a previous rule which references also inherited metavariables?

No.

If you want to do that, just make another metavariable. You can write i1@i2 to make two metavariables match at the same place.

julia

#4 lore raw
Quoted 4 lines
Quoted 2 lines

May SmPL script rules depend then on search results from a previous rule which references also inherited metavariables?

No.

I hope that such a software limitation can be adjusted under other circumstances.

Regards,
Markus