-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ulf Wiger
committed
Oct 23, 2011
1 parent
5c63412
commit bb57e23
Showing
15 changed files
with
489 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}. |
Oops, something went wrong.