ExDiceRoller v0.3.0-alpha ExDiceRoller.Compiler
Provides functionality for compiling expressions into ready-to-execute functions.
Link to this section Summary
Functions
Compiles a provided t:Parser.expression/0
into an anonymous function
Shows the nested functions and relationships of a compiled function
Link to this section Types
Link to this section Functions
Compiles a provided t:Parser.expression/0
into an anonymous function.
{:ok, roll_fun} = ExDiceRoller.compile("1dx+10")
{:ok, _}
ExDiceRoller.execute(roll_fun, x: 5)
11
ExDiceRoller.execute(roll_fun, x: "10d100")
523
Shows the nested functions and relationships of a compiled function.
> {:ok, fun} = ExDiceRoller.compile("1d8+(1-x)d(2*y)")
{:ok, #Function<0.84780260/1 in ExDiceRoller.Compiler.compile_add/4>}
> ExDiceRoller.Compiler.fun_info fun
{#Function<0.16543174/1 in ExDiceRoller.Compiler.compile_add/4>,
:"-compile_add/4-fun-0-",
[
{#Function<12.16543174/1 in ExDiceRoller.Compiler.compile_roll/4>,
:"-compile_roll/4-fun-3-", [1, 8]},
{#Function<9.16543174/1 in ExDiceRoller.Compiler.compile_roll/4>,
:"-compile_roll/4-fun-0-",
[
{#Function<15.16543174/1 in ExDiceRoller.Compiler.compile_sub/4>,
:"-compile_sub/4-fun-2-",
[
1,
{#Function<16.16543174/1 in ExDiceRoller.Compiler.compile_var/1>,
:"-compile_var/1-fun-0-", ['x']}
]},
{#Function<8.16543174/1 in ExDiceRoller.Compiler.compile_mul/4>,
:"-compile_mul/4-fun-2-",
[
2,
{#Function<16.16543174/1 in ExDiceRoller.Compiler.compile_var/1>,
:"-compile_var/1-fun-0-", ['y']}
]}
]}
]}