Permalink
Browse files

Add 'deps/parse_trans/' from commit '0ec1da744e0c7b42994c729ffaedae69…

…6993bfa3'

git-subtree-dir: deps/parse_trans
git-subtree-mainline: 099cff5
git-subtree-split: 0ec1da7
  • Loading branch information...
2 parents 099cff5 + 0ec1da7 commit beb658a7899f45d5b207be11e69247f7be07d365 Yurii Rashkovskii committed Apr 24, 2012
Showing with 4,661 additions and 0 deletions.
  1. +6 −0 deps/parse_trans/.gitignore
  2. +16 −0 deps/parse_trans/Makefile
  3. +92 −0 deps/parse_trans/README.md
  4. +92 −0 deps/parse_trans/doc/README.md
  5. +102 −0 deps/parse_trans/doc/ct_expand.md
  6. +4 −0 deps/parse_trans/doc/edoc-info
  7. BIN deps/parse_trans/doc/erlang.png
  8. +427 −0 deps/parse_trans/doc/exprecs.md
  9. +55 −0 deps/parse_trans/doc/overview.edoc
  10. +483 −0 deps/parse_trans/doc/parse_trans.md
  11. +163 −0 deps/parse_trans/doc/parse_trans_codegen.md
  12. +118 −0 deps/parse_trans/doc/parse_trans_mod.md
  13. +103 −0 deps/parse_trans/doc/parse_trans_pp.md
  14. +55 −0 deps/parse_trans/doc/stylesheet.css
  15. 0 deps/parse_trans/ebin/.gitignore
  16. +30 −0 deps/parse_trans/examples/Makefile
  17. +38 −0 deps/parse_trans/examples/ct_expand_test.erl
  18. +8 −0 deps/parse_trans/examples/ex1.erl
  19. +62 −0 deps/parse_trans/examples/ex_codegen.erl
  20. +15 −0 deps/parse_trans/examples/ex_gproc_send_xform.erl
  21. +34 −0 deps/parse_trans/examples/exprecs_eunit.erl
  22. +10 −0 deps/parse_trans/examples/test.erl
  23. +16 −0 deps/parse_trans/examples/test_exprecs.erl
  24. +23 −0 deps/parse_trans/examples/test_exprecs_vsns.erl
  25. +8 −0 deps/parse_trans/examples/test_pt.erl
  26. +17 −0 deps/parse_trans/examples/test_transform_mod.erl
  27. +25 −0 deps/parse_trans/include/codegen.hrl
  28. +25 −0 deps/parse_trans/include/exprecs.hrl
  29. BIN deps/parse_trans/rebar
  30. +12 −0 deps/parse_trans/rebar.config
  31. +236 −0 deps/parse_trans/src/ct_expand.erl
  32. +1,194 −0 deps/parse_trans/src/exprecs.erl
  33. +30 −0 deps/parse_trans/src/parse_trans.app.src
  34. +703 −0 deps/parse_trans/src/parse_trans.erl
  35. +230 −0 deps/parse_trans/src/parse_trans_codegen.erl
  36. +109 −0 deps/parse_trans/src/parse_trans_mod.erl
  37. +120 −0 deps/parse_trans/src/parse_trans_pp.erl
@@ -0,0 +1,6 @@
+examples/*.beam
+examples/*.xf*
+ebin
+*~
+*/*~
+.eunit
View
@@ -0,0 +1,16 @@
+.PHONY: rel all clean
+
+all: compile
+
+compile:
+ ./rebar compile
+
+clean:
+ ./rebar clean
+
+test:
+ ./rebar eunit
+
+doc:
+ ./rebar doc
+
View
@@ -0,0 +1,92 @@
+
+
+#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/master/doc/ct_expand.md" class="module">ct_expand</a></td></tr>
+<tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/exprecs.md" class="module">exprecs</a></td></tr>
+<tr><td><a href="http://github.com/esl/parse_trans/blob/master/doc/parse_trans.md" class="module">parse_trans</a></td></tr>
+<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>
+<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>
+<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>
+
@@ -0,0 +1,92 @@
+
+
+#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="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>
+
@@ -0,0 +1,102 @@
+
+
+#Module ct_expand#
+* [Description](#description)
+* [Data Types](#types)
+* [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"></a>
+
+##Description##
+
+
+
+
+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.
+
+
+
+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]`.
+
+
+
+ct_expand has now been extended to also evaluate calls to local functions.
+See examples/ct_expand_test.erl for some examples.
+
+
+
+A debugging facility exists: passing the option {ct_expand_trace, Flags} as an option,
+or adding a compiler attribute -ct_expand_trace(Flags) will enable a form of call trace.
+
+`Flags` can be `[]` (no trace) or `[F]`, where `F` is `c` (call trace),
+`r` (return trace), or `x` (exception trace)'.
+
+<a name="types"></a>
+
+##Data Types##
+
+
+
+
+###<a name="type-form">form()</a>##
+
+
+
+<pre>form() = any()</pre>
+
+
+
+###<a name="type-forms">forms()</a>##
+
+
+
+<pre>forms() = [<a href="#type-form">form()</a>]</pre>
+
+
+
+###<a name="type-options">options()</a>##
+
+
+
+<pre>options() = [{atom(), any()}]</pre>
+<a name="index"></a>
+
+##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>
+
+##Function Details##
+
+<a name="parse_transform-2"></a>
+
+###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>
+<br></br>
+
+
@@ -0,0 +1,4 @@
+{application,parse_trans}.
+{packages,[]}.
+{modules,[ct_expand,exprecs,parse_trans,parse_trans_codegen,parse_trans_mod,
+ parse_trans_pp]}.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit beb658a

Please sign in to comment.