Skip to content

Commit

Permalink
merged klajo-form-injection
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Wiger committed Oct 27, 2010
1 parent 06a1066 commit 049ea9f
Show file tree
Hide file tree
Showing 6 changed files with 564 additions and 337 deletions.
48 changes: 31 additions & 17 deletions doc/README.md
@@ -1,24 +1,30 @@


#The parse_trans application#
<h1>The parse_trans application</h1>

The parse_trans application
===========================
A generic parse transform library
This library is intended to simplify the task of writing parse transform
modules for Erlang.

__Authors:__ Ulf Wiger ([`ulf.wiger@erlang-consulting.com`](mailto:ulf.wiger@erlang-consulting.com)).

A generic parse transform library
This library is intended to simplify the task of writing parse transform
modules for Erlang.



#Introduction to parse transforms#
<h1>Introduction to parse transforms</h1>





##The simplest transform##
<h2>The simplest transform</h2>





Expand All @@ -33,12 +39,13 @@ This will enlighten us as to what the forms actually look like.
-export([parse_transform/2]).

parse_transform(Forms, _Options) ->
io:fwrite("Forms = ~p~n", [Forms]),
Forms.
io:fwrite("Forms = ~p~n", [Forms]),
Forms.
</pre>




Trying this with a very simple module:


Expand All @@ -47,47 +54,54 @@ Trying this with a very simple module:
-export([add/2]).

add(X,Y) ->
X + Y.
X + Y.
</pre>



<pre>
1> c(ex1, [{parse_transform,test_pt}]).
Forms = [{attribute,1,file,{"./ex1.erl",1}},
{attribute,1,module,ex1},
{attribute,2,export,[{add,2}]},
{function,4,add,2,
[{clause,4,
[{var,4,'X'},{var,4,'Y'}],
[],
[{op,5,'+',{var,5,'X'},{var,5,'Y'}}]}]},
{eof,6}]
{attribute,1,module,ex1},
{attribute,2,export,[{add,2}]},
{function,4,add,2,
[{clause,4,
[{var,4,'X'},{var,4,'Y'}],
[],
[{op,5,'+',{var,5,'X'},{var,5,'Y'}}]}]},
{eof,6}]
{ok,ex1}
</pre>




##`transform/4`##
<h2>`transform/4`</h2>




...




#Current limitations#
<h1>Current limitations</h1>




...


##Modules##
<h2 class="indextitle">Modules</h2>



<table width="100%" border="0" summary="list of modules">
<tr><td><a href="ct_expand.md" class="module">ct_expand</a></td></tr>
<tr><td><a href="exprecs.md" class="module">exprecs</a></td></tr>
<tr><td><a href="parse_trans.md" class="module">parse_trans</a></td></tr>
<tr><td><a href="parse_trans_codegen.md" class="module">parse_trans_codegen</a></td></tr>
<tr><td><a href="parse_trans_pp.md" class="module">parse_trans_pp</a></td></tr></table>

54 changes: 35 additions & 19 deletions doc/ct_expand.md
Expand Up @@ -2,48 +2,64 @@ Module ct_expand
================


#Module ct_expand#
<h1>Module ct_expand</h1>

* [Description](#description)
* [Function Index](#index)
* [Function Details](#functions)
Compile-time expansion utility.

__Authors:__ : Ulf Wiger ([`ulf.wiger@erlang-solutions.com`](mailto:ulf.wiger@erlang-solutions.com)).

##<a name="description">Description</a>##
<h2><a name="description">Description</a></h2>



Compile-time expansion utility





This module serves as an example of parse_trans-based transforms,
but might also be a useful utility in its own right.
The transform searches for calls to the pseudo-function
`ct_expand:term(Expr)`, and then replaces the call site with the
result of evaluating `Expr` at compile-time.


but might also be a useful utility in its own right.
The transform searches for calls to the pseudo-function
`ct_expand:term(Expr)`, and then replaces the call site with the
result of evaluating `Expr` at compile-time.



For example, the line





`ct_expand:term(lists:sort([3,5,2,1,4]))`

would be expanded at compile-time to `[1,2,3,4,5]`.


##<a name="index">Function Index</a>##
would be expanded at compile-time to `[1,2,3,4,5]`.


<h2><a name="index">Function Index</a></h2>



<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#parse_transform-2">parse_transform/2</a></td><td></td></tr></table>


<a name="functions"></a>


##Function Details##
<h2>Function Details</h2>


<a name="parse_transform-2"></a>


###parse_transform/2##
<h3>parse_transform/2</h3>





`parse_transform(Forms, Options) -> any()`

_Generated by EDoc, Oct 26 2010, 21:17:38._


_Generated by EDoc, Oct 27 2010, 20:50:39._

0 comments on commit 049ea9f

Please sign in to comment.