Stefan Behnel wrote:
> Hi,
>
> I implemented a little path language for Python's code tree, based on the
> path language in ElementTree and lxml. It happily steals from XPath and
> looks like this:
>
>       //DefNode/ReturnStatNode/NameNode
>
>       //nameno...@name = 'decorator']
>
>       //NameNode/@name
>   
> It allows selecting nodes (or values) from the parse tree based on the
> above expressions and is meant mainly for testing, but can be used for
> anything. The main motivation was to support assertions in the test suite,
> so that we can finally test that an expected optimisation really leads to a
> specific tree structure. This test support isn't there yet, but it should
> be trivial to add. Look that the unit tests in
>
> http://hg.cython.org/cython-unstable/file/tip/Cython/Compiler/Tests/TestTreePath.py
>
> The implementation is in
>
> http://hg.cython.org/cython-unstable/file/tip/Cython/Compiler/TreePath.py
>   

Wonderful, thanks!

FYI I have lying somewhere a metaclass which makes Cython nodes support 
W3C DOM. If you think that is valuable then I could try to polish it up, 
but unless there's a real need I'd rather spend my  time on other things.

Also I can see that this overlaps a little bit in intended usecase with 
my code tree writer, although I can see that it should be easier to 
write robust unit tests with this approach. Thanks again.

Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to