module Ast_mapper:sig
..end
type
mapper = {
val default_mapper : mapper
val tool_name : unit -> string
"ocamlc"
, "ocamlopt"
, "ocamldoc"
, "ocamldep"
,
"ocaml"
, ... Some global variables that reflect command-line
options are automatically synchronized between the calling tool
and the ppx preprocessor: Clflags.include_dirs
,
Config.load_path
, Clflags.open_modules
, Clflags.for_package
,
Clflags.debug
.val apply : source:string -> target:string -> mapper -> unit
source
file and put the result in the
target
file. The structure
or signature
field of the mapper
is applied to the implementation or interface.val run_main : (string list -> mapper) -> unit
Location.input_name
. This
function implements proper error reporting for uncaught
exceptions.val register_function : (string -> (string list -> mapper) -> unit) ref
val register : string -> (string list -> mapper) -> unit
register_function
. The default behavior is to run the
mapper immediately, taking arguments from the process command
line. This is to support a scenario where a mapper is linked as a
stand-alone executable.
It is possible to overwrite the register_function
to define
"-ppx drivers", which combine several mappers in a single process.
Typically, a driver starts by defining register_function
to a
custom implementation, then lets ppx rewriters (linked statically
or dynamically) register themselves, and then run all or some of
them. It is also possible to have -ppx drivers apply rewriters to
only specific parts of an AST.
The first argument to register
is a symbolic name to be used by
the ppx driver.
val map_opt : ('a -> 'b) -> 'a option -> 'b option
val extension_of_error : Location.error -> Parsetree.extension
val attribute_of_warning : Location.t -> string -> Parsetree.attribute
val ppx_context : tool_name:string -> unit -> Parsetree.attribute