X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatitac.ml;h=179a0ba8e8e508e413f22958cef5c20cc1039fbc;hb=1776f357e1a69fa1133956660b65d7bafdfe5c25;hp=95b500b879ee3e44201009f0f730bc8512d9990c;hpb=7f2444c2670cadafddd8785b687ef312158376b0;p=helm.git diff --git a/matita/matitac.ml b/matita/matitac.ml index 95b500b87..179a0ba8e 100644 --- a/matita/matitac.ml +++ b/matita/matitac.ml @@ -25,15 +25,84 @@ (* $Id$ *) +module G = GrafiteAst +module L = LexiconAst +module H = HExtlib + +(* from transcript *) + +let out_comment och s = + let s = if s <> "" && s.[0] = '*' then "#" ^ s else s in + Printf.fprintf och "%s%s%s\n\n" "(*" s "*)" + +let out_line_comment och s = + let l = 70 - String.length s in + let s = Printf.sprintf " %s %s" s (String.make l '*') in + out_comment och s + +let out_preamble och (path, lines) = + let ich = open_in path in + let rec print i = + if i > 0 then + let s = input_line ich in + begin Printf.fprintf och "%s\n" s; print (pred i) end + in + print lines; + out_line_comment och "This file was automatically generated: do not edit" + +(* from matitacLib *) + +let pp_ast_statement st = + GrafiteAstPp.pp_statement ~term_pp:CicNotationPp.pp_term + ~map_unicode_to_tex:(Helm_registry.get_bool + "matita.paste_unicode_as_tex") + ~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:(CicNotationPp.pp_obj CicNotationPp.pp_term) st + +(**) + +let dump f = + Helm_registry.set_bool "matita.moo" false; + let floc = H.dummy_floc in + let nl_ast = G.Comment (floc, G.Note (floc, "")) in + let och = open_out f in + let atexit () = close_out och in + let nl () = output_string och (pp_ast_statement nl_ast) in + let rt_base_dir = Filename.dirname Sys.argv.(0) in + let path = Filename.concat rt_base_dir "matita.ma.templ" in + let lines = 14 in + out_preamble och (path, lines); + let grafite_parser_cb fname = + let ast = G.Executable (floc, G.Command (floc, G.Include (floc, fname))) in + output_string och (pp_ast_statement ast); nl (); nl () + in + let matita_engine_cb = function + | G.Executable (_, G.Macro (_, G.Inline _)) + | G.Executable (_, G.Command (_, G.Include _)) -> () + | ast -> + output_string och (pp_ast_statement ast); nl (); nl () + in + let matitac_lib_cb = output_string och in + GrafiteParser.set_callback grafite_parser_cb; + MatitaEngine.set_callback matita_engine_cb; + MatitacLib.set_callback matitac_lib_cb; + at_exit atexit + let main () = - match Filename.basename Sys.argv.(0) with - | "matitadep" | "matitadep.opt" -> Matitadep.main () - | "matitaclean" | "matitaclean.opt" -> Matitaclean.main () - | "matitamake" | "matitamake.opt" -> Matitamake.main () - | _ -> + Helm_registry.set_bool "matita.moo" true; + match Filename.basename Sys.argv.(0) with + |"gragrep" |"gragrep.opt" |"gragrep.opt.static" ->Gragrep.main() + |"matitadep" |"matitadep.opt" |"matitadep.opt.static" ->Matitadep.main() + |"matitaclean"|"matitaclean.opt"|"matitaclean.opt.static"->Matitaclean.main() + |"matitamake" |"matitamake.opt" |"matitamake.opt.static" ->Matitamake.main() + |"matitaprover"|"matitaprover.opt" + |"matitaprover.opt.static" ->Matitaprover.main() + |"matitawiki"|"matitawiki.opt" ->MatitaWiki.main() + | _ -> (* let _ = Paramodulation.Saturation.init () in *) (* ALB to link paramodulation *) + let dump_msg = " Dump source with expanded macros to " in + MatitaInit.add_cmdline_spec ["-dump", Arg.String dump, dump_msg]; let _ = MatitacLib.main `COMPILER in ()