type context_node = M.qid option (* context node: None = root *)
-type context = (M.qid, context_node) H.t (* context: son, parent *)
+type context = (M.qid, M.term * context_node) H.t (* context: son, parent *)
type status = {
genv: M.environment; (* global environment *)
| _ :: tl -> get_local f (succ i) tl
in
let rec get_global f = function
- | [] -> None
+ | [] -> f None
| (args, name, _, _) :: _ when name = gref -> f (Some args)
| _ :: tl -> get_global f tl
in
in
let f name = resolve_gref (f name) st lenv name in
complete_qid f st name
+
+let xlate_item f st = function
+ | A.Section (Some name) ->
+ f {st with path = name :: st.path}
+ | A.Section None ->
+ begin match st.path with
+ | [] -> assert false
+ | _ :: tl -> f {st with path = tl}
+ end
+ | A.Context None ->
+ f {st with node = None}
+ | A.Context (Some name) ->
+ let f name = f {st with node = Some name} in
+ complete_qid f st name
+ | A.Block (name, w) ->
+ let f name ww = H.add st.cnt name (ww, st.node); f st in
+ let f name = xlate_term (f name) st [] w in
+ complete_qid f st (name, true, [])
+ | A.Decl (name, w) -> f st
+ | A.Def (name, w, trans, v) -> f st
+
+let meta_of_aut f book =
+ let f st = f st.genv in
+ Cps.list_fold_left f xlate_item initial_status book