Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Parse transform utilities for Erlang

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc
Octocat-spinner-32 ebin
Octocat-spinner-32 examples
Octocat-spinner-32 include
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.md
Octocat-spinner-32 rebar
Octocat-spinner-32 rebar.config
README.md

The parse_trans application

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_mod
parse_trans_pp
Something went wrong with that request. Please try again.