(* id, name, type, body *)
| Constructor of string * Cic.annterm (* name, type *)
| Decl of Cic.id * Cic.name * Cic.annterm (* id, binder, source *)
- | Def of Cic.id * Cic.name * Cic.annterm (* id, binder, source *)
+ | Def of Cic.id * Cic.name * Cic.annterm * Cic.annterm (* id, binder, source, type *)
| Fix_fun of Cic.id * string * int * Cic.annterm * Cic.annterm
(* id, name, ind. index, type, body *)
| Inductive_type of string * string * bool * Cic.annterm *
| Constructor (name, _) -> "Constructor " ^ name
| Cofix_fun (id, _, _, _) -> sprintf "Cofix_fun (id=%s)" id
| Decl (id, _, _) -> sprintf "Decl (id=%s)" id
- | Def (id, _, _) -> sprintf "Def (id=%s)" id
+ | Def (id, _, _, _) -> sprintf "Def (id=%s)" id
| Fix_fun (id, _, _, _, _) -> sprintf "Fix_fun (id=%s)" id
| Inductive_type (id, name, _, _, _) ->
sprintf "Inductive_type %s (id=%s)" name id
| ["id", id; "type", _] -> Decl (id, Cic.Anonymous, source)
| _ -> attribute_error ())
| "def" -> (* same as "decl" above *)
- let source = pop_cic ctxt in
+ let ty,source =
+ (*CSC: hack to parse Coq files where the LetIn is not typed *)
+ let ty = pop_cic ctxt in
+ try
+ let source = pop_cic ctxt in
+ ty,source
+ with
+ Parser_failure _ -> Cic.AImplicit ("MISSING_def_TYPE",None),ty
+ in
push ctxt
(match pop_tag_attrs ctxt with
| ["binder", binder; "id", id]
| ["binder", binder; "id", id; "sort", _] ->
- Def (id, Cic.Name binder, source)
+ Def (id, Cic.Name binder, source, ty)
| ["id", id]
- | ["id", id; "sort", _] -> Def (id, Cic.Anonymous, source)
+ | ["id", id; "sort", _] -> Def (id, Cic.Anonymous, source, ty)
| _ -> attribute_error ())
| "arity" (* transparent elements (i.e. which contain a CIC) *)
| "body"
| "LETIN" ->
let target = pop_cic ctxt in
let rec add_def target = function
- | Def (id, binder, source) :: tl ->
- add_def (Cic.ALetIn (id, binder, source, target)) tl
+ | Def (id, binder, source, ty) :: tl ->
+ add_def (Cic.ALetIn (id, binder, source, ty, target)) tl
| tl ->
ctxt.stack <- tl;
target
push ctxt
(match pop_tag_attrs ctxt with
| [ "value", "definition"] -> Obj_flavour `Definition
+ | [ "value", "mutual_definition"] -> Obj_flavour `MutualDefinition
| [ "value", "fact"] -> Obj_flavour `Fact
| [ "value", "lemma"] -> Obj_flavour `Lemma
| [ "value", "remark"] -> Obj_flavour `Remark
in
Obj_class (`Record fields)
| ["value", "projection"] -> Obj_class `Projection
- | _ -> attribute_error ())
+ | ["value", "inversion"] -> Obj_class `InversionPrinciple
+ | _ -> attribute_error ())
| tag ->
match find_helm_exception ctxt with
| Some (exn, arg) -> raise (Getter_failure (exn, arg))
| Getter_failure _ as exn ->
raise exn
| exn ->
- raise (Parser_failure ("uncaught exception: " ^ Printexc.to_string exn))
+ raise (Parser_failure ("CicParser: uncaught exception: " ^ Printexc.to_string exn))
(** {2 API implementation} *)