Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 93 lines (49 sloc) 2.114 kB
c0bfe08 generated edown docs + added README
Ulf Wiger authored
1
2
bb57e23 types added in exprecs
Ulf Wiger authored
3 #The parse_trans application#
049ea9f merged klajo-form-injection
Ulf Wiger authored
4
5
c0bfe08 generated edown docs + added README
Ulf Wiger authored
6 __Authors:__ Ulf Wiger ([`ulf.wiger@erlang-consulting.com`](mailto:ulf.wiger@erlang-consulting.com)).
049ea9f merged klajo-form-injection
Ulf Wiger authored
7
c0bfe08 generated edown docs + added README
Ulf Wiger authored
8 A generic parse transform library
9 This library is intended to simplify the task of writing parse transform
10 modules for Erlang.
11
12
13
bb57e23 types added in exprecs
Ulf Wiger authored
14 #Introduction to parse transforms#
c0bfe08 generated edown docs + added README
Ulf Wiger authored
15
16
17
18
bb57e23 types added in exprecs
Ulf Wiger authored
19 ##The simplest transform##
049ea9f merged klajo-form-injection
Ulf Wiger authored
20
c0bfe08 generated edown docs + added README
Ulf Wiger authored
21
22
23
24 The very simplest transform we can make is one that doesn't
25 change a thing. For convenience, we will at least print the forms.
26 This will enlighten us as to what the forms actually look like.
27
28 <pre>
29 -module(test_pt).
30
31 -export([parse_transform/2]).
32
33 parse_transform(Forms, _Options) ->
60299e7 cleanup, type fixes and new rebar
Ulf Wiger authored
34 io:fwrite("Forms = ~p~n", [Forms]),
35 Forms.
c0bfe08 generated edown docs + added README
Ulf Wiger authored
36 </pre>
37
38
39
40 Trying this with a very simple module:
41
42 <pre>
43 -module(ex1).
44 -export([add/2]).
45
46 add(X,Y) ->
60299e7 cleanup, type fixes and new rebar
Ulf Wiger authored
47 X + Y.
c0bfe08 generated edown docs + added README
Ulf Wiger authored
48 </pre>
49
50 <pre>
51 1> c(ex1, [{parse_transform,test_pt}]).
52 Forms = [{attribute,1,file,{"./ex1.erl",1}},
60299e7 cleanup, type fixes and new rebar
Ulf Wiger authored
53 {attribute,1,module,ex1},
54 {attribute,2,export,[{add,2}]},
55 {function,4,add,2,
56 [{clause,4,
57 [{var,4,'X'},{var,4,'Y'}],
58 [],
59 [{op,5,'+',{var,5,'X'},{var,5,'Y'}}]}]},
60 {eof,6}]
c0bfe08 generated edown docs + added README
Ulf Wiger authored
61 {ok,ex1}
62 </pre>
63
64
65
bb57e23 types added in exprecs
Ulf Wiger authored
66 ##`transform/4`##
049ea9f merged klajo-form-injection
Ulf Wiger authored
67
c0bfe08 generated edown docs + added README
Ulf Wiger authored
68
69
70 ...
71
72
73
74
bb57e23 types added in exprecs
Ulf Wiger authored
75 #Current limitations#
049ea9f merged klajo-form-injection
Ulf Wiger authored
76
c0bfe08 generated edown docs + added README
Ulf Wiger authored
77
78
79 ...
80
81
bb57e23 types added in exprecs
Ulf Wiger authored
82 ##Modules##
049ea9f merged klajo-form-injection
Ulf Wiger authored
83
c0bfe08 generated edown docs + added README
Ulf Wiger authored
84
85 <table width="100%" border="0" summary="list of modules">
beb658a Add 'deps/parse_trans/' from commit '0ec1da744e0c7b42994c729ffaedae69…
Yurii Rashkovskii authored
86 <tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/ct_expand.md" class="module">ct_expand</a></td></tr>
87 <tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/exprecs.md" class="module">exprecs</a></td></tr>
88 <tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/parse_trans.md" class="module">parse_trans</a></td></tr>
89 <tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/parse_trans_codegen.md" class="module">parse_trans_codegen</a></td></tr>
90 <tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/parse_trans_mod.md" class="module">parse_trans_mod</a></td></tr>
91 <tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/parse_trans_pp.md" class="module">parse_trans_pp</a></td></tr></table>
049ea9f merged klajo-form-injection
Ulf Wiger authored
92
Something went wrong with that request. Please try again.