aboutsummaryrefslogtreecommitdiff
path: root/library/lib.ml
diff options
context:
space:
mode:
authorfilliatr1999-12-12 22:03:12 +0000
committerfilliatr1999-12-12 22:03:12 +0000
commited8ec17ce48b4d0cf14696a4e9760239aa31f59b (patch)
tree6c596c6e8ccebb4d29a856439f07d3fd85a4e3d2 /library/lib.ml
parent9658d225b4003ac10c4c670e788d386930c3fa60 (diff)
modules
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@238 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'library/lib.ml')
-rw-r--r--library/lib.ml22
1 files changed, 13 insertions, 9 deletions
diff --git a/library/lib.ml b/library/lib.ml
index f79c22c58c..a6686168da 100644
--- a/library/lib.ml
+++ b/library/lib.ml
@@ -8,12 +8,13 @@ open Summary
type node =
| Leaf of obj
+ | Module of string
| OpenedSection of string * Summary.frozen
| FrozenState of Summary.frozen
-and library_segment = (section_path * node) list
+and library_entry = section_path * node
-type library_entry = section_path * node
+and library_segment = library_entry list
(* We keep trace of operations in the stack [lib_stk].
@@ -109,13 +110,15 @@ let check_for_module () =
let is_decl = function (_,FrozenState _) -> false | _ -> true in
try
let _ = find_entry_p is_decl in
- error "a module can not be opened after some declarations"
+ error "a module can not be started after some declarations"
with Not_found -> ()
-let open_module s =
- if !module_name <> None then error "a module is already opened";
- check_for_module ();
- module_name := Some s
+let start_module s =
+ if !module_name <> None then error "a module is already started";
+ if !path_prefix <> [] then error "some sections are already opened";
+ module_name := Some s;
+ let _ = add_anonymous_entry (Module s) in
+ path_prefix := [s]
let is_opened_section = function (_,OpenedSection _) -> true | _ -> false
@@ -135,15 +138,16 @@ let close_section s =
(* The following function exports the whole library segment, that will be
saved as a module. Objects are presented in chronological order, and
- closed sections and frozen states are removed. *)
+ frozen states are removed. *)
let export_module () =
if !module_name = None then error "no module declared";
let rec export acc = function
- | [] -> acc
+ | (_,Module _) :: _ -> acc
| (_,Leaf _) as node :: stk -> export (node::acc) stk
| (_,OpenedSection _) :: _ -> error "there are still opened sections"
| (_,FrozenState _) :: stk -> export acc stk
+ | _ -> assert false
in
export [] !lib_stk