-(* Copyright (C) 2000, 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://cs.unibo.it/helm/.
- *)
-
-module AO = AutOutput
-module MA = MetaAut
-module MO = MetaOutput
+(*
+ ||M|| This file is part of HELM, an Hypertextual, Electronic
+ ||A|| Library of Mathematics, developed at the Computer Science
+ ||T|| Department, University of Bologna, Italy.
+ ||I||
+ ||T|| HELM is free software; you can redistribute it and/or
+ ||A|| modify it under the terms of the GNU General Public License
+ \ / version 2 or (at your option) any later version.
+ \ / This software is distributed as is, NO WARRANTY.
+ V_______________________________________________________________ *)
+
+module P = Printf
+module U = NUri
+module C = Cps
+module L = Log
+module T = Time
+module H = Hierarchy
+module O = Output
+module AP = AutProcess
+module AO = AutOutput
+module MA = MetaAut
+module MO = MetaOutput
+module ML = MetaLibrary
+module MBrg = MetaBrg
+module G = Library
+module BrgO = BrgOutput
+module BrgR = BrgReduction
+module BrgU = BrgUntrusted
+module MBag = MetaBag
+module BagO = BagOutput
+module BagT = BagType
+module BagU = BagUntrusted
+
+type status = {
+ ast : AP.status;
+ mst : MA.status;
+ ac : AO.counters;
+ mc : MO.counters;
+ brgc: BrgO.counters;
+ bagc: BagO.counters
+}
+
+let initial_status cover = {
+ ac = AO.initial_counters;
+ mc = MO.initial_counters;
+ brgc = BrgO.initial_counters;
+ bagc = BagO.initial_counters;
+ mst = MA.initial_status ~cover ();
+ ast = AP.initial_status
+}
+
+let count count_fun c entity =
+ if !L.level > 2 then count_fun C.start c entity else c
+
+let flush () = L.flush 0; L.flush_err ()
+
+let bag_error s msg =
+ L.error BagO.specs (L.Warn s :: L.Loc :: msg); flush ()
+
+let brg_error s msg =
+ L.error BrgR.specs (L.Warn s :: L.Loc :: msg); flush ()
+
+let process_entity f st =
+ let f ast = f {st with ast = ast} in
+ AP.process_entity f st.ast
+
+(* kernel related ***********************************************************)
+
+type kernel = Brg | Bag
+
+type kernel_entity = BrgEntity of Brg.entity
+ | BagEntity of Bag.entity
+
+let kernel = ref Brg
+
+let print_counters st = match !kernel with
+ | Brg -> BrgO.print_counters C.start st.brgc
+ | Bag -> BagO.print_counters C.start st.bagc
+
+let kernel_of_meta f st entity = match !kernel with
+ | Brg ->
+ let f entity = f st (BrgEntity entity) in
+ MBrg.brg_of_meta f entity
+ | Bag ->
+ let f entity = f st (BagEntity entity) in
+ MBag.bag_of_meta f entity
+
+let count_entity st = function
+ | BrgEntity entity -> {st with brgc = count BrgO.count_entity st.brgc entity}
+ | BagEntity entity -> {st with bagc = count BagO.count_entity st.bagc entity}
+
+let export_entity si g = function
+ | BrgEntity entity -> G.export_entity BrgO.export_entry si g entity
+ | BagEntity _ -> ()
+
+let type_check f st si g k =
+ let brg_err msg = brg_error "Type Error" msg; failwith "Interrupted" in
+ let f _ = function
+ | None -> f st None
+ | Some (i, u, _) -> f st (Some (i, u))
+ in
+ match k with
+ | BrgEntity entity -> BrgU.type_check brg_err f ~si g entity
+ | BagEntity entity -> BagU.type_check f ~si g entity
+
+(****************************************************************************)