register_transformation name
registers a code transformation.
name
is a logical name for the transformation (such as sexp_conv
or
bin_prot
). It is mostly used for debugging purposes.
extensions
is a list of context independant extension point expanders. This is what
most code transformation should use. Extension expanders from all registered
transformations are applied at the same time, before any other
transformations. Moreover they are applied in a top-down manner, for the following
reason:
%here
(from ppx_here) will normally expand to a record of type
Lexing.position
. However when used inside %sexp
(from ppx_sexp_value) it will
expand to the human-readable sexp representation of a source code position.impl
is an optional function that is applied on implementation files and intf
is
an optional function that is applied on interface files. These two functions are
applied on the AST of the whole file. They should only be used in specific cases:
1. the transformation needs to add an header and/or footer 2. the transformation expands extension points that depend on the context
Same as:
register_transformation
~name
~impl
~intf
()