1996 2012 Ericsson AB, All Rights Reserved The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Initial Developer of the Original Code is Ericsson AB. erl_pp Robert Virding Bjarne Däcker 1 Bjarne Däcker 97-01-24 B erl_pp.sgml
erl_pp The Erlang Pretty Printer

The functions in this module are used to generate aesthetically attractive representations of abstract forms, which are suitable for printing. All functions return (possibly deep) lists of characters and generate an error if the form is wrong.

All functions can have an optional argument which specifies a hook that is called if an attempt is made to print an unknown form.

The optional argument HookFunction, shown in the functions described below, defines a function which is called when an unknown form occurs where there should be a valid expression.

If HookFunction is equal to none there is no hook function.

The called hook function should return a (possibly deep) list of characters. expr/4 is useful in a hook.

If CurrentIndentation is negative, there will be no line breaks and only a space is used as a separator.

Pretty print a form

Pretty prints a Form which is an abstract form of a type which is returned by erl_parse:parse_form/1.

Pretty print an attribute

The same as form, but only for the attribute Attribute.

Pretty print a function

The same as form, but only for the function Function.

Pretty print a guard

The same as form, but only for the guard test Guard.

Pretty print Expressions

The same as form, but only for the sequence of expressions in Expressions.

Pretty print one Expression

This function prints one expression. It is useful for implementing hooks (see below).

Bugs

It should be possible to have hook functions for unknown forms at places other than expressions.

See Also

io(3), erl_parse(3), erl_eval(3)