[erlang-questions] Pretty-printing Erlang
Thu Oct 21 12:03:49 CEST 2010
On Thu, Oct 21, 2010 at 02:59, Richard O'Keefe <ok@REDACTED> wrote:
> On 20/10/2010, at 8:03 PM, Bengt Kleberg wrote:
>> I have used the module erl_prettypr
>> (http://www.erlang.org/doc/man/erl_prettypr.html) to achieve the emacs
>> layout prescribed here at work.
> That's not exactly what I wanted, but it did lead me to
> erl_tidy:dir(), which was.
[not really an answer to the original question, sorry]
Pretty-printing is a tricky business. The parsed Erlang syntax trees
don't keep all the information in the source code. The epp_dodger can
take care of well-behaved macros, but still for example integers get
converted to their decimal value while in the source they could be in
hex or octal. The
"a_string " "another_string"
construct gets merged into one string in the parse tree, too.
With the advent of refactoring and other source code transformation
tools, a pretty-printer that keeps track of how the original looks
like is badly needed. Many tools have their own version of
pretty-printer, but I'm not aware of any that goes all the way. The
closest reference I know of is ParsErl
(http://www.erlang.se/euc/07/papers/1200ParsErl.pdf), but I can't find
any publicly available tool based on it.
And as a final blow, we still have the case of badly-behaved macros,
which are very difficult to handle in a meaningful way by any tool.
I have had a plan to implement a pretty-printer for use with erlide
since a long time ago, but there are many other things more urgent and
it doesn't look like it's going to happen soon. If anyone starts
working on this project, please feel free to contact me.
More information about the erlang-questions