]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaEngine.ml
1. Several files in grafite that should be in grafite_parser moved there.
[helm.git] / helm / matita / matitaEngine.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 open Printf
27
28 open GrafiteTypes
29
30 let debug = false ;;
31 let debug_print = if debug then prerr_endline else ignore ;;
32
33 let eval_from_stream 
34   ?do_heavy_checks ~include_paths ?clean_baseuri status str cb 
35 =
36   try
37     while true do
38       let ast = GrafiteParser.parse_statement str in
39       cb !status ast;
40       status :=
41        GrafiteEngine.eval_ast
42         ~baseuri_of_script:(GrafiteParserMisc.baseuri_of_script ~include_paths)
43         ~disambiguate_tactic:GrafiteDisambiguate.disambiguate_tactic
44         ~disambiguate_command:GrafiteDisambiguate.disambiguate_command
45         ?do_heavy_checks ?clean_baseuri !status ast
46     done
47   with End_of_file -> ()
48
49 let eval_from_stream_greedy 
50   ?do_heavy_checks ~include_paths ?clean_baseuri status str cb 
51 =
52   while true do
53     print_string "matita> ";
54     flush stdout;
55     let ast = GrafiteParser.parse_statement str in
56     cb !status ast;
57     status :=
58      GrafiteEngine.eval_ast
59       ~baseuri_of_script:(GrafiteParserMisc.baseuri_of_script ~include_paths)
60       ~disambiguate_tactic:GrafiteDisambiguate.disambiguate_tactic
61       ~disambiguate_command:GrafiteDisambiguate.disambiguate_command
62       ?do_heavy_checks ?clean_baseuri !status ast 
63   done
64 ;;
65
66 let eval_string ?do_heavy_checks ~include_paths ?clean_baseuri status str =
67   eval_from_stream 
68     ?do_heavy_checks ~include_paths ?clean_baseuri status
69       (Ulexing.from_utf8_string str) (fun _ _ -> ())
70
71 let default_options () = no_options
72
73 let initial_status =
74   lazy {
75     aliases = DisambiguateTypes.Environment.empty;
76     multi_aliases = DisambiguateTypes.Environment.empty;
77     moo_content_rev = [];
78     metadata = [];
79     proof_status = No_proof;
80     options = default_options ();
81     objects = [];
82     coercions = [];
83     notation_ids = [];
84   }
85