Convert Core Erlang forms into Erlang source code string

206 Views Asked by At

I have Core Erlang forms constructs with the cerl module. I wish to "decompile" it into an Erlang source code string.

I though I could do something like this:

Forms = erl_syntax:form_list(CoreForms),
erl_prettypr:format(Forms).

However erl_syntax:form_list/1 returns an empty list.

1

There are 1 best solutions below

3
On

Core Erlang ASTs cannot be handled with the utilities in syntax_tools - those are for normal Erlang ASTs only. For Core Erlang there are two modules (undocumented) for prettyprinting: core_pp in the compiler application, similar to erl_pp in stdlib, and cerl_prettypr in the hipe application (under lib/hipe/cerl/) which is similar to erl_prettypr in syntax_tools.