mirror of
https://github.com/valitydev/parse_trans.git
synced 2024-11-06 08:35:17 +00:00
2b89a55e5b
git-svn-id: http://svn.ulf.wiger.net/parse_trans/trunk/parse_trans@5 ae7daa23-5771-0410-ae54-ec81a0701e84
56 lines
1.2 KiB
Plaintext
56 lines
1.2 KiB
Plaintext
@author Ulf Wiger <ulf.wiger@erlang-consulting.com>
|
|
@doc A generic parse transform library
|
|
This library is intended to simplify the task of writing parse transform
|
|
modules for Erlang.
|
|
|
|
<h1>Introduction to parse transforms</h1>
|
|
|
|
<h2>The simplest transform</h2>
|
|
|
|
<p>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.</p>
|
|
|
|
<pre>
|
|
-module(test_pt).
|
|
|
|
-export([parse_transform/2]).
|
|
|
|
parse_transform(Forms, _Options) ->
|
|
io:fwrite("Forms = ~p~n", [Forms]),
|
|
Forms.
|
|
</pre>
|
|
|
|
<p>Trying this with a very simple module:</p>
|
|
|
|
<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>
|
|
|
|
<h2>`transform/4'</h2>
|
|
<p>...</p>
|
|
|
|
|
|
<h1>Current limitations</h1>
|
|
<p>...</p>
|
|
|
|
@end
|