package yuujinchou
Library
Module
Module type
Parameter
Class
Class type
The Modifier
module implements the engine running the modifiers of type Language.t
.
type ('data, 'tag, 'hook, 'context) handler = {
not_found : 'context option -> Trie.bwd_path -> unit;
(*
*)not_found ctx prefix
is called when the engine expects at least one binding within the subtree atprefix
but could not find any, wherectx
is the context passed toS.modify
. Modifiers such asLanguage.any
,Language.only
,Language.none
, and a few other modifiers expect at least one matching binding. For example, the modifierLanguage.except
["x"; "y"]
expects that there was already something under the subtree atx.y
. If there were actually no names with the prefixx.y
, then the modifier will trigger this effect withprefix
beingEmp #< "x" #< "y"
.shadow : 'context option -> Trie.bwd_path -> ('data * 'tag) -> ('data * 'tag) -> 'data * 'tag;
(*
*)shadow ctx path x y
is called when itemy
is being assigned topath
butx
is already bound atpath
, wherectx
is the context passed toS.modify
. Modifiers such asLanguage.renaming
andLanguage.union
could lead to bindings having the same name, and when that happens, this function is called to resolve the conflicting bindings. To implement silent shadowing, one can simply return itemy
. One can also employ a more sophisticated strategy to implement type-directed disambiguation.hook : 'context option -> Trie.bwd_path -> 'hook -> ('data, 'tag) Trie.t -> ('data, 'tag) Trie.t;
(*
*)hook prefix id input
is called when processing the modifiers created byLanguage.hook
, wherectx
is the context passed toS.modify
. When the engine encounters the modifierLanguage.hook
id
while handling the subtreeinput
atprefix
, it will callhook prefix id input
and replace the existing subtreeinput
with the return value.
}
The type of effect handlers used in this module.
module type Param = sig ... end
The parameters of an engine.
module type S = sig ... end
The signature of the engine.