[Cython] Best way to display parse tree
Stefan Behnel
stefan_ml at behnel.de
Fri Mar 6 11:55:25 CET 2009
Hoyt Koepke wrote:
> I'm trying to get into cython development
You are very welcome.
> and I'm having difficulty
> understanding the internals of the parse tree and how it works. Being
> able to print or display the parse tree would really help in this
> effort, as it's really tedious to work through the code trying to
> figure this stuff out. What is the best way to see the parse tree of
> a given pyx file / function / code block? Is there an easy way to do
> it that I don't know about?
Glad you asked. :)
Yes, there is. Look into Main.py, there is a method called
create_pipeline(). It imports a class called PrintTree at the top and
builds the compiler pipeline at the end. If you throw an instance of that
class into the pipeline at any point, it will dump out the current tree
for you. Note that the output can be pretty long, so you may want to start
with a short example (such as one of the test cases).
Stefan
More information about the Cython-dev
mailing list