src/Pure/ProofGeneral/pgip_isabelle.ML
changeset 23799 20f58293fc5e
parent 23680 09ccdb1b93ba
child 23867 743f34b12f67
equal deleted inserted replaced
23798:fac9ea4d58ab 23799:20f58293fc5e
     8 signature PGIP_ISABELLE =
     8 signature PGIP_ISABELLE =
     9 sig
     9 sig
    10     val isabelle_pgml_version_supported : string
    10     val isabelle_pgml_version_supported : string
    11     val isabelle_pgip_version_supported : string
    11     val isabelle_pgip_version_supported : string
    12     val systemid : string
    12     val systemid : string
    13     val accepted_inputs : (string * bool * (string list)) list 
    13     val accepted_inputs : (string * bool * (string list)) list
    14 
    14 
    15     val location_of_position : Position.T -> PgipTypes.location
    15     val location_of_position : Position.T -> PgipTypes.location
    16 
    16 
    17     (* Additional types of objects in Isar scripts *)
    17     (* Additional types of objects in Isar scripts *)
    18 
    18 
    23     val ObjFormalComment : PgipTypes.objtype
    23     val ObjFormalComment : PgipTypes.objtype
    24     val ObjClass : PgipTypes.objtype
    24     val ObjClass : PgipTypes.objtype
    25     val ObjTheoremSet : PgipTypes.objtype
    25     val ObjTheoremSet : PgipTypes.objtype
    26     val ObjOracle : PgipTypes.objtype
    26     val ObjOracle : PgipTypes.objtype
    27     val ObjLocale : PgipTypes.objtype
    27     val ObjLocale : PgipTypes.objtype
    28 	
    28 
    29 end
    29 end
    30 
    30 
    31 structure PgipIsabelle : PGIP_ISABELLE =
    31 structure PgipIsabelle : PGIP_ISABELLE =
    32 struct
    32 struct
    33 
    33 
    34 val isabelle_pgml_version_supported = "2.0";
    34 val isabelle_pgml_version_supported = "2.0";
    35 val isabelle_pgip_version_supported = "2.0"
    35 val isabelle_pgip_version_supported = "2.0"
    36 val systemid = "Isabelle"
    36 val systemid = "Isabelle"
    37 
    37 
       
    38 
    38 (** Accepted commands **)
    39 (** Accepted commands **)
    39 
    40 
    40 local
    41 local
    41 
    42 
    42     (* These element names are a subset of those in pgip_input.ML.
    43     (* These element names are a subset of those in pgip_input.ML.
    43        They must be handled in proof_general_pgip.ML/process_pgip_element. *)
    44        They must be handled in proof_general_pgip.ML/process_pgip_element. *)
    44 						    
    45 
    45     val accepted_names =
    46     val accepted_names =
    46     (* not implemented: "askconfig", "forget", "restoregoal" *)
    47     (* not implemented: "askconfig", "forget", "restoregoal" *)
    47     ["askpgip","askpgml","askprefs","getpref","setpref",
    48     ["askpgip","askpgml","askprefs","getpref","setpref",
    48      "proverinit","proverexit","startquiet","stopquiet",
    49      "proverinit","proverexit","startquiet","stopquiet",
    49      "pgmlsymbolson", "pgmlsymbolsoff",
    50      "pgmlsymbolson", "pgmlsymbolsoff",
    50      "dostep", "undostep", "redostep", "abortgoal", 
    51      "dostep", "undostep", "redostep", "abortgoal",
    51      "askids", "showid", "askguise",
    52      "askids", "showid", "askguise",
    52      "parsescript",
    53      "parsescript",
    53      "showproofstate", "showctxt", "searchtheorems", "setlinewidth", "viewdoc",
    54      "showproofstate", "showctxt", "searchtheorems", "setlinewidth", "viewdoc",
    54      "doitem", "undoitem", "redoitem", "abortheory",
    55      "doitem", "undoitem", "redoitem", "abortheory",
    55      "retracttheory", "loadfile", "openfile", "closefile",
    56      "retracttheory", "loadfile", "openfile", "closefile",
    56      "abortfile", "retractfile", "changecwd", "systemcmd"];
    57      "abortfile", "retractfile", "changecwd", "systemcmd"];
    57 
    58 
    58     fun element_async p = 
    59     fun element_async p =
    59 	false (* single threaded only *)
    60         false (* single threaded only *)
    60 
    61 
    61     fun supported_optional_attrs p = (case p of
    62     fun supported_optional_attrs p = (case p of
    62 					  "undostep" => ["times"]
    63                                           "undostep" => ["times"]
    63 					(* TODO: we could probably extend these too:
    64                                         (* TODO: we could probably extend these too:
    64 					| "redostep" => ["times"]
    65                                         | "redostep" => ["times"]
    65 					| "undoitem" => ["times"]
    66                                         | "undoitem" => ["times"]
    66 					| "redoitem" => ["times"] *)
    67                                         | "redoitem" => ["times"] *)
    67 				        | _ => [])
    68                                         | _ => [])
    68 in
    69 in
    69 val accepted_inputs = 
    70 val accepted_inputs =
    70     (map (fn p=> (p, element_async p, supported_optional_attrs p))
    71     (map (fn p=> (p, element_async p, supported_optional_attrs p))
    71          accepted_names);
    72          accepted_names);
    72 end
    73 end
    73 
    74 
    74 
    75 
    75 fun location_of_position pos = 
    76 fun location_of_position pos =
    76     let val line = Position.line_of pos
    77     let val line = Position.line_of pos
    77 	val (url,descr) = 
    78         val (url,descr) =
    78 	    (case Position.file_of pos of
    79             (case Position.file_of pos of
    79 	       NONE => (NONE, NONE)
    80                NONE => (NONE, NONE)
    80 	     | SOME fname => 
    81              | SOME fname =>
    81 	       let val path = Path.explode fname in
    82                let val path = Path.explode fname in
    82 		 case ThyLoad.check_file NONE path of
    83                  case ThyLoad.check_file NONE path of
    83 		   SOME _ => (SOME (PgipTypes.pgipurl_of_path path), NONE)
    84                    SOME _ => (SOME (PgipTypes.pgipurl_of_path path), NONE)
    84 		 | NONE => (NONE, SOME fname)
    85                  | NONE => (NONE, SOME fname)
    85 	       end);
    86                end);
    86     in
    87     in
    87 	{ descr=descr, url=url, line=line, column=NONE, char=NONE, length=NONE }
    88         { descr=descr, url=url, line=line, column=NONE, char=NONE, length=NONE }
    88     end
    89     end
    89 
    90 
    90 
    91 
    91 val [ObjTheoryBody,
    92 val [ObjTheoryBody,
    92      ObjTheoryDecl,
    93      ObjTheoryDecl,
    95      ObjFormalComment,
    96      ObjFormalComment,
    96      ObjClass,
    97      ObjClass,
    97      ObjTheoremSet,
    98      ObjTheoremSet,
    98      ObjOracle,
    99      ObjOracle,
    99      ObjLocale] =
   100      ObjLocale] =
   100     map PgipTypes.ObjOther 
   101     map PgipTypes.ObjOther
   101 	["theory body", 
   102         ["theory body",
   102 	 "theory declaration",
   103          "theory declaration",
   103 	 "theory subsection",
   104          "theory subsection",
   104 	 "proof body",
   105          "proof body",
   105 	 "formal comment",
   106          "formal comment",
   106 	 "class",
   107          "class",
   107 	 "theorem set declaration",
   108          "theorem set declaration",
   108 	 "oracle",
   109          "oracle",
   109 	 "locale"];
   110          "locale"];
   110 
   111 
   111 	
       
   112 end
   112 end
   113