1 (* Copyright (C) 2004, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 type state_tag = [ `Command | `Proof ]
28 class type interpreterState =
30 (** eval a toplevel phrase in the current state and return the new state
32 method evalPhrase: string -> state_tag
36 ~(disambiguator: MatitaTypes.disambiguator)
37 ~(console: MatitaConsole.console)
41 method evalPhrase s: state_tag =
42 let command = CicTextualParser2.parse_command (Stream.of_string s) in
44 | CommandAst.Theorem (_, _, Some name, ast, None) ->
45 let (_, metasenv, expr) = disambiguator#disambiguateTermAst ast in
46 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
47 let proof = MatitaProof.proof ~typ:expr ~metasenv () in
51 MatitaTypes.not_implemented (* TODO Zack *)
52 "MatitaInterpreter.commandState#evalPhrase: commands other than full theorem ones";
57 ~(disambiguator: MatitaTypes.disambiguator)
58 ~(console: MatitaConsole.console)
62 method evalPhrase (s: string): state_tag =
64 MatitaTypes.not_implemented "MatitaInterpreter.proofState#evalPhrase";
69 ~(disambiguator: MatitaTypes.disambiguator)
70 ~(console: MatitaConsole.console)
71 ~(get_proof: unit -> MatitaTypes.proof)
72 ~(new_proof: MatitaTypes.proof -> unit)
76 lazy (new commandState ~disambiguator ~console ~new_proof ())
79 lazy (new proofState ~disambiguator ~console ~get_proof ())
82 val mutable state = Lazy.force commandState
85 match state#evalPhrase s with
86 | `Command -> state <- Lazy.force commandState
87 | `Proof -> state <- Lazy.force proofState