How to fix parse errors for two SmPL scripts?
Hello,
I stumbled on undesirable behaviour once more also with the software combination “Coccinelle 1.2-00021-gac9af0e8”.
A)
@replacement@
constant char[] format1, format2;
expression check, input, target;
expression list el;
identifier x;
@@
-if (check)
- target += x(input, format1, el);
-else
- target += x(input, format2, el);
+target += x(input, (check) ? format1 : format2, el);
Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci use_ternary_operator3.cocci …
minus: parse error:
File "use_ternary_operator3.cocci", line 8, column 14, charpos = 144
around = 'x',
whole content = - target += x(input, format1, el);
B)
@replacement2@
expression check, context, target;
expression list inputs;
format list fl1, fl2;
identifier action;
@@
-if (check)
- target += action(context, "%@fl1@", inputs);
-else
- target += action(context, "%@fl2@", inputs);
+target += action(context, (check) ? "%@fl1@" : "%@fl2@", inputs);
Another questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci use_ternary_operator4.cocci …
minus: parse error:
File "use_ternary_operator4.cocci", line 8, column 14, charpos = 144
around = 'action',
whole content = - target += action(context, "%@fl1@", inputs);
How can corresponding software components be improved?
Regards,
Markus
Quoted 44 lines · Markus Elfring
Hello,
I stumbled on undesirable behaviour once more also with the software combination “Coccinelle 1.2-00021-gac9af0e8”.
A)
@replacement@
constant char[] format1, format2;
expression check, input, target;
expression list el;
identifier x;
@@(quoted diff) +1
-4-if (check) - target += x(input, format1, el); -else - target += x(input, format2, el); +target += x(input, (check) ? format1 : format2, el);Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciuse_ternary_operator3.cocci…
minus: parse error:
File "use_ternary_operator3.cocci", line 8, column 14, charpos = 144
around = 'x',
whole content = - target +=x(input, format1, el);B)
@replacement2@
expression check, context, target;
expression list inputs;
format list fl1, fl2;
identifier action;
@@(quoted diff) +1
-4-if (check) - target += action(context, "%@fl1@", inputs); -else - target += action(context, "%@fl2@", inputs); +target += action(context, (check) ? "%@fl1@" : "%@fl2@", inputs);
Quoted 7 lines
Another questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciuse_ternary_operator4.cocci…
minus: parse error:
File "use_ternary_operator4.cocci", line 8, column 14, charpos = 144
around = 'action',
whole content = - target +=action(context, "%@fl1@", inputs);
Thanks for the reports. I will look into it.
julia
Quoted 44 lines · Markus Elfring
Hello,
I stumbled on undesirable behaviour once more also with the software combination “Coccinelle 1.2-00021-gac9af0e8”.
A)
@replacement@
constant char[] format1, format2;
expression check, input, target;
expression list el;
identifier x;
@@(quoted diff) +1
-4-if (check) - target += x(input, format1, el); -else - target += x(input, format2, el); +target += x(input, (check) ? format1 : format2, el);Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciuse_ternary_operator3.cocci…
minus: parse error:
File "use_ternary_operator3.cocci", line 8, column 14, charpos = 144
around = 'x',
whole content = - target +=x(input, format1, el);B)
@replacement2@
expression check, context, target;
expression list inputs;
format list fl1, fl2;
identifier action;
@@(quoted diff) +1
-4-if (check) - target += action(context, "%@fl1@", inputs); -else - target += action(context, "%@fl2@", inputs); +target += action(context, (check) ? "%@fl1@" : "%@fl2@", inputs);
Quoted 7 lines
Another questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciuse_ternary_operator4.cocci…
minus: parse error:
File "use_ternary_operator4.cocci", line 8, column 14, charpos = 144
around = 'action',
whole content = - target +=action(context, "%@fl1@", inputs);
It's not the ideal solution, but in the meantime, both work fine if x and action are declared as expression rather than identifier.
julia
This problem has been fixed.
julia
Quoted 58 lines · Markus Elfring
Hello,
I stumbled on undesirable behaviour once more also with the software combination “Coccinelle 1.2-00021-gac9af0e8”.
A)
@replacement@
constant char[] format1, format2;
expression check, input, target;
expression list el;
identifier x;
@@(quoted diff) +1
-4-if (check) - target += x(input, format1, el); -else - target += x(input, format2, el); +target += x(input, (check) ? format1 : format2, el);Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciuse_ternary_operator3.cocci…
minus: parse error:
File "use_ternary_operator3.cocci", line 8, column 14, charpos = 144
around = 'x',
whole content = - target +=x(input, format1, el);B)
@replacement2@
expression check, context, target;
expression list inputs;
format list fl1, fl2;
identifier action;
@@(quoted diff) +1
-4-if (check) - target += action(context, "%@fl1@", inputs); -else - target += action(context, "%@fl2@", inputs); +target += action(context, (check) ? "%@fl1@" : "%@fl2@", inputs);Another questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciuse_ternary_operator4.cocci…
minus: parse error:
File "use_ternary_operator4.cocci", line 8, column 14, charpos = 144
around = 'action',
whole content = - target +=action(context, "%@fl1@", inputs);How can corresponding software components be improved?
Regards,
Markus