Skip to content

Commit

Permalink
Merge branch 'module-transforms'
Browse files Browse the repository at this point in the history
  • Loading branch information
uwiger committed Nov 22, 2011
2 parents 6364c2c + 5b2201f commit 565399c
Show file tree
Hide file tree
Showing 22 changed files with 1,714 additions and 690 deletions.
108 changes: 92 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,92 @@
Parse Transform Utility Library
===============================

This application contains some utility functions that
make it easier to write maintainable parse transforms
for erlang. The library uses Syntax Tools, which may seem
unwieldy at first. However, I recommend getting acquainted
with Syntax Tools; it has many advantages in for parse
transforms.

Documentation
-------------
The EDoc is generated using the EDown extension, in order
to make it easy to read online on Github. To generate
normal edoc, update `rebar.config` to remove the edown-
related dependencies and edoc options.


#The parse_trans application#


__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#




##The simplest transform##




The very simplest transform we can make is one that doesn't
change a thing. For convenience, we will at least print the forms.
This will enlighten us as to what the forms actually look like.

<pre>
-module(test_pt).

-export([parse_transform/2]).

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



Trying this with a very simple module:

<pre>
-module(ex1).
-export([add/2]).

add(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}]
{ok,ex1}
</pre>



##`transform/4`##



...




#Current limitations#



...


##Modules##


<table width="100%" border="0" summary="list of modules">
<tr><td><a href="http://github.com/esl/parse_trans/blob/module-transforms/doc/ct_expand.md" class="module">ct_expand</a></td></tr>
<tr><td><a href="http://github.com/esl/parse_trans/blob/module-transforms/doc/exprecs.md" class="module">exprecs</a></td></tr>
<tr><td><a href="http://github.com/esl/parse_trans/blob/module-transforms/doc/parse_trans.md" class="module">parse_trans</a></td></tr>
<tr><td><a href="http://github.com/esl/parse_trans/blob/module-transforms/doc/parse_trans_codegen.md" class="module">parse_trans_codegen</a></td></tr>
<tr><td><a href="http://github.com/esl/parse_trans/blob/module-transforms/doc/parse_trans_mod.md" class="module">parse_trans_mod</a></td></tr>
<tr><td><a href="http://github.com/esl/parse_trans/blob/module-transforms/doc/parse_trans_pp.md" class="module">parse_trans_pp</a></td></tr></table>

23 changes: 7 additions & 16 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@


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

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

Expand All @@ -16,14 +11,12 @@ modules for Erlang.



<h1>Introduction to parse transforms</h1>

#Introduction to parse transforms#




<h2>The simplest transform</h2>

##The simplest transform##



Expand Down Expand Up @@ -70,8 +63,7 @@ Forms = [{attribute,1,file,{"./ex1.erl",1}},



<h2><code>transform/4</code></h2>

##`transform/4`##



Expand All @@ -80,22 +72,21 @@ Forms = [{attribute,1,file,{"./ex1.erl",1}},



<h1>Current limitations</h1>

#Current limitations#



...


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

##Modules##


<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_mod.md" class="module">parse_trans_mod</a></td></tr>
<tr><td><a href="parse_trans_pp.md" class="module">parse_trans_pp</a></td></tr></table>

41 changes: 15 additions & 26 deletions doc/ct_expand.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
Module ct_expand
================


<h1>Module ct_expand</h1>

#Module ct_expand#
* [Description](#description)
* [Data Types](#types)
* [Function Index](#index)
Expand All @@ -14,10 +11,9 @@ Compile-time expansion utility.



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

<h2><a name="description">Description</a></h2>
__Authors:__ : Ulf Wiger ([`ulf.wiger@erlang-solutions.com`](mailto:ulf.wiger@erlang-solutions.com)).<a name="description"></a>

##Description##



Expand All @@ -38,61 +34,54 @@ For example, the line

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

<a name="types"></a>


<h2><a name="types">Data Types</a></h2>
##Data Types##





<h3 class="typedecl"><a name="type-form">form()</a></h3>

###<a name="type-form">form()</a>##



<pre>form() = any()</pre>



<h3 class="typedecl"><a name="type-forms">forms()</a></h3>

###<a name="type-forms">forms()</a>##



<pre>forms() = [<a href="#type-form">form()</a>]</pre>
<pre>forms() = [[form()](#type-form)]</pre>



<h3 class="typedecl"><a name="type-options">options()</a></h3>

###<a name="type-options">options()</a>##



<pre>options() = [{atom(), any()}]</pre>
<a name="index"></a>


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

##Function Index##


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


<h2><a name="functions">Function Details</a></h2>

##Function Details##

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

<h3>parse_transform/2</h3>

###parse_transform/2##




<pre>parse_transform(Forms::<a href="#type-forms">forms()</a>, Options::<a href="#type-options">options()</a>) -> <a href="#type-forms">forms()</a></pre>
<pre>parse_transform(Forms::[forms()](#type-forms), Options::[options()](#type-options)) -&gt; [forms()](#type-forms)</pre>
<br></br>


3 changes: 2 additions & 1 deletion doc/edoc-info
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{application,parse_trans}.
{packages,[]}.
{modules,[ct_expand,exprecs,parse_trans,parse_trans_codegen,parse_trans_pp]}.
{modules,[ct_expand,exprecs,parse_trans,parse_trans_codegen,parse_trans_mod,
parse_trans_pp]}.
Loading

0 comments on commit 565399c

Please sign in to comment.