Formular.Compiler (formular v0.4.2)

This module is used to compile the code into Elixir modules.

Summary

Functions

Create an Elixir module from the raw code (AST).

Functions

create_module(module, raw_ast, env \\ %Macro.Env{})

@spec create_module(module(), Macro.t(), Macro.Env.t()) :: {:module, module()}

Create an Elixir module from the raw code (AST).

The created module will have to public functions:

  • run/1 which accepts a binding keyword list and execute the code.
  • used_variables/0 which returns a list of variable names that have been used in the code.

Usage

iex> ast = quote do: a + b
...> Formular.Compiler.create_module(MyMod, ast)
...> MyMod.run(a: 1, b: 2)
3

...> MyMod.used_variables()
[:a, :b]