[erlang-questions] how: info on how to traverse abstract format trees?

Robert Virding rvirding@REDACTED
Tue Jul 22 15:39:34 CEST 2008


2008/7/3 Thomas Lindgren <thomasl_erlang@REDACTED>:

>
> --- On Tue, 6/24/08, Tim Fletcher <twoggle@REDACTED> wrote:
>
> > I'm just checking to see if there might be some
> > recommended/documented
> > way of doing such a traversal. Trying to work it out from
> > parse
> > transform code directly is a bit intimidating (which is why
> > frabjous
> > is very appealing).
>
> Personally, I've always tended to write my own, among other things because
> the appropriate traversal differs depending on what you want to do. But the
> erlang distribution itself includes a few hints:
>
> * erl_id_trans.erl contains a skeleton parse transform


I agree. I have a modified version of erl_id_trans.erl which threads a (in
this case dummy) state structure through all the calls as well as rebuilding
the tree. It is a little easier to extend to be useful. It also uses some
different styles when traversing the structure as examples of when you might
need to handle them differently. For example passing over a list using
mapfoldl (which fits this perfectly) when you know you can handle each
element separately as opposed to processing the list explicitly when you
need that.

It is not really documented but you cam "see" it when you know what to look
for.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080722/e6431a06/attachment.htm>


More information about the erlang-questions mailing list