On Wed, 16 Aug 2017, SF Markus Elfring wrote:
> >> Can the search for duplicated source code be improved by the means of the
> >> semantic patch language?
> >
> > For two statements at least you could do:
> >
> > (
> > {
> > s1
> > s2
> > ...
> > }
> > &
> > {
> > sl
> > }
> > )
>
> I constructed another SmPL script based on this suggestion as follows.
>
> @duplicated_code@
> identifier work;
> statement s1, s2;
> statement list sl;
> type T;
> @@
> T work(...)
> {
> ... when any
> *if ((...) < 0) {
> * s1
> * s2
> ...
> *}
> &{
> sl
> }
> ...
> *if ((...) < 0) {
> * s1
> * s2
> ...
> *}
> &{
> sl
> }
> ...
> }
>
>
> Unfortunately, the software version “1.0.6-00186-g0acd38ee” does not like this
> SmPL specification.
The syntax is exactly the same as that of a disjunction
(
&
)
There are no outer parentheses in column 0 in your specification.
julia
>
> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --parse-cocci
> show_same_statements2.cocci
> …
> minus: parse error:
> File "show_same_statements2.cocci", line 15, column 0, charpos = 156
> around = '&',
> whole content = &{
>
>
> How can my understanding become better also for the use of SmPL conjunctions?
>
> Regards,
> Markus
>_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci