On Mon, 13 Feb 2012, Michael Stefaniuc wrote:
Hello Julia,
Julia Lawall wrote:
Here is a patch that imports expression lists into python as an instance
many thanks! The patch seems to work (needs a indentation change for
python/coccilib/elems.py on rc9).
of the class ExpressionList, having the methods __getitem__ and __str__.
you can thus write eg:
Would it be possible to add a __len__ attribute too? Expression lists
can be empty and nicest way to check for that is that len(es) > 0.
OK, I'll do that. I guess that you can already get that information from
es.elements?
julia
@r@
expression list es;
@@
f(es)
@script:python@
es << r.es;
@@
print "%s" % es
print "%s" % es[1]
--------------------
The elements of the expression list are stored in the "elements" field
of the ExpressionList structure, and thus is it also possible to say eg
es.elements[1]. The elements list does not contain the commas between
the elements. They have disappeared completely. The elements are just
Sure, the comma isn't part of the expressions.
ordinary strings, not Expression structures. Maybe making them
Expression structures would be a good idea. But maybe getting rid of
Expression structures would be better, since they don't offer any
information other than the string representation.
I guess that making the expression a string should be fine; I never
needed more than the string from python.
Suggestions are welcome. If this seems to be what is desired, I will do
the same for the other list types.
thanks
bye
michael
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)