Dag,
Do you want to transform the ExprTree or the DOCUMENT (i.e. the C
file) produced by the ExprTree?
I understood that you were working on the second point, but seems that
you are working on the first point !
Matching an expr tree with XPath, seems to me like shooting to a fly
with a cannon.
It will be very slow and not all the possible matching rules will be
possible with XPath plus I imagine that will be some trickery with
recursive functions.
I would prefer other forms of matching:
i.e.
class ForInToForFrom(Transformation):
def ex_match1 (self, tree):
return len(tree) >=3 and tree is ForInStatNode and tree[1] is
SimpleCallNode and tree[2] is NameNode and tree[2].name == RANGE_ID
def ex_match2 (self, tree):
return tree == ForInStatNode ( SimpleCallNode ( NameNode
(name = RANGE_ID)))
def eg_match3 (self,tree):
subtree = buildMatch ("""
ForInStatNode:
SimpleCallNode:
NameNode:
name = range
""")
return subtree.matches(tree)
def transform (self, tree):
return Nodes.ForFromStatNode(...)
Plex have a DSL to express matching Rules we could readapt it to match
Nodes instead of chars ...
To better understand what kind of transformation we would like to
apply I think we should have a 10 / 20 item list of possible
transforms.
>From this list should be derived the best form to express the matching
against the ExprTree or the AST.
This things could be done in N different ways. Finding the most simple
and effective is the challenge.
Fabrizio
--------------------------
Luck favors the prepared mind. (Pasteur)
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev