parse_trans/doc
Klas Johansson 1ec65427e4 Inject an abstract form when '$form' is seen
'$form' works much like '$var', only that it makes it possible to
inject ready-made abstract forms into the generated
functions/expressions.  The following call:

  gen(Name, F) ->
     codegen:gen_function(Name, fun(X) -> X =:= {'$form',F} end).

generates the following if called like this: gen(is_foo, {atom,0,foo})

  is_foo(X) ->
     X =:= foo.
2010-10-26 21:23:11 +02:00
..
ct_expand.md Inject an abstract form when '$form' is seen 2010-10-26 21:23:11 +02:00
edoc-info Refactor pretty-printing + doc improvements 2010-09-03 14:36:35 +02:00
erlang.png forgot to add new files 2009-09-11 09:29:39 +00:00
exprecs.md Inject an abstract form when '$form' is seen 2010-10-26 21:23:11 +02:00
overview.edoc ported ct_expand, bug fixes 2009-09-11 09:27:16 +00:00
parse_trans_codegen.md Inject an abstract form when '$form' is seen 2010-10-26 21:23:11 +02:00
parse_trans_pp.md Inject an abstract form when '$form' is seen 2010-10-26 21:23:11 +02:00
parse_trans.md Inject an abstract form when '$form' is seen 2010-10-26 21:23:11 +02:00
README.md generated edown docs + added README 2010-10-23 21:06:20 +02:00
stylesheet.css forgot to add new files 2009-09-11 09:29:39 +00:00

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

-module(test_pt).

-export([parse_transform/2]).

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

Trying this with a very simple module:

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

add(X,Y) ->
    X + Y.
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}

##transform/4##

...

#Current limitations#

...

##Modules##

ct_expand
exprecs
parse_trans
parse_trans_codegen
parse_trans_pp