[erlang-questions] Function to syntax tree
Tony Arcieri
tony.arcieri@REDACTED
Sun May 2 19:55:33 CEST 2010
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