[erlang-questions] Function to syntax tree

Boris Okner boris.okner@REDACTED
Sun May 2 20:31:18 CEST 2010


Thanks a lot Tony,

Really got me a lot closer. The resulting AST is of type list though, but I
can now see how to transform it to the function AST, or I may even be able
to use it as is.

Boris

On Sun, May 2, 2010 at 1:55 PM, Tony Arcieri <tony.arcieri@REDACTED>wrote:

> On Sat, May 1, 2010 at 9:03 PM, bokner <boris.okner@REDACTED> wrote:
>
>> My question is: how do I do the same, but  with the function itself
>> instead string representation? I.e.,
>>
>> F = fun(X) -> X +1 end,
>>
>> AST = <some code turning F into AST>,
>> fun_expr = erl_syntax:type(AST).
>>
>
> This maybe?
>
> Fun = fun() -> 2 + 2 end,
> {env, Env} = erlang:fun_info(Fun, env),
> [Abs|_] = lists:reverse(Env)
>
> Note that will get you to the Erlang abstract format representation...
> you'll need to convert that to AST:
>
> AST = erl_syntax:abstract(Abs)
>
> --
> Tony Arcieri
> Medioh! A Kudelski Brand
>


More information about the erlang-questions mailing list