diff --git a/compiler/utilities/misc.ml b/compiler/utilities/misc.ml index 5c2d88c..f02f364 100644 --- a/compiler/utilities/misc.ml +++ b/compiler/utilities/misc.ml @@ -122,7 +122,7 @@ let rec assocd value = function (** { 3 Compiler iterators } *) -(** Mapfold *) (* TODO optim : lot's of place we don't need the List.rev *) +(** Mapfold *) (* TODO optim : in a lot of places we don't need the List.rev *) let mapfold f acc l = let l,acc = List.fold_left (fun (l,acc) e -> let e,acc = f acc e in e::l, acc) @@ -170,23 +170,31 @@ let fold_righti f l acc = exception Assert_false let internal_error passe code = - Format.eprintf "@.---------\nInternal compiler error\nPasse : %s, Code : %d\n----------@." passe code; + Format.eprintf "@.---------\n + Internal compiler error\n + Passe : %s, Code : %d\n + ----------@." passe code; raise Assert_false exception Unsupported let unsupported passe code = - Format.eprintf "@.---------\nUnsupported feature, please report it\nPasse : %s, Code : %d\n----------@." passe code; + Format.eprintf "@.---------\n + Unsupported feature, please report it\n + Passe : %s, Code : %d\n + ----------@." passe code; raise Unsupported (* Functions to decompose a list into a tuple *) let _arity_error i l = - Format.eprintf "@.---------\nInternal compiler error: \ - wrong list size (found %d, expected %d).\n----------@." (List.length l) i; + Format.eprintf "@.---------\n + Internal compiler error: wrong list size (found %d, expected %d).\n + ----------@." (List.length l) i; raise Assert_false let _arity_min_error i l = - Format.eprintf "@.---------\nInternal compiler error: \ - wrong list size (found %d, expected %d at least).\n----------@." (List.length l) i; + Format.eprintf "@.---------\n + Internal compiler error: wrong list size (found %d, expected %d at least).\n + ----------@." (List.length l) i; raise Assert_false let assert_empty = function diff --git a/compiler/utilities/misc.mli b/compiler/utilities/misc.mli index 2daf31f..16783a9 100644 --- a/compiler/utilities/misc.mli +++ b/compiler/utilities/misc.mli @@ -13,7 +13,8 @@ val optional : ('a -> 'b) -> 'a option -> 'b option val optional_wacc : ('a -> 'b -> 'c*'a) -> 'a -> 'b option -> ('c option * 'a) val optunit : ('a -> unit) -> 'a option -> unit -(** [split_string s c] splits the string [s] according to the separator [c] into a list of string without [c] *) +(** [split_string s c] splits the string [s] according to the separator + [c] into a list of string without [c] *) val split_string : string -> string -> string list (* Generation of unique names. Mandatory call of reset_symbol between @@ -63,7 +64,7 @@ val list_compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int val option_compare : ('a -> 'a -> int) -> 'a option -> 'a option -> int (** Mapfold *) -val mapfold: ('a -> 'b -> 'c * 'a) -> 'a -> 'b list -> 'c list * 'a +val mapfold: ('acc -> 'b -> 'c * 'acc) -> 'acc -> 'b list -> 'c list * 'acc (** Mapfold, right version. *) val mapfold_right