one interpretation in case of duplicate interpretation definitions. This
happens when a module A defines an interpretation, it is included by B and
C and then a module D includes both B and C, thus defining the interpretation
twice.
exception Interpretation_not_found
exception Pretty_printer_not_found
exception Interpretation_not_found
exception Pretty_printer_not_found
+let rec list_uniq = function
+ | [] -> []
+ | h::[] -> [h]
+ | h1::h2::tl when h1 = h2 -> list_uniq (h2 :: tl)
+ | h1::tl (* when h1 <> h2 *) -> h1 :: list_uniq tl
+
let lookup_interpretations symbol =
try
let lookup_interpretations symbol =
try
+ list_uniq
+ (List.sort Pervasives.compare
+ (List.map
(fun id ->
let (dsc, _, args, appl_pattern, _) =
try
(fun id ->
let (dsc, _, args, appl_pattern, _) =
try
with Not_found -> assert false
in
dsc, args, appl_pattern)
with Not_found -> assert false
in
dsc, args, appl_pattern)
- !(Hashtbl.find interpretations symbol)
+ !(Hashtbl.find interpretations symbol)))
with Not_found -> raise Interpretation_not_found
let add_pretty_printer ~precedence ~associativity l2 l1 =
with Not_found -> raise Interpretation_not_found
let add_pretty_printer ~precedence ~associativity l2 l1 =