diff --git a/src/Modifier.ml b/src/Modifier.ml index 9ebc092f..28e10bdb 100644 --- a/src/Modifier.ml +++ b/src/Modifier.ml @@ -8,7 +8,7 @@ module type S = ModifierSigs.S with module Language := Language module Make (P : Param) : S with module P = P = struct -module Language = Language + module Language = Language module P = P include P diff --git a/src/ModifierSigs.ml b/src/ModifierSigs.ml index e8028c08..fa61f8bf 100644 --- a/src/ModifierSigs.ml +++ b/src/ModifierSigs.ml @@ -18,9 +18,17 @@ end module type Handler = sig module P : Param + val not_found : P.context option -> Trie.bwd_path -> unit + (** [not_found ctx prefix] is called when the engine expects at least one binding within the subtree at [prefix] but could not find any, where [ctx] is the context passed to {!val:S.modify}. Modifiers such as {!val:Language.any}, {!val:Language.only}, {!val:Language.none}, and a few other modifiers expect at least one matching binding. For example, the modifier {!val:Language.except}[ ["x"; "y"]] expects that there was already something under the subtree at [x.y]. If there were actually no names with the prefix [x.y], then the modifier will trigger this effect with [prefix] being [Emp #< "x" #< "y"]. *) + val shadow : P.context option -> Trie.bwd_path -> P.data * P.tag -> P.data * P.tag -> P.data * P.tag + (** [shadow ctx path x y] is called when item [y] is being assigned to [path] but [x] is already bound at [path], where [ctx] is the context passed to {!val:S.modify}. Modifiers such as {!val:Language.renaming} and {!val:Language.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 item [y]. One can also employ a more sophisticated strategy to implement type-directed disambiguation. *) + + val hook : P.context option -> Trie.bwd_path -> P.hook -> (P.data, P.tag) Trie.t -> (P.data, P.tag) Trie.t + (** [hook prefix id input] is called when processing the modifiers created by {!val:Language.hook}, where [ctx] is the context passed to {!val:S.modify}. When the engine encounters the modifier {!val:Language.hook}[ id] while handling the subtree [input] at [prefix], it will call [hook prefix id input] and replace the existing subtree [input] with the return value. *) + end module type S =