On Sun, 9 Mar 2014, SF Markus Elfring wrote:

> >> Would you like to clarify data analysis according to the current situation
> >> around "coccilib.elems.TermList instance"?
> > 
> > I know nothing about this.
> 
> I am surprised by this feedback.

I didn't implement it, and I never use python.  The thing you are citing 
was implemented by a masters student for his masters thesis project, and 
it contains whatever he found useful.

> I assume that a corresponding interface description would be nice if I 
> look at "man 3cocci Coccilib". How are the chances to improve the 
> mapping from the OCaml API to the Python binding?

If you would like to have such a thing you are welcome to implement.  In 
my experience the AST is very rarely useful.

> > But I am not sure that using it is the best way to do whjat you 
> > want, although I also don't know what you want to do.
> 
> The tool "spatch" counts all elements in a metavariable of the type 
> "parameter list". I would like to treat list elements that have got the 
> function parameter type "void" or no name differently.
> - How can I assign the number "zero" (instead of "1") in this case?

Have a special rule for such functions and use position variables to 
prevent the rule that matches interesting parameter lists from matching 
functions that have satisfied this case:

@r@
position p;
identifier f;
@@

f@p(void} { ... }

@goodfunctions@
position p != r.p;
parameter list[n] ps;
identifier f;
@@

f@p(ps) { ... }

Or you can just use your python code to see if ps is just the string 
"void".

> I am also interested a bit in run time optimisation. A passed list should be
> sufficient for further computations. I do not really need a count in another
> variable which was specified between square brackets of a SmPL rule.

It is hard to imagine why converting all the elements of a list to strings 
as is done in the interface to python would be more efficient than just 
passing a single number.

Anyway, the runtime cost is not here, in either case.  The runtime cost 
will be that you have to parse every function of every file.

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to