X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2Fmatita%2FmatitaInterpreter.ml;fp=helm%2Fmatita%2FmatitaInterpreter.ml;h=0000000000000000000000000000000000000000;hp=f5dd123f53ef6a18c6e29a43c7a9587621d7888e;hb=1696761e4b8576e8ed81caa905fd108717019226;hpb=5325734bc2e4927ed7ec146e35a6f0f2b49f50c1 diff --git a/helm/matita/matitaInterpreter.ml b/helm/matita/matitaInterpreter.ml deleted file mode 100644 index f5dd123f5..000000000 --- a/helm/matita/matitaInterpreter.ml +++ /dev/null @@ -1,126 +0,0 @@ -(* Copyright (C) 2004, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://helm.cs.unibo.it/ - *) - -open Printf - -type state_tag = [ `Command | `Proof ] - -exception Command_not_found of string - -class virtual interpreterState ~(console: MatitaConsole.console) = - object (self) - (** eval a toplevel phrase in the current state and return the new state - *) - method parsePhrase s = CicTextualParser2.parse_tactical (Stream.of_string s) - - method virtual evalTactical: - (CicAst.term, string) TacticAst.tactical -> state_tag - - method evalPhrase s = self#evalTactical (self#parsePhrase s) - end - -class commandState - ~(disambiguator: MatitaTypes.disambiguator) - ~(proof_handler: MatitaTypes.proof_handler) - ~(console: MatitaConsole.console) - () -= - object (self) - inherit interpreterState ~console - - method evalTactical = function -(* - | TacticAst.Command _ -> failwith "1" - | TacticAst.Tactic _ -> failwith "2" - | TacticAst.LocatedTactical _ -> failwith "3" - | TacticAst.Fail -> failwith "4" - | TacticAst.Do (_, _) -> failwith "5" - | TacticAst.IdTac -> failwith "6" - | TacticAst.Repeat _ -> failwith "7" - | TacticAst.Seq _ -> failwith "8" - | TacticAst.Then (_, _) -> failwith "9" - | TacticAst.Tries _ -> failwith "10" - | TacticAst.Try _ -> failwith "11" -*) - | TacticAst.LocatedTactical (_, tactical) -> self#evalTactical tactical - | TacticAst.Command (TacticAst.Theorem (_, Some name, ast, None)) -> - let (_, metasenv, expr) = disambiguator#disambiguateTermAst ast in - let _ = CicTypeChecker.type_of_aux' metasenv [] expr in - let proof = MatitaProof.proof ~typ:expr ~metasenv () in - proof_handler.MatitaTypes.new_proof proof; - `Proof - | TacticAst.Command TacticAst.Quit -> - proof_handler.MatitaTypes.quit (); - `Command (* dummy answer, useless *) - | TacticAst.Command TacticAst.Proof -> - (* do nothing, just for compatibility with coq syntax *) - `Command - | tactical -> - raise (Command_not_found (TacticAstPp.pp_tactical tactical)) - end - -class proofState - ~(disambiguator: MatitaTypes.disambiguator) - ~(proof_handler: MatitaTypes.proof_handler) - ~(console: MatitaConsole.console) - () -= - let commandState = - new commandState ~disambiguator ~proof_handler ~console () - in - object - inherit interpreterState ~console - - method evalTactical = function - | TacticAst.Command TacticAst.Abort -> - proof_handler.MatitaTypes.set_proof None; - `Command - | tactical -> (* fallback on command state *) - commandState#evalTactical tactical - end - -class interpreter - ~(disambiguator: MatitaTypes.disambiguator) - ~(proof_handler: MatitaTypes.proof_handler) - ~(console: MatitaConsole.console) - () -= - let commandState = - new commandState ~disambiguator ~proof_handler ~console () - in - let proofState = new proofState ~disambiguator ~proof_handler ~console () in - object - val mutable state = commandState - - method evalPhrase s = - try - (match state#evalPhrase s with - | `Command -> state <- commandState - | `Proof -> state <- proofState) - with exn -> - console#echo_error (sprintf "Uncaught exception: %s" - (Printexc.to_string exn)) - end -