Legend:
Library
Module
Module type
Parameter
Class
Class type
Local rewriting rules.
This module lets you define local rewriting rules, such as extension point expanders. It is not completely generic and you cannot define any kind of rewriting, it currently focuses on what is commonly used. New scheme can be added on demand.
We have some ideas to make this fully generic, but this hasn't been a priority so far.
val special_function :
Base.String.t->(Ppxlib_ast__.Import.Parsetree.expression ->Ppxlib_ast__.Import.Parsetree.expression Base.Option.t)->t
special_function id expand is a rule to rewrite a function call at parsing time. id is the identifier to match on and expand is used to expand the full function application (it gets the Pexp_apply node). If the function is found in the tree without being applied, expand gets only the identifier (Pexp_ident node) so you should handle both cases.
If id is an operator identifier and contains dots, it should be parenthesized (e.g. "(+.+)").
expand must decide whether the expression it receive can be rewritten or not. Especially ppxlib makes the assumption that expand is idempotent. It will loop if it is not.
constant kind suffix expander Registers an extension for transforming constants literals, based on the suffix character.
The rest of this API is for rewriting rules that apply when a certain attribute is present. The API is not complete and is currently only enough to implement deriving.
Match the attribute on a group of items, such as a group of recursive type definitions (Pstr_type, Psig_type). The expander will be triggered if any of the item has the attribute. The expander is called as follow:
expand ~loc ~path rec_flag items values
where values is the list of values associated to the attribute for each item in items. expand must return a list of element to add after the group. For instance a list of structure item to add after a group of type definitions.
val attr_str_type_decl :
(Ppxlib_ast__.Import.Parsetree.structure_item,
Ppxlib_ast__.Import.Parsetree.type_declaration,
_)attr_group_inline
val attr_sig_type_decl :
(Ppxlib_ast__.Import.Parsetree.signature_item,
Ppxlib_ast__.Import.Parsetree.type_declaration,
_)attr_group_inline
val attr_str_type_decl_expect :
(Ppxlib_ast__.Import.Parsetree.structure_item,
Ppxlib_ast__.Import.Parsetree.type_declaration,
_)attr_group_inline
The _expect variants are for producing code that is compared to what the user wrote in the source code.
val attr_sig_type_decl_expect :
(Ppxlib_ast__.Import.Parsetree.signature_item,
Ppxlib_ast__.Import.Parsetree.type_declaration,
_)attr_group_inline