Markus proposes that we add some kind of naming of lists of identifiers so
that it is not necessary to repeat the same
identifier x != {a,b,c,d,e,f};
multiple times.
While I can see the benefit of not duplicating code, I don;t really like
the idea of adding lots of new constructions into the SmPL language. If
one can make assignments to identifier lists, why not assignments to other
things. And so on.
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)