7.2 KiB
Module parse_trans
#Module parse_trans#
- Description
- Function Index
- Function Details
Generic parse transform library for Erlang.
Authors: : Ulf Wiger (
ulf.wiger@erlang-consulting.com
).
##Description##
Generic parse transform library for Erlang.
...
##Function Index##
context/2 | Accessor function for the Context record. |
depth_first/4 | |
do_depth_first/4 | |
do_insert_forms/4 | |
do_inspect/4 | |
do_transform/4 | |
error/3 | . |
format_error/1 | |
function_exists/3 | Checks whether the given function is defined in Forms. |
get_attribute/2 | Returns the value of the first occurence of attribute A. |
get_file/1 | Returns the name of the file being compiled. |
get_module/1 | Returns the name of the module being compiled. |
get_orig_syntax_tree/1 | . |
get_pos/1 | Tries to retrieve the line number from an erl_syntax form. |
initial_context/2 | Initializes a context record. |
inspect/4 | Equvalent to do_inspect(Fun,Acc,Forms,initial_context(Forms,Options)). |
optionally_pretty_print/3 | |
pp_beam/1 | Reads debug_info from the beam file Beam and returns a string containing the pretty-printed corresponding erlang source code. |
pp_beam/2 | Reads debug_info from the beam file Beam and pretty-prints it as Erlang source code, storing it in the file Out. |
pp_src/2 | Pretty-prints the erlang source code corresponding to Forms into Out. |
revert/1 | Reverts back from Syntax Tools format to Erlang forms. |
top/3 | |
transform/4 | Makes one pass. |
##Function Details##
###context/2##
context(X1::Attr, Context) -> any()
* Attr = module | function | arity | options
Accessor function for the Context record.
###depth_first/4##
depth_first(Fun, Acc, Forms, Options) -> any()
###do_depth_first/4##
do_depth_first(F, Acc, Forms, Context) -> any()
###do_insert_forms/4##
do_insert_forms(X1, Insert, Forms, Context) -> any()
###do_inspect/4##
do_inspect(F, Acc, Forms, Context) -> any()
###do_transform/4##
do_transform(F, Acc, Forms, Context) -> any()
###error/3##
error(R::Reason, F::Form, I::Info) -> [throw()](#type-throw)
* Info = [{Key, Value}]
Used to report errors detected during the parse transform.
###format_error/1##
format_error(X1) -> any()
###function_exists/3##
function_exists(Fname::atom(), Arity::integer(), Forms) -> [boolean()](#type-boolean)
Checks whether the given function is defined in Forms.
###get_attribute/2##
get_attribute(A, Forms) -> any()
* A = atom()
Returns the value of the first occurence of attribute A.
###get_file/1##
get_file(Forms) -> string()
Returns the name of the file being compiled.
###get_module/1##
get_module(Forms) -> atom()
Returns the name of the module being compiled.
###get_orig_syntax_tree/1##
get_orig_syntax_tree(File) -> Forms
Fetches a Syntax Tree representing the code before pre-processing, that is, including record and macro definitions. Note that macro definitions must be syntactically complete forms (this function uses epp_dodger).
###get_pos/1##
get_pos(I::list()) -> integer()
Tries to retrieve the line number from an erl_syntax form. Returns a (very high) dummy number if not successful.
###initial_context/2##
initial_context(Forms, Options) -> #context{}
Initializes a context record. When traversing through the form list, the context is updated to reflect the current function and arity. Static elements in the context are the file name, the module name and the options passed to the transform function.
###inspect/4##
inspect(F::Fun, Acc::Forms, Forms::Acc, Options) -> NewAcc
* Fun = function()
Equvalent to do_inspect(Fun,Acc,Forms,initial_context(Forms,Options)).
###optionally_pretty_print/3##
optionally_pretty_print(Result, Options, Context) -> any()
###pp_beam/1##
pp_beam(Beam::[filename()](#type-filename)) -> string() | {error, Reason}
Reads debug_info from the beam file Beam and returns a string containing the pretty-printed corresponding erlang source code.
###pp_beam/2##
pp_beam(Beam::[filename()](#type-filename), Out::[filename()](#type-filename)) -> ok | {error, Reason}
Reads debug_info from the beam file Beam and pretty-prints it as Erlang source code, storing it in the file Out.
###pp_src/2##
pp_src(Res::Forms, Out::[filename()](#type-filename)) -> ok
Pretty-prints the erlang source code corresponding to Forms into Out
###revert/1##
revert(Tree) -> Forms
Reverts back from Syntax Tools format to Erlang forms.
Note that the Erlang forms are a subset of the Syntax Tools syntax tree, so this function is safe to call even on a list of regular Erlang forms.
###top/3##
top(F, Forms, Options) -> any()
###transform/4##
transform(Fun, Acc, Forms, Options) -> {TransformedForms, NewAcc}
* Fun = function()
-
Options = [{Key, Value}]
Makes one pass Generated by EDoc, Oct 23 2010, 21:00:44.