How to generate AST for a module in erlang?

Viewed 92

how to generate an AST ,during runtime, for a whole module?
enter image description here

1 Answers

There are multiple ways to achieve that result.

For instance, you can use ktn_dodger like we do on the rebar3 formatter.

But, with just OTP…

1> epp_dodger:quick_parse_file("src/pt_example.erl").
{ok,[{attribute,1,module,pt_example},
     {attribute,3,export,[{a,0}]},
     {function,5,a,0,
               [{clause,5,[],[],
                        [{call,6,
                               {remote,6,{atom,6,io},{atom,6,format}},
                               [{string,6,"Hello!"}]}]}]}]}
Related