Function Decorating v0.0.3 FnDef
Summary
Functions
Generate AST for argument AST and its mediator
Add mediator argument to a function argument ast
Add meidator arguments to a function arguments list ast
Parse a function call into its parts: name and arguments
Functions
Generate AST for argument AST and its mediator.
Examples
iex> FnDef.calc_full_arg(quote context: __MODULE__ do first_name end, quote context: __MODULE__ do arg0 end)
{:=, [], [{:first_name, [], __MODULE__}, {:arg0, [], __MODULE__}]}
Add mediator argument to a function argument ast.
Returns {decorated argument name, decorated argument ast}
Examples
iex> FnDef.decorate_arg({quote context: __MODULE__ do first_name end, 0})
{{:arg0, [], FnDef}, {:=, [], [{:first_name, [], __MODULE__}, {:arg0, [], FnDef}]}}
Specs
decorate_args(list) :: {list, list}
Add meidator arguments to a function arguments list ast.
Mainly for the availabity to print unbounded arguments in a function call.
say(word) -> say(word = arg0)
Returns {[args names], [decorated args ast]}
Examples
iex> FnDef.decorate_args(quote context: __MODULE__ do [a, b, _] end)
{[{:arg0, [], FnDef}, {:arg1, [], FnDef}, {:arg2, [], FnDef}],
[{:=, [], [{:a, [], __MODULE__}, {:arg0, [], FnDef}]},
{:=, [], [{:b, [], __MODULE__}, {:arg1, [], FnDef}]},
{:=, [], [{:_, [], __MODULE__}, {:arg2, [], FnDef}]}]}