Hi,
I have a question where I could check how the Elixir / Erlang compiler works? Is there any public source code or is it top secret?
Hi,
I have a question where I could check how the Elixir / Erlang compiler works? Is there any public source code or is it top secret?
Ok so you have to be level over 9000 to see the source code of either⊠nope
All is on Github. Elixirâs public repo is here:
and Erlangâs:
Both repositories contain compiler as well as some core tools + standard libraries.
Hehe I saw the repos I just expected something more than I found Anyway, thanks
oh well. In Erlang peek into lib/compiler. Elixir hasnât got dedicated directory I think but you can follow the âmix compileâ task execution from https://github.com/elixir-lang/elixir/blob/master/lib/mix/lib/mix/compilers/elixir.ex to locate relevant code. Most of the compiler compiler thing is in written in Erlang I believe: https://github.com/elixir-lang/elixir/tree/master/lib/elixir/src
You are correct. Elixir is parsed using the Leex Lexical Analizer Generator and the Yecc Parser Generator.
The grammar file that Yecc will use to parse Elixir code is elixir/lib/elixir/src/elixir_parser.yrl at main · elixir-lang/elixir · GitHub. This is the place where things like operator precedence are stated, and is probably what you were looking for.
Itâs interesting to note that Elixirâs grammar is quite small, as nearly everything that seems a âkeywordâ in Elixir is actually just a macro or a function. The only things that are bootstrapped in Erlang to allow the Kernel elixir module to compile are found in the elixir_bootstrap.erl module: elixir/lib/elixir/src/elixir_bootstrap.erl at main · elixir-lang/elixir · GitHub
Itâs quite interesting to see how e.g. defmodule
is implemented in the Kernel module itself.