X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmetadata%2FmetadataPp.ml;h=acf425ce130df9f5af422cbc30ff6ea9788b23b6;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=5b8ae4e7a55c2ca88c6ef2102b0437344f2e1756;hpb=21758b512843088d19e81830d9fb121725c8a16e;p=helm.git diff --git a/helm/ocaml/metadata/metadataPp.ml b/helm/ocaml/metadata/metadataPp.ml index 5b8ae4e7a..acf425ce1 100644 --- a/helm/ocaml/metadata/metadataPp.ml +++ b/helm/ocaml/metadata/metadataPp.ml @@ -25,53 +25,91 @@ open Printf +open MetadataTypes + +let pp_relation r = + match r with + | Eq i -> sprintf "= %d" i + | Ge i -> sprintf ">= %d" i + | Gt i -> sprintf "> %d" i + | Le i -> sprintf "<= %d" i + | Lt i -> sprintf "< %d" i + let pp_position = function - | `MainConclusion -> "MainConclusion" - | `MainHypothesis -> "MainHypothesis" + | `MainConclusion (Some d) -> sprintf "MainConclusion(%s)" (pp_relation d) + | `MainConclusion None -> sprintf "MainConclusion" + | `MainHypothesis (Some d) -> sprintf "MainHypothesis(%s)" (pp_relation d) + | `MainHypothesis None -> "MainHypothesis" | `InConclusion -> "InConclusion" | `InHypothesis -> "InHypothesis" | `InBody -> "InBody" +let pp_position_tag = function + | `MainConclusion _ -> mainconcl_pos + | `MainHypothesis _ -> mainhyp_pos + | `InConclusion -> inconcl_pos + | `InHypothesis -> inhyp_pos + | `InBody -> inbody_pos + +let columns_of_position pos = + match pos with + | `MainConclusion (Some (Eq d)) -> `String mainconcl_pos, `Int d + | `MainConclusion None -> `String mainconcl_pos, `Null + | `MainHypothesis (Some (Eq d)) -> `String mainhyp_pos, `Int d + | `MainHypothesis None -> `String mainhyp_pos, `Null + | `InConclusion -> `String inconcl_pos, `Null + | `InHypothesis -> `String inhyp_pos, `Null + | `InBody -> `String inbody_pos, `Null + | _ -> assert false + +(* let metadata_ns = "http://www.cs.unibo.it/helm/schemas/schema-helm" let uri_of_pos pos = String.concat "#" [metadata_ns; pp_position pos] - -let pp_sort = function - | Cic.Prop -> "Prop" - | Cic.Set -> "Set" - | Cic.Type _ -> "Type" - | Cic.CProp -> "CProp" +*) type t = [ `Int of int | `String of string | `Null ] -let columns_of_metadata ~about metadatas = - let position p = `String (pp_position p) in - let sort s = `String (pp_sort s) in - let source = `String about in - let depth d = `Int d in - let depth_opt = function None -> `Null | Some d -> `Int d in - let occurrence u = `String u in +let columns_of_metadata_aux ~about metadata = + let sort s = `String (CicPp.ppsort s) in + let source = `String (UriManager.string_of_uri about) in + let occurrence u = `String (UriManager.string_of_uri u) in List.fold_left (fun (sort_cols, rel_cols, obj_cols) metadata -> match metadata with - | `Sort (s, p, d) -> - [source; position p; depth d; sort s] :: sort_cols, rel_cols, obj_cols - | `Rel (p, d) -> - sort_cols, [source; position p; depth d] :: rel_cols, obj_cols - | `Obj (o, p, d) -> + | `Sort (s, p) -> + let (p, d) = columns_of_position (p :> position) in + [source; p; d; sort s] :: sort_cols, rel_cols, obj_cols + | `Rel p -> + let (p, d) = columns_of_position (p :> position) in + sort_cols, [source; p; d] :: rel_cols, obj_cols + | `Obj (o, p) -> + let (p, d) = columns_of_position p in sort_cols, rel_cols, - [source; occurrence o; position p; depth_opt d] :: obj_cols) - ([], [], []) metadatas + [source; occurrence o; p; d] :: obj_cols) + ([], [], []) metadata -let columns_of_ind_metadata ind_metadata = +let columns_of_metadata metadata = List.fold_left - (fun (sort_cols, rel_cols, obj_cols) (uri, _, metadatas) -> - let (s, r, o) = columns_of_metadata ~about:uri metadatas in + (fun (sort_cols, rel_cols, obj_cols) (uri, _, metadata) -> + let (s, r, o) = columns_of_metadata_aux ~about:uri metadata in (List.append sort_cols s, List.append rel_cols r, List.append obj_cols o)) - ([], [], []) ind_metadata + ([], [], []) metadata +let pp_constr = + function + | `Sort (sort, p) -> + sprintf "Sort %s; [%s]" + (CicPp.ppsort sort) (String.concat ";" (List.map pp_position p)) + | `Rel p -> sprintf "Rel [%s]" (String.concat ";" (List.map pp_position p)) + | `Obj (uri, p) -> sprintf "Obj %s; [%s]" + (UriManager.string_of_uri uri) (String.concat ";" (List.map pp_position p)) + +(* let pp_columns ?(sep = "\n") (sort_cols, rel_cols, obj_cols) = String.concat sep ([ "Sort" ] @ List.map Dbi.sdebug (sort_cols :> Dbi.sql_t list list) @ [ "Rel" ] @ List.map Dbi.sdebug (rel_cols :> Dbi.sql_t list list) @ [ "Obj" ] @ List.map Dbi.sdebug (obj_cols :> Dbi.sql_t list list)) +*) +