serge-sans-paille / pythran

Ahead of Time compiler for numeric kernels
https://pythran.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.99k stars 190 forks source link

Extend ASTPattern to support substitution #354

Open serge-sans-paille opened 9 years ago

serge-sans-paille commented 9 years ago

ASTPattern, contributed by @pbrunet , does a great job at matching tree expressions. It would be great to have it support capturing patterns to provide a re.sub -like method.

pbrunet commented 9 years ago

You should have a look at pattern_transform.py in the optimization folder which already do it for few patterns.

serge-sans-paille commented 9 years ago

Yeah, the problem is that it could/should be part of the matcher interface, to match the re interface. What do you think of this improvement?

pbrunet commented 9 years ago

I agree but ast_matcher is an analysis and the ast_matcher.sub will also modify the ast. Should it be something else than just analysis/optimization?

serge-sans-paille commented 9 years ago

+1, maybe in utils.py?, or a tree_matcher.py at the root

pbrunet commented 9 years ago

I prefer tree_matcher.py at the root. It makes more sense to me.