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
Have fun,
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev