Vlad Dumitrescu vladdu55@REDACTED
Fri Jun 2 12:47:04 CEST 2006

On 6/2/06, Richard Carlsson <richardc@REDACTED> wrote:
> Vlad Dumitrescu wrote:
>  > Is there any way to force the use of erl_syntax trees everywhere?
> So, you want to convert the trees to a Java representation?

Yes, I use the parse trees in Erlide. Right now, I take the mixed
trees that epp_dodger returns, but we are planning some changes that
would make this more inconvenient. For example, we will have extra
information to annotate the nodes with.

I suppose I should walk the tree and clone it using erl_syntax calls,
then the new tree will be fully "syntax_tools" style. It is possible
that I'll have to do it anyway, in order to add the annotations.

> Or do you want to force other library modules, such as the compiler
> or linter, to accept full erl_syntax trees?

We are using the parser just as a "syntactic parser", not for
compiling but for having a model of the code as it is written in the
file. For example, I modified the lexical scanner to retain the token
text, thus making a difference between the integer 10 written as 16#A
or 2#1010.

> 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.

If I want to create serialized Java objects in Erlang, I'd have to
reimplement most of the serialization streaming stuff, which I don't
look forward to. Instead, I am sending the Erlang term representing
the tree and use jinterface to split it in components. So I have to
rely on the internal representation...

Thank you for the answer!

best regards,

More information about the erlang-questions mailing list