| author | wenzelm | 
| Tue, 24 Mar 2009 13:12:23 +0100 | |
| changeset 30700 | dc38bb27df50 | 
| parent 29606 | fedb8be05f24 | 
| child 37216 | 3165bc303f66 | 
| permissions | -rw-r--r-- | 
| 21637 | 1 | (* Title: Pure/ProofGeneral/pgip_isabelle.ML | 
| 2 | Author: David Aspinall | |
| 3 | ||
| 22165 | 4 | Prover-side PGIP abstraction: Isabelle configuration and mapping to Isabelle types. | 
| 21637 | 5 | *) | 
| 6 | ||
| 7 | signature PGIP_ISABELLE = | |
| 8 | sig | |
| 9 | val isabelle_pgml_version_supported : string | |
| 10 | val isabelle_pgip_version_supported : string | |
| 23603 | 11 | val systemid : string | 
| 23799 | 12 | val accepted_inputs : (string * bool * (string list)) list | 
| 22165 | 13 | |
| 14 | val location_of_position : Position.T -> PgipTypes.location | |
| 22403 | 15 | |
| 16 | (* Additional types of objects in Isar scripts *) | |
| 17 | ||
| 18 | val ObjTheoryBody : PgipTypes.objtype | |
| 19 | val ObjTheoryDecl : PgipTypes.objtype | |
| 20 | val ObjTheoryBodySubsection : PgipTypes.objtype | |
| 21 | val ObjProofBody : PgipTypes.objtype | |
| 22 | val ObjFormalComment : PgipTypes.objtype | |
| 23 | val ObjClass : PgipTypes.objtype | |
| 24 | val ObjTheoremSet : PgipTypes.objtype | |
| 25 | val ObjOracle : PgipTypes.objtype | |
| 26 | val ObjLocale : PgipTypes.objtype | |
| 23799 | 27 | |
| 21637 | 28 | end | 
| 29 | ||
| 30 | structure PgipIsabelle : PGIP_ISABELLE = | |
| 31 | struct | |
| 32 | ||
| 23603 | 33 | val isabelle_pgml_version_supported = "2.0"; | 
| 21637 | 34 | val isabelle_pgip_version_supported = "2.0" | 
| 23603 | 35 | val systemid = "Isabelle" | 
| 21637 | 36 | |
| 23799 | 37 | |
| 21637 | 38 | (** Accepted commands **) | 
| 39 | ||
| 40 | local | |
| 41 | ||
| 42 | (* 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. *) | |
| 23799 | 44 | |
| 21637 | 45 | val accepted_names = | 
| 46 | (* not implemented: "askconfig", "forget", "restoregoal" *) | |
| 47 | ["askpgip","askpgml","askprefs","getpref","setpref", | |
| 48 | "proverinit","proverexit","startquiet","stopquiet", | |
| 49 | "pgmlsymbolson", "pgmlsymbolsoff", | |
| 23799 | 50 | "dostep", "undostep", "redostep", "abortgoal", | 
| 21637 | 51 | "askids", "showid", "askguise", | 
| 52 | "parsescript", | |
| 53 | "showproofstate", "showctxt", "searchtheorems", "setlinewidth", "viewdoc", | |
| 54 | "doitem", "undoitem", "redoitem", "abortheory", | |
| 55 | "retracttheory", "loadfile", "openfile", "closefile", | |
| 56 | "abortfile", "retractfile", "changecwd", "systemcmd"]; | |
| 57 | ||
| 23799 | 58 | fun element_async p = | 
| 59 | false (* single threaded only *) | |
| 21637 | 60 | |
| 61 | fun supported_optional_attrs p = (case p of | |
| 23799 | 62 | "undostep" => ["times"] | 
| 63 | (* TODO: we could probably extend these too: | |
| 64 | | "redostep" => ["times"] | |
| 65 | | "undoitem" => ["times"] | |
| 66 | | "redoitem" => ["times"] *) | |
| 67 | | _ => []) | |
| 21637 | 68 | in | 
| 23799 | 69 | val accepted_inputs = | 
| 21637 | 70 | (map (fn p=> (p, element_async p, supported_optional_attrs p)) | 
| 71 | accepted_names); | |
| 72 | end | |
| 73 | ||
| 22165 | 74 | |
| 23799 | 75 | fun location_of_position pos = | 
| 22165 | 76 | let val line = Position.line_of pos | 
| 26005 
431ab3907291
location_of_position: Position.column_of (which counts Isabelle symbols, not characters);
 wenzelm parents: 
23884diff
changeset | 77 | val column = Position.column_of pos | 
| 23799 | 78 | val (url,descr) = | 
| 79 | (case Position.file_of pos of | |
| 80 | NONE => (NONE, NONE) | |
| 81 | | SOME fname => | |
| 82 | let val path = Path.explode fname in | |
| 23884 
1d39ec4fe73f
simplified ThyLoad interfaces: only one additional directory;
 wenzelm parents: 
23867diff
changeset | 83 | case ThyLoad.check_file Path.current path of | 
| 23799 | 84 | SOME _ => (SOME (PgipTypes.pgipurl_of_path path), NONE) | 
| 85 | | NONE => (NONE, SOME fname) | |
| 86 | end); | |
| 23680 | 87 | in | 
| 26005 
431ab3907291
location_of_position: Position.column_of (which counts Isabelle symbols, not characters);
 wenzelm parents: 
23884diff
changeset | 88 |         { descr=descr, url=url, line=line, column=column, char=NONE, length=NONE }
 | 
| 23680 | 89 | end | 
| 22403 | 90 | |
| 91 | ||
| 92 | val [ObjTheoryBody, | |
| 93 | ObjTheoryDecl, | |
| 94 | ObjTheoryBodySubsection, | |
| 95 | ObjProofBody, | |
| 96 | ObjFormalComment, | |
| 97 | ObjClass, | |
| 98 | ObjTheoremSet, | |
| 99 | ObjOracle, | |
| 100 | ObjLocale] = | |
| 23799 | 101 | map PgipTypes.ObjOther | 
| 102 | ["theory body", | |
| 103 | "theory declaration", | |
| 104 | "theory subsection", | |
| 105 | "proof body", | |
| 106 | "formal comment", | |
| 107 | "class", | |
| 108 | "theorem set declaration", | |
| 109 | "oracle", | |
| 110 | "locale"]; | |
| 22403 | 111 | |
| 21637 | 112 | end |