1

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.

4
  • What is CoreForms? Commented Aug 9, 2018 at 12:38
  • what is the c_erl module? which function are you using? With which parameters? Commented Aug 9, 2018 at 14:17
  • 1
    The module is named cerl, not c_erl. It is part of the compiler application. Commented Aug 9, 2018 at 15:11
  • @pdexter CoreForms is a cerl:cerl(), a module as Core Erlang AST. Commented Aug 10, 2018 at 14:14

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

core_pp:format/1 converts core Erlang to a core Erlang source string, but I am interested in building a regular Erlang source string.
@lpil ah, so from core you want to print Erlang? That isn't trivially possible. You cannot 'simply' reconstruct the Erlang source from core.
As I feared. Thanks for confirming :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.