X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fautomath%2FautProcess.ml;fp=helm%2Fsoftware%2Flambda-delta%2Fautomath%2FautProcess.ml;h=c6ef561f0b26c49bf189ff1b984f841b11ced4fb;hb=2b821e608cc1fceebc13e85867a244fe02edf71e;hp=0000000000000000000000000000000000000000;hpb=016f069da6221053873b4d505716ef1bd80f08b6;p=helm.git diff --git a/helm/software/lambda-delta/automath/autProcess.ml b/helm/software/lambda-delta/automath/autProcess.ml new file mode 100644 index 000000000..c6ef561f0 --- /dev/null +++ b/helm/software/lambda-delta/automath/autProcess.ml @@ -0,0 +1,53 @@ +(* + ||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 A = Aut + +type status = { + opening : bool; (* just opened section *) + reopening: bool; (* just reopened section *) + closing : bool; (* just closed section *) + iao : int; (* implicit context after opening section *) + iar : int; (* implicit context after reopening section *) + iac : int (* implicit context after closing section *) +} + +(* internal functions *******************************************************) + +let proc_section f st = function + | Some (true, _) -> f {st with opening = true} + | Some (false, _) -> f {st with reopening = true} + | None -> f {st with closing = true} + +let proc_context f st = + f {st with opening = false; reopening = false; closing = false} + +let proc_proper f st = + let st = if st.opening then {st with iao = succ st.iao} else st in + let st = if st.reopening then {st with iar = succ st.iar} else st in + let st = if st.closing then {st with iac = succ st.iac} else st in + proc_context f st + +let proc_item f st item = match item with + | A.Section section -> proc_section f st section item + | A.Context _ -> proc_context f st item + | _ -> proc_proper f st item + +(* interface functions ******************************************************) + +let initial_status = { + opening = false; reopening = false; closing = false; + iao = 0; iar = 0; iac = 0 +} + +let process_item = proc_item + +let get_counters f st = f st.iao st.iar st.iac