[erlang-questions] clarify: how to traverse AST with erl_syntax functions ?

Roberto Saccon rsaccon@REDACTED
Mon Dec 17 11:21:38 CET 2007

is there a good example anywhere ?

I think I am doing something wrong, e.g.: I want to traverse the AST
of the string module and access some of the functions.

1> {_, Beam, _} = code:get_object_code(list_to_atom("string")).
2> {ok,{_,[{abstract_code,{_,Ac}}]}} = beam_lib:chunks(Beam,[abstract_code]).
3>T= erl_syntax:abstract(Ac).
4> erl_syntax:type(T).
5> Ts=erl_syntax:list_elements(T).

now Ii grab one element form the middle of the  list, which
encapsulates a function of the string module:

11> T_in_the_middle.
12> erl_syntax:type(T_in_the_middle).

And now how do I get to the function inside ? Is there a "direct way"
to get there or do I need to unpack the tuple ?

Roberto Saccon

More information about the erlang-questions mailing list