Julia,

This proposal sounds very useful to me.

I would not want to remove any of the existing functionality.
As it currently stands cocci can be used by people who only
know C and I think it would be useful to keep this ability.

Relating to your C++ post earlier this week.  I think it was in
the later 90s that somebody told me that writing a C++ compiler
was about seven times the effort of writing a C compiler.  A lot
of new stuff has been added in C++11 and not so much in C1x,
so I suspect the ratio will have gone up.

Perhaps a solution would be to allow scripting code in metavariable
declarations. Then we could in principle get rid of all sorts of
constraints. There would be no need to learn the SmPL constraints and
where they could occur. One would just have to remember the syntax of
one's preferred scripting language (from among the optons available :).

So for example, one could write:

@initialize:ocaml@
let badnames = ["one";"two";"three"]

@@
identifier x where ocaml{not (List.mem x badnames)};
@@

*f(3)

I imagine that is it possible to do the same thing in python.

Similarly, one could get rid of the regular expression matching
notation. I assume python provides something for that, for those that
don't want to use ocaml. Note that the interaction with python might be
less efficient than the current native ocaml version.

One could also get rid of the subterm notation, expression e <= r.e1;,
although that would currently require someone who wants this
functionality to use ocaml, because currently only ocaml code gets a
representation of the abstract syntax tree.

An issue is what metavariables this code can use. In the above, I have
assumed that the ocaml code is implicitly parameterized by the
metavariable that is being declared. It would be too complicated to
allow the code to have access to other metavariables being declared at
the same time. But if an appropriate syntax for declaring them could be
found, it would be possible to allow metavariables to be inherited from
previous rules. Currently we have @@ to separate metavariable
declarations from the script code. Perhaps we could use that, although
it seems a bit ugly. Another option would be to have no separator. The
end of the metavariable list would be the occurrence of the last x << r.y;

What do you think?

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)


--
Derek M. Jones                  tel: +44 (0) 1252 520 667
Knowledge Software Ltd          blog:shape-of-code.coding-guidelines.com
Source code analysis            http://www.knosof.co.uk
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to