X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmetadata%2FmetadataPp.ml;fp=helm%2Focaml%2Fmetadata%2FmetadataPp.ml;h=5b8ae4e7a55c2ca88c6ef2102b0437344f2e1756;hb=21758b512843088d19e81830d9fb121725c8a16e;hp=0000000000000000000000000000000000000000;hpb=dd8726f655e4fdad063baf456fcfc95f82e079cc;p=helm.git diff --git a/helm/ocaml/metadata/metadataPp.ml b/helm/ocaml/metadata/metadataPp.ml new file mode 100644 index 000000000..5b8ae4e7a --- /dev/null +++ b/helm/ocaml/metadata/metadataPp.ml @@ -0,0 +1,77 @@ +(* Copyright (C) 2004, HELM Team. + * + * This file is part of HELM, an Hypertextual, Electronic + * Library of Mathematics, developed at the Computer Science + * Department, University of Bologna, Italy. + * + * HELM is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * HELM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HELM; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + * + * For details, see the HELM World-Wide-Web page, + * http://helm.cs.unibo.it/ + *) + +open Printf + +let pp_position = function + | `MainConclusion -> "MainConclusion" + | `MainHypothesis -> "MainHypothesis" + | `InConclusion -> "InConclusion" + | `InHypothesis -> "InHypothesis" + | `InBody -> "InBody" + +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 + 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_cols, rel_cols, + [source; occurrence o; position p; depth_opt d] :: obj_cols) + ([], [], []) metadatas + +let columns_of_ind_metadata ind_metadata = + List.fold_left + (fun (sort_cols, rel_cols, obj_cols) (uri, _, metadatas) -> + let (s, r, o) = columns_of_metadata ~about:uri metadatas in + (List.append sort_cols s, List.append rel_cols r, List.append obj_cols o)) + ([], [], []) ind_metadata + +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)) +