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