[erlang-questions] Function to syntax tree
Boris Okner
boris.okner@REDACTED
Sun May 2 16:13:37 CEST 2010
Thanks Richard,
So the sequence you're suggesting is:
Function -> BEAM code -> Erlang source code -> AST?
Still, assuming second step done by Decompiler, 3rd step by erl_scan and
erl_parse, how do I get a BEAM code for anonymous function?
On Sun, May 2, 2010 at 5:22 AM, Richard Carlsson <carlsson.richard@REDACTED
> wrote:
> bokner wrote:
>
>> erl_scan and erl_parse can turn function represented by string into
>> AST. For example,
>>
>> 1> {ok, S, _} = erl_scan:string("fun(X) -> X+1 end."),
>> 1> {ok, P} = erl_parse:parse_exprs(S),
>> 1> [F] = P, erl_syntax:type(F).
>> fun_expr
>>
>> 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>,
>>
>
> The "<some code turning F into AST>" would be something called
> a Decompiler (see wikipedia for details), turning BEAM code
> back into Erlang source code. See also:
> http://www.erlang.org/pipermail/erlang-questions/2006-January/018810.html
>
> As far as I know, nobody has written a BEAM decompiler.
>
> /Richard
>
>
More information about the erlang-questions
mailing list