X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fbin%2Froles%2FrolesEngine.ml;fp=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fbin%2Froles%2FrolesEngine.ml;h=564f64d5b31e342843990aa172472148b58fcfd8;hb=a1ae862976f2489107dd107937f5e05d0aaa7144;hp=0000000000000000000000000000000000000000;hpb=076439def28e649ec384fae038ed021dadd5f75c;p=helm.git diff --git a/matita/matita/contribs/lambdadelta/bin/roles/rolesEngine.ml b/matita/matita/contribs/lambdadelta/bin/roles/rolesEngine.ml new file mode 100644 index 000000000..564f64d5b --- /dev/null +++ b/matita/matita/contribs/lambdadelta/bin/roles/rolesEngine.ml @@ -0,0 +1,68 @@ +(* + ||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 EG = RolesGlobal +module EI = RolesInput +module EO = RolesOutput +module EU = RolesUtils +module ET = RolesTypes + +let st = EU.new_status + +let new_stage v = + if st.ET.w = [] then st.ET.s <- v + else EU.raise_error ET.ENews + +let toggle_entry = function + | [0] -> st.ET.r <- EU.list_toggle_all st.ET.r + | [0;m] -> st.ET.r <- EU.list_toggle m st.ET.r + | [0;m;1] -> + let r = EU.list_nth m st.ET.r in + r.ET.o <- EU.list_toggle_all r.ET.o + | [0;m;1;n] -> + let r = EU.list_nth m st.ET.r in + r.ET.o <- EU.list_toggle n r.ET.o + | [0;m;2] -> + let r = EU.list_nth m st.ET.r in + r.ET.n <- EU.list_toggle_all r.ET.n + | [0;m;2;n] -> + let r = EU.list_nth m st.ET.r in + r.ET.n <- EU.list_toggle n r.ET.n + | [1] -> st.ET.t <- EU.list_toggle_all st.ET.t + | [1;m] -> st.ET.t <- EU.list_toggle m st.ET.t + | [2] -> st.ET.w <- EU.list_toggle_all st.ET.w + | [2;m] -> st.ET.w <- EU.list_toggle m st.ET.w + | _ -> EU.raise_error ET.ENoEntry + +let read_waiting fname = + if st.ET.s = [] then EU.raise_error ET.ENoStage else + let ich = Scanf.Scanning.open_in fname in + let w = EI.read_names ich [] in + Scanf.Scanning.close_in ich; + let error n = ET.ENameClash n in + st.ET.w <- EU.list_union error EU.compare_names st.ET.w (List.rev w) + +let read_status () = + if st.ET.s <> [] then EU.raise_error (ET.EStage st.ET.s) else + let fname = Filename.concat !EG.wd "roles.osn" in + let ich = open_in fname in + let tmp = EI.read_status ich in + close_in ich; + st.ET.r <- tmp.ET.r; + st.ET.s <- tmp.ET.s; + st.ET.t <- tmp.ET.t; + st.ET.w <- tmp.ET.w + +let write_status () = + let fname = Filename.concat !EG.wd "roles.osn" in + let och = open_out fname in + EO.out_status och st; + close_out och