Fri Jun 2 12:23:20 CEST 2006
Vlad Dumitrescu wrote:
> Using epp_dodger is very nice, but the resulting tree is a mixture of
> "normal" trees and erl_syntax trees. Because I send these trees to
> Java, it would be much easier to have a uniform representation.
> Is there any way to force the use of erl_syntax trees everywhere?
So, you want to convert the trees to a Java representation?
First, note that any "normal" erl_parse tree can always be used
as it is with the erl_syntax functions, but once you use an
erl_syntax function to manipulate syntax trees, the output is
not backwards compatible with erl_parse unless you do a 'revert'
(which does not work on all things, e.g. macro calls and comments).
Or do you want to force other library modules, such as the compiler
or linter, to accept full erl_syntax trees?
Probably, the best way to write a translator from erl_syntax trees
to some other representation like Java objects would be to base it
on the functions erl_syntax:type/1 and erl_syntax:subtrees/1. Also
see the functions get_pos/1, get_ann/1, get_precomments/1 and get_postcomments/1.
In the reverse direction, use erl_syntax:make_tree/2.
More information about the erlang-questions