[erlang-questions] Function to syntax tree

Ulf Wiger ulf.wiger@REDACTED
Mon May 3 08:53:02 CEST 2010


Perhaps this code snippet might be of some help?

http://www.erlang.org/cgi-bin/ezmlm-cgi/4/31984

I have not tried to see whether it still works, though.

BR,
Ulf W

bokner wrote:
> Hi,
> 
> 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>,
> fun_expr = erl_syntax:type(AST).
> 
> Thanks,
> Boris
> 
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 


-- 
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list