aboutsummaryrefslogtreecommitdiffhomepage
path: root/dev/base_include
blob: 7e233d171d7dbff1dad9ebaef5a1eebea1a0979b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

(* File to include to get some Coq facilities under the ocaml toplevel.
   This file is loaded by include.ml *)

(* We only assume that the variable COQTOP is set *)
let src_dir =
  let coqtop = try Sys.getenv "COQTOP" with Not_found -> "." in
  let coqtop = 
    if Sys.file_exists coqtop then 
      coqtop
    else begin
      print_endline ("Cannot find the sources in "^coqtop);
      print_string "Where are they ? ";
      read_line ()
    end 
  in
  let add_dir dl = 
    Topdirs.dir_directory (List.fold_left Filename.concat "" dl) 
  in
  List.iter add_dir
    [ [ "config" ]; [ "dev" ]; [ "lib" ]; [ "kernel" ]; [ "library" ]; 
      [ "pretyping" ]; [ "parsing" ]; [ "proofs" ]; [ "tactics" ];
      [ "toplevel" ] ];
  coqtop
;;
(* Now Coq_config.cmi is accessible *)
Topdirs.dir_directory Coq_config.camlp4lib;;

#use "top_printers.ml";;

#install_printer  (* identifier *) prid;;
#install_printer  (* section_path *)  prsp;;
#install_printer  (* constr *)  print_pure_constr;;

(* parsing of terms *)

let parse_com   = Pcoq.parse_string Pcoq.Constr.constr;;
let parse_tac = Pcoq.parse_string Pcoq.Tactic.tactic;;

(* For compatibility reasons *)
let parse_ast = parse_com;;

(* build a term of type rawconstr without type-checking or resolution of 
   implicit syntax *)

let e s = Astterm.interp_rawconstr Evd.empty (Global.env()) (parse_ast s);;

(* For compatibility *)
let raw_constr_of_string = e;;

(* build a term of type constr with type-checking and resolution of 
   implicit syntax *)

let constr_of_string s 
	= Astterm.interp_constr Evd.empty (Global.env()) (parse_ast s);;

(* Get the current goal *)

let getgoal x = top_goal_of_pftreestate (Pfedit.get_pftreestate x);;

let get_nth_goal n = nth_goal_of_pftreestate n (Pfedit.get_pftreestate ());;
let current_goal () = get_nth_goal 1;;

let pf_e gl s = 
    Astterm.interp_constr (project gl) (pf_env gl) (parse_ast s);;

open Toplevel
let go = loop