summaryrefslogtreecommitdiff
path: root/parsing/ast_mapper.mli
diff options
context:
space:
mode:
Diffstat (limited to 'parsing/ast_mapper.mli')
-rw-r--r--parsing/ast_mapper.mli45
1 files changed, 25 insertions, 20 deletions
diff --git a/parsing/ast_mapper.mli b/parsing/ast_mapper.mli
index bf23a7af34..651717e5f1 100644
--- a/parsing/ast_mapper.mli
+++ b/parsing/ast_mapper.mli
@@ -62,15 +62,17 @@ val default_mapper: mapper
val apply: source:string -> target:string -> mapper -> unit
- (** Apply a mapper to a dumped parsetree found in the [source] file
- and put the result in the [target] file. *)
-
-val main: mapper -> unit
- (** Entry point to call to implement a standalone -ppx rewriter
- from a mapper object. *)
+(** Apply a mapper (parametrized by the unit name) to a dumped
+ parsetree found in the [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
- (** Same as [main], but with extra arguments from the command line. *)
+(** Entry point to call to implement a standalone -ppx rewriter from a
+ mapper, parametrized by the command line arguments. The current
+ unit name can be obtained from [Location.input_name]. This
+ function implements proper error reporting for uncaught
+ exceptions. *)
(** {2 Registration API} *)
@@ -78,19 +80,22 @@ val register_function: (string -> (string list -> mapper) -> unit) ref
val register: string -> (string list -> mapper) -> unit
- (** Apply the [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. *)
+(** Apply the [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. *)
+
(** {2 Convenience functions to write mappers} *)