| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open Printf |
| 12 |
open Index |
| 13 |
|
| 14 |
let type_of_string = function |
| 15 |
| "def" | "coe" | "subclass" | "canonstruc" | "fix" | "cofix" | "ex" |
| 16 |
|"scheme" -> |
| 17 |
Definition |
| 18 |
| "prf" | "thm" -> Lemma |
| 19 |
| "ind" | "variant" | "coind" -> Inductive |
| 20 |
| "constr" -> Constructor |
| 21 |
| "indrec" | "rec" | "corec" -> Record |
| 22 |
| "proj" -> Projection |
| 23 |
| "class" -> Class |
| 24 |
| "meth" -> Method |
| 25 |
| "inst" -> Instance |
| 26 |
| "var" -> Variable |
| 27 |
| "defax" | "prfax" | "ax" -> Axiom |
| 28 |
| "abbrev" | "syndef" -> Abbreviation |
| 29 |
| "not" -> Notation |
| 30 |
| "lib" -> Library |
| 31 |
| "mod" | "modtype" -> Module |
| 32 |
| "tac" -> TacticDefinition |
| 33 |
| "sec" -> Section |
| 34 |
| "binder" -> Binder |
| 35 |
| s -> invalid_arg ("type_of_string:" ^ s) |
| 36 |
|
| 37 |
let ill_formed_glob_file f = |
| 38 |
eprintf "Warning: ill-formed file %s (links will not be available)\n" f |
| 39 |
|
| 40 |
let outdated_glob_file f = |
| 41 |
eprintf |
| 42 |
"Warning: %s not consistent with corresponding .v file (links will not be \ |
| 43 |
available)\n" |
| 44 |
f |
| 45 |
|
| 46 |
let correct_file vfile f c = |
| 47 |
let s = input_line c in |
| 48 |
if String.length s < 7 || String.sub s 0 7 <> "DIGEST " then ( |
| 49 |
ill_formed_glob_file f; false ) |
| 50 |
else |
| 51 |
let s = String.sub s 7 (String.length s - 7) in |
| 52 |
match (vfile, s) with |
| 53 |
| None, "NO" -> true |
| 54 |
| Some _, "NO" -> ill_formed_glob_file f; false |
| 55 |
| None, _ -> ill_formed_glob_file f; false |
| 56 |
| Some vfile, s -> |
| 57 |
s = Digest.to_hex (Digest.file vfile) || (outdated_glob_file f; false) |
| 58 |
|
| 59 |
let read_glob vfile f = |
| 60 |
let c = open_in f in |
| 61 |
if correct_file vfile f c then |
| 62 |
let cur_mod = ref "" in |
| 63 |
try |
| 64 |
while true do |
| 65 |
let s = input_line c in |
| 66 |
let n = String.length s in |
| 67 |
if n > 0 then |
| 68 |
match s.[0] with |
| 69 |
| 'F' -> |
| 70 |
cur_mod := String.sub s 1 (n - 1); |
| 71 |
current_library := !cur_mod |
| 72 |
| 'R' -> ( |
| 73 |
try |
| 74 |
Scanf.sscanf s "R%d:%d %s %s %s %s" |
| 75 |
(fun loc1 loc2 lib_dp sp id ty -> |
| 76 |
for loc = loc1 to loc2 do |
| 77 |
add_ref !cur_mod loc lib_dp sp id (type_of_string ty); |
| 78 |
|
| 79 |
|
| 80 |
ignore |
| 81 |
(List.fold_right |
| 82 |
(fun thisPiece priorPieces -> |
| 83 |
let newPieces = |
| 84 |
match priorPieces with |
| 85 |
| "" -> thisPiece |
| 86 |
| _ -> thisPiece ^ "." ^ priorPieces |
| 87 |
in |
| 88 |
add_ref !cur_mod loc "" "" newPieces Library; |
| 89 |
newPieces) |
| 90 |
(Str.split (Str.regexp_string ".") lib_dp) |
| 91 |
"") |
| 92 |
done) |
| 93 |
with _ -> () ) |
| 94 |
| _ -> ( |
| 95 |
try |
| 96 |
Scanf.sscanf s "%s %d:%d %s %s" (fun ty loc1 loc2 sp id -> |
| 97 |
add_def loc1 loc2 (type_of_string ty) sp id) |
| 98 |
with Scanf.Scan_failure _ -> () ) |
| 99 |
done; |
| 100 |
assert false |
| 101 |
with End_of_file -> close_in c |