1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>erl_pp</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>erl_pp</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
erl_pp</UL>
<H3>MODULE SUMMARY</H3>
<UL>
The Erlang Pretty Printer</UL>
<H3>DESCRIPTION</H3>
<UL>
<P>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.
<P>All functions can have an optional argument which specifies a hook
that is called if an attempt is made to print an unknown form.
</UL>
<H3>EXPORTS</H3>
<P><A NAME="form%1"><STRONG><CODE>form(Form) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="form%2"><STRONG><CODE>form(Form, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Form = term()</CODE></STRONG><BR>
<STRONG><CODE>HookFunction = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>DeepCharList = [char()|DeepCharList]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Pretty prints a
<CODE>Form</CODE> which is an abstract form of a type which is
returned by <CODE>erl_parse:parse_form</CODE>.
</UL>
<P><A NAME="attribute%1"><STRONG><CODE>attribute(Attribute) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="attribute%2"><STRONG><CODE>attribute(Attribute, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Attribute = term()</CODE></STRONG><BR>
<STRONG><CODE>HookFunction = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>DeepCharList = [char()|DeepCharList]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>The same as <CODE>form</CODE>, but only for the attribute
<CODE>Attribute</CODE>.
</UL>
<P><A NAME="function%1"><STRONG><CODE>function(Function) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="function%2"><STRONG><CODE>function(Function, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Function = term()</CODE></STRONG><BR>
<STRONG><CODE>HookFunction = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>DeepCharList = [char()|DeepCharList]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>The same as <CODE>form</CODE>, but only for the function
<CODE>Function</CODE>.
</UL>
<P><A NAME="guard%1"><STRONG><CODE>guard(Guard) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="guard%2"><STRONG><CODE>guard(Guard, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Form = term()</CODE></STRONG><BR>
<STRONG><CODE>HookFunction = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>DeepCharList = [char()|DeepCharList]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>The same as <CODE>form</CODE>, but only for the guard test
<CODE>Guard</CODE>.
</UL>
<P><A NAME="exprs%1"><STRONG><CODE>exprs(Expressions) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="exprs%2"><STRONG><CODE>exprs(Expressions, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="exprs%3"><STRONG><CODE>exprs(Expressions, Indent, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Expressions = term()</CODE></STRONG><BR>
<STRONG><CODE>HookFunction = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>Indent = integer()</CODE></STRONG><BR>
<STRONG><CODE>DeepCharList = [char()|DeepCharList]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>The same as <CODE>form</CODE>, but only for the sequence of
expressions in <CODE>Expressions</CODE>.
</UL>
<P><A NAME="expr%1"><STRONG><CODE>expr(Expression) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="expr%2"><STRONG><CODE>expr(Expression, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="expr%3"><STRONG><CODE>expr(Expression, Indent, HookFunction) -> DeepCharList</CODE></STRONG></A><BR>
<A NAME="expr%4"><STRONG><CODE>expr(Expression, Indent, Precedence, HookFunction) ->-> DeepCharList</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Expression = term()</CODE></STRONG><BR>
<STRONG><CODE>HookFunction = see separate description below.</CODE></STRONG><BR>
<STRONG><CODE>Indent = integer()</CODE></STRONG><BR>
<STRONG><CODE>Precedence = </CODE></STRONG><BR>
<STRONG><CODE>DeepCharList = [char()|DeepCharList]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This function prints one expression. It is useful for implementing hooks (see below).
</UL>
<H3>Unknown Expression Hooks</H3>
<UL>
<P>The optional argument <CODE>HookFunction</CODE>, 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:
<P><DL>
<DT><CODE>Function</CODE></DT>
<DD> The hook function is called by:<BR>
<PRE>Function(Expr,
CurrentIndentation,
CurrentPrecedence,
HookFunction)</PRE>
</DD>
<DT><CODE>none</CODE></DT>
<DD> There is no hook function<BR>
</DD>
</DL>
<P>The called hook function should return a (possibly deep) list
of characters. <CODE>expr/4</CODE> is useful in a hook.
<P>If <CODE>CurrentIndentation</CODE> is negative, there will be no line
breaks and only a space is used as a separator.
</UL>
<H3>Bugs</H3>
<UL>
<P>It should be possible to have hook functions for unknown forms
at places other than expressions.
</UL>
<H3>See Also</H3>
<UL>
<P><A HREF="io.html">io</A>,
<A HREF="erl_parse.html">erl_parse</A>,
<A HREF="erl_eval.html">erl_eval</A>
</UL>
<H3>AUTHORS</H3>
<UL>
Robert Virding - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright © 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>
|