Corner.Ast (corner v0.1.3)
Helpers for operating AST.
The first parameter suggested to be an ast for all of functions
exception of make_map/2
in this module.
Link to this section Summary
Functions
Check if the clauses have the same arity.
Get the real arguments after return from Macro.decompose_call/1
.
Check if the ast is compsed type.
Check if the ast is a map.
Check if the ast is a pin expression.
Check if the ast is a Regex.
Check if the ast is a struct.
Check if the ast is a tuple.
Check if the ast
is the ast of a variable.
Convert list to tuple.
Make a map for the give keys
and values
.
Get the keys in the ast of the map.
If the ast is a tuple, return the size of the tuple.
Convert tuple to list.
Link to this section Functions
clauses_arity_check(list)
Check if the clauses have the same arity.
If all caluses have some arity, return {:ok, arity}
,
else return :error
.
get_args(ast)
Get the real arguments after return from Macro.decompose_call/1
.
is_composed_type?(ast)
Check if the ast is compsed type.
Map, tuple, and struct and list are reconized as compsed type.
is_map?(arg1)
Check if the ast is a map.
An ast of a struct is also reconized as a map, but a variable which binding a value of map or struct is not.
is_pin?(arg1)
Check if the ast is a pin expression.
is_regex?(arg1)
Check if the ast is a Regex.
sigil_r/1
and sigile_R/1
are reconized as regex.
But a variable whicn biding a Regex strcut not regconized as a regex.
is_struct?(arg1)
Check if the ast is a struct.
A variable which bidnding a value of one struct is recongized as variable not a struct.
is_tuple?(arg1)
Check if the ast is a tuple.
is_variable?(ast)
Check if the ast
is the ast of a variable.
list_to_tuple(ast)
Convert list to tuple.
make_map(keys, values)
Make a map for the give keys
and values
.
map_keys(arg)
Get the keys in the ast of the map.
map_values(arg)
tuple_size(ast)
If the ast is a tuple, return the size of the tuple.
tuple_to_list(ast)
Convert tuple to list.