AST Manipulation and Common Subexpression Elimination
"Martin v. Löwis"
martin at v.loewis.de
Sat Oct 18 07:51:19 EDT 2003
Robert Kern wrote:
> 1. Can I do better than brute-force traversing the AST and trying to match each
> subtree to the other subtrees (using something like the match() function given
> in the parser module example)?
Certainly: you could do hashing or sorting. For hashing, define some
hash function for expressions, preferably recursively
> 2. Are there good tools out there for doing AST transformations like this? Are
> there any GUI tools for messing with the AST? I know that I will want to
> interactively select which subexpressions are eliminated in this fashion.
GUI yes, interactive no: You might want to take a look at the
dotty/graphviz tool suite.
Regards,
Martin
More information about the Python-list
mailing list