1val _ = quietdec := true; 2 3(* ---------------------------------------------------------------------- 4 Establish the basic environment and bring in the HOL kernel 5 ---------------------------------------------------------------------- *) 6load "PP"; 7structure MosmlPP = PP 8 9(* ---------------------------------------------------------------------- 10 Set interactive flag to true 11 ---------------------------------------------------------------------- *) 12 13val _ = load "Globals"; 14val _ = Globals.interactive := true; 15 16val _ = app load 17 ["Mosml", "Process", "Path", "boolLib", "proofManagerLib", "Arbrat"]; 18 19open HolKernel Parse boolLib proofManagerLib; 20 21(* Loading HolKernel installs the "standard" set of infixes, which are 22 set up in src/0/Overlay.sml *) 23 24(*---------------------------------------------------------------------------* 25 * Install prettyprinters * 26 *---------------------------------------------------------------------------*) 27 28local 29 fun pp_from_stringfn sf pps x = PP.add_string (sf x) 30 fun gprint0 g t = let 31 val tyg = Parse.type_grammar() 32 val (_, ppt) = Parse.print_from_grammars (tyg,g) 33 in 34 ppt t 35 end 36 val gprint = (fn g => fn t => smpp.lift (gprint0 g) t) 37 fun ppg g = Parse.mlower (term_grammar.prettyprint_grammar gprint g) 38 fun ppgrules grs = 39 Parse.mlower (term_grammar.prettyprint_grammar_rules gprint grs) 40 fun timepp t = PP.add_string (Time.toString t ^ "s") 41 fun locpp l = PP.add_string (locn.toShortString l) 42 structure MPP = MosmlPP 43 open PrettyImpl 44in 45 fun mosmlpp ppfn pps x = let 46 val slist = ref ([] : string list) 47 fun output_slist () = (app (MPP.add_string pps) (List.rev (!slist)); 48 slist := []) 49 fun consume_string s = let 50 open Substring 51 val (pfx,sfx) = splitl (fn c => c <> #"\n") (full s) 52 in 53 if size sfx = 0 then slist := s :: !slist 54 else 55 (output_slist(); 56 MPP.add_newline pps; 57 if size sfx > 1 then consume_string (string (triml 1 sfx)) 58 else ()) 59 end 60 in 61 MPP.begin_block pps MPP.INCONSISTENT 0; 62 HOLPP.prettyPrint(consume_string, !Globals.linewidth) (ppfn x); 63 MPP.end_block pps; 64 output_slist() 65 end 66 val _ = installPP (mosmlpp Pretype.pp_pretype) 67 val _ = installPP (mosmlpp (Parse.term_pp_with_delimiters Hol_pp.pp_term)) 68 val _ = installPP (mosmlpp (Parse.type_pp_with_delimiters Hol_pp.pp_type)) 69 val _ = installPP (mosmlpp Hol_pp.pp_thm) 70 val _ = installPP (mosmlpp Hol_pp.pp_theory) 71 val _ = installPP (mosmlpp type_grammar.prettyprint_grammar) 72 val _ = installPP (mosmlpp ppg) 73 val _ = installPP (mosmlpp ppgrules) 74 val _ = installPP (mosmlpp proofManagerLib.pp_proof) 75 val _ = installPP (mosmlpp proofManagerLib.pp_proofs) 76 val _ = installPP (mosmlpp Rewrite.pp_rewrites) 77 val _ = installPP (mosmlpp TypeBasePure.pp_tyinfo) 78 val _ = installPP (mosmlpp DefnBase.pp_defn) 79 val _ = installPP (mosmlpp Arbnum.pp_num) 80 val _ = installPP (mosmlpp Arbint.pp_int) 81 val _ = installPP (mosmlpp Arbrat.pp_rat) 82 val _ = installPP (mosmlpp timepp) 83 val _ = installPP (mosmlpp locpp) 84end; 85 86 87(*---------------------------------------------------------------------------* 88 * Set up the help paths. * 89 *---------------------------------------------------------------------------*) 90 91local 92 open Path 93 fun HELP s = toString(fromString(concat(HOLDIR, concat("help",s)))) 94 val SIGOBJ = toString(fromString(concat(HOLDIR, "sigobj"))) 95in 96 val () = indexfiles := HELP "HOL.Help" :: !indexfiles 97 val () = helpdirs := HOLDIR :: SIGOBJ :: !helpdirs 98 val () = Help.specialfiles := 99 {file = "help/Docfiles/HOL.help", 100 term = "hol", title = "HOL Overview"} 101 :: !Help.specialfiles 102end 103 104 105(*---------------------------------------------------------------------------* 106 * Set parameters for parsing and help. * 107 *---------------------------------------------------------------------------*) 108 109val _ = quotation := true 110val _ = Help.displayLines := 60; 111 112(*---------------------------------------------------------------------------* 113 * Set up compile_theory function * 114 *---------------------------------------------------------------------------*) 115 116fun compile_theory () = let 117 val name = current_theory() 118 val signame = name^"Theory.sig" 119 val smlname = name^"Theory.sml" 120 fun readable f = FileSys.access(f, [FileSys.A_READ]) 121in 122 if readable signame andalso readable smlname then let 123 in 124 Meta.compileStructure ["Overlay"] signame; 125 Meta.compileStructure ["Overlay"] smlname; 126 print ("Compiled "^name^" theory files.\n") 127 end 128 else 129 print "No theory files on disk; perhaps export_theory() required.\n" 130end 131 132 133(*---------------------------------------------------------------------------* 134 * Print a banner. * 135 *---------------------------------------------------------------------------*) 136 137val build_stamp = 138 let open TextIO Path 139 val stampstr = openIn (concat(HOLDIR, concat("tools", "build-stamp"))) 140 val stamp = inputAll stampstr before closeIn stampstr 141 in 142 stamp 143 end handle _ => ""; 144 145val exit_string = 146 if Systeml.OS = "winNT" then 147 "To exit type <Control>-Z <Return> (*not* quit();)" 148 else 149 "To exit type <Control>-D (*not* quit();)" 150 151 152(* ---------------------------------------------------------------------- 153 if present, look at a Holmakefile in the current directory to see 154 if we should extend the loadPath 155 ---------------------------------------------------------------------- *) 156 157structure HOL_Interactive : sig 158 val toggle_quietdec : unit -> bool 159 val amquiet : unit -> bool 160 val print_banner : unit -> unit 161end = 162struct 163 fun toggle_quietdec () = (Meta.quietdec := not (!Meta.quietdec) ; 164 !Meta.quietdec) 165 fun amquiet () = !Meta.quietdec 166 fun print_banner() = 167 TextIO.output(TextIO.stdOut, 168 "\n---------------------------------------------------------------------\n" 169 ^" HOL-4 [" 170 ^Globals.release^" "^Lib.int_to_string(Globals.version) 171 ^" ("^Thm.kernelid^", "^build_stamp 172 ^")]\n\n" 173 ^" For introductory HOL help, type: help \"hol\";\n" 174 ^" "^exit_string 175 ^"\n---------------------------------------------------------------------\ 176 \\n\n") 177 178end; 179 180val _ = HOL_Interactive.print_banner() 181 182local 183 open Path 184in 185 val _ = loadPath := concat (HOLDIR, concat ("tools", "Holmake")) :: !loadPath 186 val _ = load "ReadHMF.uo" 187 val _ = loadPath := tl (!loadPath) 188end; 189 190val _ = ReadHMF.extend_path_with_includes {quietp = false, lpref = loadPath}; 191 192use (Path.concat(Globals.HOLDIR, "tools/check-intconfig.sml")); 193 194(* Local variables: *) 195(* mode: sml *) 196(* end: *) 197