An Erlang to Elixir Transpiler
Check otp.ex for examples of the output generated by this tool.
Here are some blogposts with more details:
- http://marianoguerra.org/posts/elixir-flavoured-erlang-an-erlang-to-elixir-transpiler/
- http://marianoguerra.org/posts/elixir-flavoured-erlang-who-transpiles-the-transpiler/
- http://marianoguerra.org/posts/how-to-transpile-a-complex-erlang-project-with-elixir-flavoured-erlang-erldns/
An LFE (Lisp Flavoured Erlang) to Elixir Transpiler
./efe pp-lfe file.conf my-code.lfe
Try some examples:
make lfe-test
Check:
- out/samples/ping_pong.ex
- out/samples/sample-module.ex
- out/samples/simple-erl-exercises.ex
rebar3 escriptize
cp _build/default/bin/efe .
The general format is:
efe pp file.conf file.erl+
where file.conf
is a config file with the following format:
#{
% blobs, if relative (start with .) are joined with current erlang file directory
includes => [".", "../../*/include", "../../*/src"],
% map of macro names and what they should expand to
macros => #{'VSN' => '1.0', 'COMPILER_VSN' => '2.0'},
encoding => latin1, % or utf8
output_dir => "./out",
% prefix to add to compiled modules, useful when transpiling otp to avoid
% conflicts
mod_prefix => "m_"
}.
Here is the config used to transpile cowboy
#{
includes => [".", "../include", "../../"],
macros => #{},
encoding => utf8,
output_dir => "./out"
}.
git clone [email protected]:erlang/otp.git
mkdir -p out
./efe pp otp.conf otp/lib/*/src/*.erl otp/erts/preloaded/src/.erl
Results in out/otp/
git clone https://github.com/ninenines/cowboy.git
# need header files from cowlib
git clone https://github.com/ninenines/cowlib.git
mkdir -p out
./efe pp cowboy.conf cowboy/src/*.erl
Results in out/cowboy