Skip to content

Elixir Flavoured Erlang: an Erlang to Elixir Transpiler

License

Notifications You must be signed in to change notification settings

marianoguerra/efe

Repository files navigation

Elixir Flavoured Erlang

An Erlang to Elixir Transpiler

Check otp.ex for examples of the output generated by this tool.

Here are some blogposts with more details:

EFLFE: Elixir Flavoured Lisp Flavoured Erlang

An LFE (Lisp Flavoured Erlang) to Elixir Transpiler

⚠️ Work in Progress ⚠️

./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

Build

rebar3 escriptize
cp _build/default/bin/efe .

Run

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"
}.

Transpiling OTP

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/

Transpiling Cowboy

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

About

Elixir Flavoured Erlang: an Erlang to Elixir Transpiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages