-(* 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 AH = AutHelpers
+(*
+ ||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 H = Hierarchy
+module O = Output
+module AP = AutProcess
+module AO = AutOutput
+module MA = MetaAut
+module MO = MetaOutput
+module MBrg = MetaBrg
+module BrgO = BrgOutput
+module BrgT = BrgType
+module BrgU = BrgUntrusted
+module MBag = MetaBag
+module BagO = BagOutput
+module BagR = BagReduction
+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 item =
+ if !L.level > 2 then count_fun C.start c item 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 BrgO.specs (L.Warn s :: L.Loc :: msg); flush ()
+
+let process_item f st =
+ let f ast = f {st with ast = ast} in
+ AP.process_item f st.ast
+
+(* kernel related ***********************************************************)
+
+type kernel = Brg | Bag
+
+type kernel_item = BrgItem of Brg.item
+ | BagItem of Bag.item
+
+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 item = match !kernel with
+ | Brg ->
+ let f item = f st (BrgItem item) in
+ MBrg.brg_of_meta f item
+ | Bag ->
+ let f item = f st (BagItem item) in
+ MBag.bag_of_meta f item
+
+let count_item st = function
+ | BrgItem item -> {st with brgc = count BrgO.count_item st.brgc item}
+ | BagItem item -> {st with bagc = count BagO.count_item st.bagc item}
+
+let type_check f st g = function
+ | BrgItem item ->
+ let f _ = function
+ | None -> f st None
+ | Some (i, u, _) -> f st (Some (i, u))
+ in
+ BrgU.type_check f g item
+ | BagItem item ->
+ let f _ = function
+ | None -> f st None
+ | Some (i, u, _) -> f st (Some (i, u))
+ in
+ BagU.type_check f g item
+
+let si () = match !kernel with
+ | Brg -> BrgT.si := true
+ | Bag -> BagR.nsi := true
+
+(****************************************************************************)