Module ktn_code

Data Types

tree_node()

tree_node() = #{type => tree_node_type(), attrs => #{}, node_attrs => #{}, content => [tree_node()]}

tree_node_type()

tree_node_type() = root | function | clause | match | tuple | atom | integer | float | string | char | binary | binary_element | var | call | remote | 'case' | case_expr | case_clauses | 'fun' | named_fun | query | 'try' | try_catch | try_case | try_after | 'if' | 'catch' | 'receive' | receive_after | receive_case | nil | cons | map | map_field_assoc | map_field_exact | lc | lc_expr | generate | bc | bc_expr | b_generate | op | record | record_field | record_index | block | module | type | callback | export | export_type | remote_type | type | ann_type | paren_type | any

Function Index

attr/2
beam_to_erl/2If the beam was not compiled with debug_info the code generated by this function will look really ugly.
beam_to_string/1If the beam was not compiled with debug_info the code generated by this function will look really ugly.
consult/1Like file:consult/1 but for strings and binaries.
content/1
eval/1Evaluates the erlang expression in the string provided.
eval/2*
get_location/1*
get_text/1*
is_dot/1*
node_attr/2
parse_tree/1Equivalent to parse_tree([], Source).
parse_tree/2
parse_tree/3Parses code in a string or binary format and returns the parse tree.
source_encoding/1*
split_when/2*Splits a list whenever an element satisfies the When predicate.
split_when/3*
to_map/1*Converts a parse tree form the abstract format to a map based repr.
to_str/1
token_to_map/1*
type/1

Function Details

attr/2

attr(Key::term(), Node::tree_node()) -> term() | undefined

beam_to_erl/2

beam_to_erl(BeamPath::beam_lib:beam(), ErlPath::string()) -> ok

If the beam was not compiled with debug_info the code generated by this function will look really ugly

beam_to_string/1

beam_to_string(BeamPath::beam_lib:beam()) -> {ok, string()} | {error, beam_lib, term()}

If the beam was not compiled with debug_info the code generated by this function will look really ugly

consult/1

consult(Source::string() | binary()) -> [term()]

Like file:consult/1 but for strings and binaries.

content/1

content(Node::tree_node()) -> [tree_node()]

eval/1

eval(Source::string() | binary()) -> term()

Evaluates the erlang expression in the string provided.

eval/2 *

eval(Source::string() | binary(), Bindings::orddict:orddict()) -> term()

get_location/1 *

get_location(Attrs) -> any()

get_text/1 *

get_text(Attrs) -> any()

is_dot/1 *

is_dot(X1::tuple()) -> boolean()

node_attr/2

node_attr(Key::term(), Node::tree_node()) -> term() | undefined

parse_tree/1

parse_tree(Source::string() | binary()) -> tree_node()

Equivalent to parse_tree([], Source).

parse_tree/2

parse_tree(IncludeDirs::[string()], Source::string() | binary()) -> tree_node()

parse_tree/3

parse_tree(IncludeDirs::[string()], FileName::file:name_all() | undefined, Source::string() | binary()) -> tree_node()

Parses code in a string or binary format and returns the parse tree.

source_encoding/1 *

source_encoding(Source::binary() | list()) -> latin1 | utf8

split_when/2 *

split_when(When::function(), List::list()) -> list()

Splits a list whenever an element satisfies the When predicate. Returns a list of lists where each list includes the matched element as its last one. E.g. split_when(fun (X) -> $. == X end, "a.b.c") = ["a.", "b.", "c"] NOTE: Copied from ktn_lists not to bring the whole erlang-katana repo as a dependency here

split_when/3 *

split_when(When, Tail, Results) -> any()

to_map/1 *

to_map(ListParsed::term()) -> tree_node() | [tree_node()]

Converts a parse tree form the abstract format to a map based repr.

To do

to_str/1

to_str(Arg::binary() | list() | atom() | integer()) -> string()

token_to_map/1 *

token_to_map(X1) -> any()

type/1

type(X1::tree_node()) -> atom()


Generated by EDoc