Commit 37a91e70 authored by bguillaum's avatar bguillaum
Browse files

trailing whitespaces

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7422 7838e531-6607-4d57-9587-6c381814729c
parent c1144628
...@@ -87,8 +87,8 @@ module P_graph = struct ...@@ -87,8 +87,8 @@ module P_graph = struct
let table = Array.of_list sorted_ids in let table = Array.of_list sorted_ids in
(* the nodes, in the same order *) (* the nodes, in the same order *)
let map_without_edges = List_.foldi_left let map_without_edges = List_.foldi_left
(fun i acc elt -> Pid_map.add (Pid.Pos i) elt acc) (fun i acc elt -> Pid_map.add (Pid.Pos i) elt acc)
Pid_map.empty node_list in Pid_map.empty node_list in
let (map : t) = let (map : t) =
...@@ -153,7 +153,7 @@ module P_graph = struct ...@@ -153,7 +153,7 @@ module P_graph = struct
| None -> Pid.Neg (Id.build ~loc ast_edge.Ast.src new_table) in | None -> Pid.Neg (Id.build ~loc ast_edge.Ast.src new_table) in
let i2 = let i2 =
match Id.build_opt ast_edge.Ast.tar old_table with match Id.build_opt ast_edge.Ast.tar old_table with
| Some i -> Pid.Pos i | Some i -> Pid.Pos i
| None -> Pid.Neg (Id.build ~loc ast_edge.Ast.tar new_table) in | None -> Pid.Neg (Id.build ~loc ast_edge.Ast.tar new_table) in
let edge = P_edge.build ~locals (ast_edge, loc) in let edge = P_edge.build ~locals (ast_edge, loc) in
match map_add_edge acc i1 edge i2 with match map_add_edge acc i1 edge i2 with
......
...@@ -41,16 +41,16 @@ module P_graph: sig ...@@ -41,16 +41,16 @@ module P_graph: sig
val build: val build:
?pat_vars: string list -> ?pat_vars: string list ->
?locals: Label.decl array -> ?locals: Label.decl array ->
Ast.node list -> Ast.node list ->
Ast.edge list -> Ast.edge list ->
(t * Id.table * (Pid.t * P_fs.t) list ) (t * Id.table * (Pid.t * P_fs.t) list )
val build_extension: val build_extension:
?locals: Label.decl array -> ?locals: Label.decl array ->
Id.table -> Id.table ->
Ast.node list -> Ast.node list ->
Ast.edge list -> Ast.edge list ->
(extension * Id.table) (extension * Id.table)
val roots: t -> Pid.t list val roots: t -> Pid.t list
...@@ -72,9 +72,9 @@ module G_graph: sig ...@@ -72,9 +72,9 @@ module G_graph: sig
val find: Gid.t -> t -> G_node.t val find: Gid.t -> t -> G_node.t
val build: val build:
?locals: Label.decl array -> ?locals: Label.decl array ->
Ast.node list -> Ast.node list ->
Ast.edge list -> Ast.edge list ->
t t
val of_conll: ?loc:Loc.t -> Conll.line list -> t val of_conll: ?loc:Loc.t -> Conll.line list -> t
...@@ -93,14 +93,14 @@ module G_graph: sig ...@@ -93,14 +93,14 @@ module G_graph: sig
val del_edge : ?edge_ident: string -> Loc.t -> t -> Gid.t -> G_edge.t -> Gid.t -> t val del_edge : ?edge_ident: string -> Loc.t -> t -> Gid.t -> G_edge.t -> Gid.t -> t
val del_node : t -> Gid.t -> t val del_node : t -> Gid.t -> t
val add_neighbour : Loc.t -> t -> Gid.t -> G_edge.t -> (Gid.t * t) val add_neighbour : Loc.t -> t -> Gid.t -> G_edge.t -> (Gid.t * t)
val merge_node : Loc.t -> t -> Gid.t -> Gid.t -> t option val merge_node : Loc.t -> t -> Gid.t -> Gid.t -> t option
val shift_in : Loc.t -> t -> Gid.t -> Gid.t -> t val shift_in : Loc.t -> t -> Gid.t -> Gid.t -> t
val shift_out : Loc.t -> t -> Gid.t -> Gid.t -> t val shift_out : Loc.t -> t -> Gid.t -> Gid.t -> t
val shift_edges : Loc.t -> t -> Gid.t -> Gid.t -> t val shift_edges : Loc.t -> t -> Gid.t -> Gid.t -> t
(** [update_feat tar_id tar_feat_name concat_items] sets the feature of the node [tar_id] (** [update_feat tar_id tar_feat_name concat_items] sets the feature of the node [tar_id]
with feature name [tar_feat_name] to be the contatenation of values described by the [concat_items]. with feature name [tar_feat_name] to be the contatenation of values described by the [concat_items].
It returns both the new graph and the new feature value produced as the second element *) It returns both the new graph and the new feature value produced as the second element *)
val update_feat: ?loc:Loc.t -> t -> Gid.t -> string -> concat_item list -> (t * string) val update_feat: ?loc:Loc.t -> t -> Gid.t -> string -> concat_item list -> (t * string)
......
...@@ -20,13 +20,13 @@ module G_node = struct ...@@ -20,13 +20,13 @@ module G_node = struct
let empty = { fs = G_fs.empty; pos = None; next = Massoc_gid.empty } let empty = { fs = G_fs.empty; pos = None; next = Massoc_gid.empty }
let to_string t = let to_string t =
Printf.sprintf " fs=[%s]\n next=%s\n" Printf.sprintf " fs=[%s]\n next=%s\n"
(G_fs.to_string t.fs) (G_fs.to_string t.fs)
(Massoc_gid.to_string G_edge.to_string t.next) (Massoc_gid.to_string G_edge.to_string t.next)
let to_gr t = let to_gr t =
sprintf "%s [%s] " sprintf "%s [%s] "
(match t.pos with Some i -> sprintf "(%d)" i | None -> "") (match t.pos with Some i -> sprintf "(%d)" i | None -> "")
(G_fs.to_gr t.fs) (G_fs.to_gr t.fs)
...@@ -36,7 +36,7 @@ module G_node = struct ...@@ -36,7 +36,7 @@ module G_node = struct
| None -> None | None -> None
let build (ast_node, loc) = let build (ast_node, loc) =
(ast_node.Ast.node_id, (ast_node.Ast.node_id,
{ fs = G_fs.build ast_node.Ast.fs; { fs = G_fs.build ast_node.Ast.fs;
pos = ast_node.Ast.position; pos = ast_node.Ast.position;
next = Massoc_gid.empty; next = Massoc_gid.empty;
...@@ -47,18 +47,17 @@ module G_node = struct ...@@ -47,18 +47,17 @@ module G_node = struct
pos = Some line.Conll.num; pos = Some line.Conll.num;
next = Massoc_gid.empty; next = Massoc_gid.empty;
} }
let remove (id_tar : Gid.t) label t = {t with next = Massoc_gid.remove id_tar label t.next} let remove (id_tar : Gid.t) label t = {t with next = Massoc_gid.remove id_tar label t.next}
let remove_key node_id t = let remove_key node_id t =
try {t with next = Massoc_gid.remove_key node_id t.next} with Not_found -> t try {t with next = Massoc_gid.remove_key node_id t.next} with Not_found -> t
let merge_key ?(strict=false) src_id tar_id t = let merge_key ?(strict=false) src_id tar_id t =
try Some {t with next = Massoc_gid.merge_key src_id tar_id t.next} try Some {t with next = Massoc_gid.merge_key src_id tar_id t.next}
with Massoc_gid.Duplicate -> if strict then None else Some t with Massoc_gid.Duplicate -> if strict then None else Some t
let shift_out ?(strict=false) src_t tar_t = let shift_out ?(strict=false) src_t tar_t =
try Some {tar_t with next = Massoc_gid.disjoint_union src_t.next tar_t.next} try Some {tar_t with next = Massoc_gid.disjoint_union src_t.next tar_t.next}
with Massoc_gid.Not_disjoint -> if strict then None else Some tar_t with Massoc_gid.Not_disjoint -> if strict then None else Some tar_t
...@@ -87,10 +86,10 @@ module P_node = struct ...@@ -87,10 +86,10 @@ module P_node = struct
let unif_fs fs t = { t with fs = P_fs.unif fs t.fs } let unif_fs fs t = { t with fs = P_fs.unif fs t.fs }
let empty = { fs = P_fs.empty; next = Massoc_pid.empty; name = ""; loc=None } let empty = { fs = P_fs.empty; next = Massoc_pid.empty; name = ""; loc=None }
let build ?pat_vars (ast_node, loc) = let build ?pat_vars (ast_node, loc) =
(ast_node.Ast.node_id, (ast_node.Ast.node_id,
{ {
name = ast_node.Ast.node_id; name = ast_node.Ast.node_id;
fs = P_fs.build ?pat_vars ast_node.Ast.fs; fs = P_fs.build ?pat_vars ast_node.Ast.fs;
next = Massoc_pid.empty; next = Massoc_pid.empty;
......
...@@ -17,10 +17,10 @@ module G_node: sig ...@@ -17,10 +17,10 @@ module G_node: sig
val set_fs: t -> G_fs.t -> t val set_fs: t -> G_fs.t -> t
(* FIXME move Gid up and replace int by Gid.t *) (* FIXME move Gid up and replace int by Gid.t *)
val remove: Gid.t -> G_edge.t -> t -> t val remove: Gid.t -> G_edge.t -> t -> t
val remove_key: Gid.t -> t -> t val remove_key: Gid.t -> t -> t
val merge_key: ?strict:bool -> Gid.t -> Gid.t -> t -> t option val merge_key: ?strict:bool -> Gid.t -> Gid.t -> t -> t option
val shift_out: ?strict:bool -> t -> t -> t option val shift_out: ?strict:bool -> t -> t -> t option
......
...@@ -10,19 +10,19 @@ module Instance : sig ...@@ -10,19 +10,19 @@ module Instance : sig
graph: G_graph.t; graph: G_graph.t;
commands: Command.h list; commands: Command.h list;
rules: string list; rules: string list;
big_step: Grew_types.big_step option; big_step: Grew_types.big_step option;
} }
val empty:t val empty:t
val build: Ast.gr -> t val build: Ast.gr -> t
val of_conll: ?loc:Loc.t -> Conll.line list -> t val of_conll: ?loc:Loc.t -> Conll.line list -> t
(* rev_steps reverse the small step list: during rewriting, the last rule is in the head of the list and the reverse is needed for display *) (* rev_steps reverse the small step list: during rewriting, the last rule is in the head of the list and the reverse is needed for display *)
val rev_steps: t -> t val rev_steps: t -> t
val clear: t -> t val clear: t -> t
val from_graph: G_graph.t -> t val from_graph: G_graph.t -> t
val get_graph: t -> G_graph.t val get_graph: t -> G_graph.t
...@@ -60,7 +60,7 @@ module Rule : sig ...@@ -60,7 +60,7 @@ module Rule : sig
(* raise Stop if some command fails to apply *) (* raise Stop if some command fails to apply *)
val normalize: val normalize:
string -> (* module name *) string -> (* module name *)
?confluent:bool -> ?confluent:bool ->
t list -> (* rule list *) t list -> (* rule list *)
t list -> (* filter list *) t list -> (* filter list *)
Instance.t -> Instance.t ->
......
open Log open Log
open Printf open Printf
module StringSet = Set.Make (String) module StringSet = Set.Make (String)
module StringMap = Map.Make (String) module StringMap = Map.Make (String)
...@@ -9,7 +9,7 @@ module IntMap = Map.Make (struct type t = int let compare = Pervasives.compare e ...@@ -9,7 +9,7 @@ module IntMap = Map.Make (struct type t = int let compare = Pervasives.compare e
let png_file_from_dot dot output_file = let png_file_from_dot dot output_file =
let temp_file_name,out_ch = Filename.open_temp_file ~mode:[Open_rdonly;Open_wronly;Open_text] "grewui_" ".dot" in let temp_file_name,out_ch = Filename.open_temp_file ~mode:[Open_rdonly;Open_wronly;Open_text] "grewui_" ".dot" in
fprintf out_ch "%s" dot; fprintf out_ch "%s" dot;
close_out out_ch; close_out out_ch;
...@@ -19,7 +19,7 @@ let png_file_from_dot dot output_file = ...@@ -19,7 +19,7 @@ let png_file_from_dot dot output_file =
(* ================================================================================ *) (* ================================================================================ *)
module Loc = struct module Loc = struct
type t = string * int type t = string * int
let to_string (file,line) = sprintf "(file: %s, line: %d)" (Filename.basename file) line let to_string (file,line) = sprintf "(file: %s, line: %d)" (Filename.basename file) line
...@@ -39,7 +39,7 @@ module File = struct ...@@ -39,7 +39,7 @@ module File = struct
fprintf out_ch "%s\n" data; fprintf out_ch "%s\n" data;
close_out out_ch close_out out_ch
let read file = let read file =
let in_ch = open_in file in let in_ch = open_in file in
let rev_lines = ref [] in let rev_lines = ref [] in
try try
...@@ -49,12 +49,12 @@ module File = struct ...@@ -49,12 +49,12 @@ module File = struct
then () then ()
else rev_lines := line :: !rev_lines else rev_lines := line :: !rev_lines
done; assert false done; assert false
with End_of_file -> with End_of_file ->
close_in in_ch; close_in in_ch;
List.rev !rev_lines List.rev !rev_lines
(* [read_ln file] returns a list of couples (line_num, line). Blank lines and lines starting with '%' are ignored. *) (* [read_ln file] returns a list of couples (line_num, line). Blank lines and lines starting with '%' are ignored. *)
let read_ln file = let read_ln file =
let in_ch = open_in file in let in_ch = open_in file in
let cpt = ref 0 in let cpt = ref 0 in
let rev_lines = ref [] in let rev_lines = ref [] in
...@@ -66,7 +66,7 @@ module File = struct ...@@ -66,7 +66,7 @@ module File = struct
then () then ()
else rev_lines := (!cpt, line) :: !rev_lines else rev_lines := (!cpt, line) :: !rev_lines
done; assert false done; assert false
with End_of_file -> with End_of_file ->
close_in in_ch; close_in in_ch;
List.rev !rev_lines List.rev !rev_lines
end (* module File *) end (* module File *)
...@@ -89,16 +89,16 @@ end (* module Pid *) ...@@ -89,16 +89,16 @@ end (* module Pid *)
(* ================================================================================ *) (* ================================================================================ *)
module Pid_map = module Pid_map =
struct struct
include Map.Make (Pid) include Map.Make (Pid)
exception True exception True
let exists fct map = let exists fct map =
try try
iter iter
(fun key value -> (fun key value ->
if fct key value if fct key value
then raise True then raise True
) map; ) map;
false false
...@@ -138,14 +138,14 @@ module Gid_map = Map.Make (Gid) ...@@ -138,14 +138,14 @@ module Gid_map = Map.Make (Gid)
module Array_ = struct module Array_ = struct
let dicho_mem elt array = let dicho_mem elt array =
let rec loop low high = let rec loop low high =
(if low > high (if low > high
then false then false
else else
match (low+high)/2 with match (low+high)/2 with
| middle when array.(middle) = elt -> true | middle when array.(middle) = elt -> true
| middle when array.(middle) < elt -> loop (middle+1) high | middle when array.(middle) < elt -> loop (middle+1) high
| middle -> loop low (middle - 1) | middle -> loop low (middle - 1)
) in ) in
loop 0 ((Array.length array) - 1) loop 0 ((Array.length array) - 1)
(* dichotomic search in a sorted array *) (* dichotomic search in a sorted array *)
...@@ -155,16 +155,16 @@ module Array_ = struct ...@@ -155,16 +155,16 @@ module Array_ = struct
match (low+high)/2 with match (low+high)/2 with
| middle when array.(middle) = elt -> middle | middle when array.(middle) = elt -> middle
| middle when array.(middle) < elt -> loop (middle+1) high | middle when array.(middle) < elt -> loop (middle+1) high
| middle -> loop low (middle - 1) in | middle -> loop low (middle - 1) in
loop 0 ((Array.length array) - 1) loop 0 ((Array.length array) - 1)
let dicho_find_assoc elt array = let dicho_find_assoc elt array =
let rec loop low high = let rec loop low high =
(if low > high then raise Not_found); (if low > high then raise Not_found);
match (low+high)/2 with match (low+high)/2 with
| middle when fst array.(middle) = elt -> middle | middle when fst array.(middle) = elt -> middle
| middle when fst array.(middle) < elt -> loop (middle+1) high | middle when fst array.(middle) < elt -> loop (middle+1) high
| middle -> loop low (middle - 1) in | middle -> loop low (middle - 1) in
loop 0 ((Array.length array) - 1) loop 0 ((Array.length array) - 1)
end (* module Array_ *) end (* module Array_ *)
...@@ -180,7 +180,7 @@ module List_ = struct ...@@ -180,7 +180,7 @@ module List_ = struct
| x::t when x=elt -> t | x::t when x=elt -> t
| x::t -> x::(rm elt t) | x::t -> x::(rm elt t)
let pos x l = let pos x l =
let rec loop i = function let rec loop i = function
| [] -> None | [] -> None
| h::t when h=x -> Some i | h::t when h=x -> Some i
...@@ -194,7 +194,7 @@ module List_ = struct ...@@ -194,7 +194,7 @@ module List_ = struct
let rec opt_map f = function let rec opt_map f = function
| [] -> [] | [] -> []
| x::t -> | x::t ->
match f x with match f x with
| None -> opt_map f t | None -> opt_map f t
| Some r -> r :: (opt_map f t) | Some r -> r :: (opt_map f t)
...@@ -203,20 +203,20 @@ module List_ = struct ...@@ -203,20 +203,20 @@ module List_ = struct
| [] -> [] | [] -> []
| x::t -> (f x)@(flat_map f t) | x::t -> (f x)@(flat_map f t)
let iteri fct = let iteri fct =
let rec loop i = function let rec loop i = function
| [] -> () | [] -> ()
| h::t -> (fct i h); (loop (i+1) t) in | h::t -> (fct i h); (loop (i+1) t) in
loop 0 loop 0
let mapi fct = let mapi fct =
let rec loop i = function let rec loop i = function
| [] -> [] | [] -> []
| h::t -> let head = fct i h in head :: (loop (i+1) t) | h::t -> let head = fct i h in head :: (loop (i+1) t)
in loop 0 in loop 0
let opt_mapi fct = let opt_mapi fct =
let rec loop i = function let rec loop i = function
| [] -> [] | [] -> []
| h::t -> | h::t ->
match fct i h with match fct i h with
...@@ -225,8 +225,8 @@ module List_ = struct ...@@ -225,8 +225,8 @@ module List_ = struct
in loop 0 in loop 0
let foldi_left f init l = let foldi_left f init l =
fst fst
(List.fold_left (List.fold_left
(fun (acc,i) elt -> (f i acc elt, i+1)) (fun (acc,i) elt -> (f i acc elt, i+1))
(init,0) l (init,0) l
) )
...@@ -242,7 +242,7 @@ module List_ = struct ...@@ -242,7 +242,7 @@ module List_ = struct
let rec sort_insert elt = function let rec sort_insert elt = function
| [] -> [elt] | [] -> [elt]
| h::t when elt<h -> elt::h::t | h::t when elt<h -> elt::h::t
| h::t -> h::(sort_insert elt t) | h::t -> h::(sort_insert elt t)
let rec sort_mem elt = function let rec sort_mem elt = function
...@@ -255,7 +255,7 @@ module List_ = struct ...@@ -255,7 +255,7 @@ module List_ = struct
| [] -> None | [] -> None
| (k,_)::_ when key<k -> None | (k,_)::_ when key<k -> None
| (k,_)::t when key>k -> sort_assoc key t | (k,_)::t when key>k -> sort_assoc key t
| (_,v)::_ -> Some v | (_,v)::_ -> Some v
let rec sort_remove_assoc key = function let rec sort_remove_assoc key = function
| [] -> [] | [] -> []
...@@ -265,7 +265,7 @@ module List_ = struct ...@@ -265,7 +265,7 @@ module List_ = struct
exception Usort exception Usort
let rec usort_remove key = function let rec usort_remove key = function
| [] -> raise Not_found | [] -> raise Not_found
| x::t when key < x -> raise Not_found | x::t when key < x -> raise Not_found
| x::t when key = x -> t | x::t when key = x -> t
...@@ -279,30 +279,30 @@ module List_ = struct ...@@ -279,30 +279,30 @@ module List_ = struct
| _ -> raise Usort in | _ -> raise Usort in
try Some (loop l) with Usort -> None try Some (loop l) with Usort -> None
let rec sort_disjoint l1 l2 = let rec sort_disjoint l1 l2 =
match (l1,l2) with match (l1,l2) with
| [], _ | _, [] -> true | [], _ | _, [] -> true
| h1::t1 , h2::t2 when h1<h2 -> sort_disjoint t1 l2 | h1::t1 , h2::t2 when h1<h2 -> sort_disjoint t1 l2
| h1::t1 , h2::t2 when h1>h2 -> sort_disjoint l1 t2 | h1::t1 , h2::t2 when h1>h2 -> sort_disjoint l1 t2
| _ -> false | _ -> false
let sort_is_empty_inter l1 l2 = let sort_is_empty_inter l1 l2 =
let rec loop = function let rec loop = function
| [], _ | _, [] -> true | [], _ | _, [] -> true
| x1::t1, x2::t2 when x1 < x2 -> loop (t1, x2::t2) | x1::t1, x2::t2 when x1 < x2 -> loop (t1, x2::t2)
| x1::t1, x2::t2 when x1 > x2 -> loop (x1::t1, t2) | x1::t1, x2::t2 when x1 > x2 -> loop (x1::t1, t2)
| x1::t1, x2::t2 -> false in | x1::t1, x2::t2 -> false in
loop (l1,l2) loop (l1,l2)
let sort_inter l1 l2 = let sort_inter l1 l2 =
let rec loop = function let rec loop = function
| [], _ | _, [] -> [] | [], _ | _, [] -> []
| x1::t1, x2::t2 when x1 < x2 -> loop (t1, x2::t2) | x1::t1, x2::t2 when x1 < x2 -> loop (t1, x2::t2)
| x1::t1, x2::t2 when x1 > x2 -> loop (x1::t1, t2) | x1::t1, x2::t2 when x1 > x2 -> loop (x1::t1, t2)
| x1::t1, x2::t2 -> x1 :: loop (t1, t2) in | x1::t1, x2::t2 -> x1 :: loop (t1, t2) in
loop (l1,l2) loop (l1,l2)
let sort_union l1 l2 = let sort_union l1 l2 =
let rec loop = function let rec loop = function
| [], l | l, [] -> l | [], l | l, [] -> l
| x1::t1, x2::t2 when x1 < x2 -> x1 :: loop (t1, x2::t2) | x1::t1, x2::t2 when x1 < x2 -> x1 :: loop (t1, x2::t2)
...@@ -312,15 +312,15 @@ module List_ = struct ...@@ -312,15 +312,15 @@ module List_ = struct