identity parse transform using syntax_tools

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Mon Feb 13 16:21:07 CET 2006


You're absolutely right.
I tried to write a version that might work for
most simple transforms.

In plain_fsm_xform (I just realized I haven't
actually published it yet), I did write something
along the lines that you describe:

http://article.gmane.org/gmane.comp.lang.erlang.general/12482

Obviously, it gets a bit too complicated for a generic
support function. 

While I was writing it, I still ended up tagging
the syntax tree with annotations, and used multiple
passes. The annnotations go away when you revert to
the standard parsed forms, so they can be used to
tag the structure and then running multiple passes.

/Uffe

> -----Original Message-----
> From: Vlad Dumitrescu XX (LN/EAB) 
> Sent: den 13 februari 2006 15:58
> To: Ulf Wiger (AL/EAB); erlang-questions@REDACTED
> Subject: RE: identity parse transform using syntax_tools
> 
> Hi!
> 
> Nice - a clean and readable implementation, very useful for 
> simple transformations!
> 
> 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
>             0
>         /   |   \
>        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.... 
> 
> Best regards,
> Vlad
> 
> 



More information about the erlang-questions mailing list