From 84adefa331c4159d432d22840663c38f155cd4c1 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 20 Nov 2009 14:54:40 +0000 Subject: The R13B03 release. --- lib/stdlib/doc/src/erl_pp.xml | 178 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 lib/stdlib/doc/src/erl_pp.xml (limited to 'lib/stdlib/doc/src/erl_pp.xml') diff --git a/lib/stdlib/doc/src/erl_pp.xml b/lib/stdlib/doc/src/erl_pp.xml new file mode 100644 index 0000000000..6b15c5afd3 --- /dev/null +++ b/lib/stdlib/doc/src/erl_pp.xml @@ -0,0 +1,178 @@ + + + + +
+ + 1996 + 2007 + 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.

+
+ + + form(Form) -> DeepCharList + form(Form, HookFunction) -> DeepCharList + Pretty print a form + + Form = term() + HookFunction = see separate description below. + DeepCharList = [char()|DeepCharList] + + +

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

+
+
+ + attribute(Attribute) -> DeepCharList + attribute(Attribute, HookFunction) -> DeepCharList + Pretty print an attribute + + Attribute = term() + HookFunction = see separate description below. + DeepCharList = [char()|DeepCharList] + + +

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

+
+
+ + function(Function) -> DeepCharList + function(Function, HookFunction) -> DeepCharList + Pretty print a function + + Function = term() + HookFunction = see separate description below. + DeepCharList = [char()|DeepCharList] + + +

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

+
+
+ + guard(Guard) -> DeepCharList + guard(Guard, HookFunction) -> DeepCharList + Pretty print a guard + + Form = term() + HookFunction = see separate description below. + DeepCharList = [char()|DeepCharList] + + +

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

+
+
+ + exprs(Expressions) -> DeepCharList + exprs(Expressions, HookFunction) -> DeepCharList + exprs(Expressions, Indent, HookFunction) -> DeepCharList + Pretty print Expressions + + Expressions = term() + HookFunction = see separate description below. + Indent = integer() + DeepCharList = [char()|DeepCharList] + + +

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

+
+
+ + expr(Expression) -> DeepCharList + expr(Expression, HookFunction) -> DeepCharList + expr(Expression, Indent, HookFunction) -> DeepCharList + expr(Expression, Indent, Precedence, HookFunction) ->-> DeepCharList + Pretty print one Expression + + Expression = term() + HookFunction = see separate description below. + Indent = integer() + Precedence = + DeepCharList = [char()|DeepCharList] + + +

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

+
+
+
+ +
+ Unknown Expression Hooks +

The optional argument HookFunction, shown in the functions described above, defines a function which is called when an unknown form occurs where there + should be a valid expression. It can have the following formats:

+ + Function + +

The hook function is called by:

+ +Function(Expr, + CurrentIndentation, + CurrentPrecedence, + HookFunction) +
+ 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.

+
+ +
+ 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)

+
+
+ -- cgit v1.2.3