identity parse transform using syntax_tools
Vlad Dumitrescu XX (LN/EAB)
Mon Feb 13 15:57:43 CET 2006
Nice - a clean and readable implementation, very useful for simple
Now I have to explain why I said "simple transformations" without making
it sound like a negative remark :-)
The code implements a preorder traversal of the tree. This means that
the transformation of the current form has to be defined in terms of
non-transformed code. Depending on the specific transformation, a
definition in terms of transformed code might be significantly easier,
so a postorder traversal might be what's needed.
In the general case, I think one would really need to do a generalized
'Euler tour' traversal, meaning that the tree
/ | \
1 2 7
/ \ /|\
3 4 5 8 6
Would be traversed in the order 0 1 3 1 4 1 0 2 5 2 8 2 6 2 0 7 0
Defining a single function to manage this is quite difficult, especially
if it is to remain readable.
If the transformation is so complicated there are other options:
making several passes over the tree
defining a new language so that the correct tree is generated
from normal parsing
I am also very interested in meta-programming and its applications, and
have some ideas about how to integrate such beasts with Erlang.
Unfortunately, only ideas so far; translating those into code requires
time that I don't have right now....
More information about the erlang-questions