| author | wenzelm | 
| Thu, 12 Jun 2008 18:54:29 +0200 | |
| changeset 27178 | c8ddb3000743 | 
| parent 26548 | 41bbcaf3e481 | 
| child 28020 | 1ff5167592ba | 
| permissions | -rw-r--r-- | 
| 21637 | 1 | (* Title: Pure/ProofGeneral/pgip_output.ML | 
| 2 | ID: $Id$ | |
| 3 | Author: David Aspinall | |
| 4 | ||
| 21940 | 5 | PGIP abstraction: output commands. | 
| 21637 | 6 | *) | 
| 7 | ||
| 8 | signature PGIPOUTPUT = | |
| 9 | sig | |
| 10 | (* These are the PGIP messages which the prover emits. *) | |
| 11 | datatype pgipoutput = | |
| 26548 | 12 |       Normalresponse      of { content: XML.tree list }
 | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 13 |     | Errorresponse       of { fatality: PgipTypes.fatality, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 14 | location: PgipTypes.location option, | 
| 26548 | 15 | content: XML.tree list } | 
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 16 |     | Informfileloaded    of { url: PgipTypes.pgipurl, completed: bool }
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 17 |     | Informfileoutdated  of { url: PgipTypes.pgipurl, completed: bool }
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 18 |     | Informfileretracted of { url: PgipTypes.pgipurl, completed: bool }
 | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 19 |     | Metainforesponse    of { attrs: XML.attributes, 
 | 
| 26548 | 20 | content: XML.tree list } | 
| 21 |     | Lexicalstructure    of { content: XML.tree list }
 | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 22 |     | Proverinfo          of { name: string, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 23 | version: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 24 | instance: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 25 | descr: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 26 | url: Url.T, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 27 | filenameextns: string } | 
| 21867 | 28 |     | Setids              of { idtables: PgipTypes.idtable list  }
 | 
| 29 |     | Delids              of { idtables: PgipTypes.idtable list }
 | |
| 30 |     | Addids              of { idtables: PgipTypes.idtable list }
 | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 31 |     | Hasprefs            of { prefcategory: string option, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 32 | prefs: PgipTypes.preference list } | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 33 |     | Prefval             of { name: string, value: string }
 | 
| 22161 | 34 |     | Setrefs             of { url: PgipTypes.pgipurl option,
 | 
| 35 | thyname: PgipTypes.objname option, | |
| 36 | objtype: PgipTypes.objtype option, | |
| 37 | name: PgipTypes.objname option, | |
| 38 | idtables: PgipTypes.idtable list, | |
| 39 | fileurls : PgipTypes.pgipurl list } | |
| 22336 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 40 |     | Idvalue             of { thyname: PgipTypes.objname option,
 | 
| 21867 | 41 | objtype: PgipTypes.objtype, | 
| 22336 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 42 | name: PgipTypes.objname, | 
| 26548 | 43 | text: XML.tree list } | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 44 |     | Informguise         of { file : PgipTypes.pgipurl option,  
 | 
| 21867 | 45 | theory: PgipTypes.objname option, | 
| 46 | theorem: PgipTypes.objname option, | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 47 | proofpos: int option } | 
| 21867 | 48 |     | Parseresult         of { attrs: XML.attributes, doc:PgipMarkup.pgipdocument, 
 | 
| 26548 | 49 | errs: XML.tree list } (* errs to become PGML *) | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 50 |     | Usespgip            of { version: string, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 51 | pgipelems: (string * bool * string list) list } | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 52 |     | Usespgml            of { version: string }
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 53 |     | Pgip                of { tag: string option, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 54 | class: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 55 | seq: int, id: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 56 | destid: string option, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 57 | refid: string option, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 58 | refseq: int option, | 
| 26548 | 59 | content: XML.tree list } | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 60 |     | Ready               of { }
 | 
| 21637 | 61 | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 62 | val output : pgipoutput -> XML.tree | 
| 21637 | 63 | end | 
| 64 | ||
| 65 | structure PgipOutput : PGIPOUTPUT = | |
| 66 | struct | |
| 67 | open PgipTypes | |
| 68 | ||
| 69 | datatype pgipoutput = | |
| 26548 | 70 | 	 Normalresponse      of { content: XML.tree list }
 | 
| 23749 
ac6d3a8d22b5
Track schema changes: remove cleardisplay, proofstate messages. Simplify attributes on cleardisplay, normalresponse.
 aspinall parents: 
23610diff
changeset | 71 |        | Errorresponse       of { fatality: fatality, 
 | 
| 
ac6d3a8d22b5
Track schema changes: remove cleardisplay, proofstate messages. Simplify attributes on cleardisplay, normalresponse.
 aspinall parents: 
23610diff
changeset | 72 | location: location option, | 
| 26548 | 73 | content: XML.tree list } | 
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 74 |        | Informfileloaded    of { url: Path.T, completed: bool }
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 75 |        | Informfileoutdated  of { url: Path.T, completed: bool }
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 76 |        | Informfileretracted of { url: Path.T, completed: bool }
 | 
| 26548 | 77 |        | Metainforesponse    of { attrs: XML.attributes, content: XML.tree list }
 | 
| 78 |        | Lexicalstructure    of { content: XML.tree list }
 | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 79 |        | Proverinfo          of { name: string, version: string, instance: string,
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 80 | descr: string, url: Url.T, filenameextns: string } | 
| 21867 | 81 |        | Setids              of { idtables: PgipTypes.idtable list  }
 | 
| 82 |        | Delids              of { idtables: PgipTypes.idtable list }
 | |
| 83 |        | Addids              of { idtables: PgipTypes.idtable list }
 | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 84 |        | Hasprefs            of { prefcategory: string option, prefs: preference list }
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 85 |        | Prefval             of { name: string, value: string }
 | 
| 22336 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 86 |        | Idvalue             of { thyname: PgipTypes.objname option,
 | 
| 21867 | 87 | objtype: PgipTypes.objtype, | 
| 22336 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 88 | name: PgipTypes.objname, | 
| 26548 | 89 | text: XML.tree list } | 
| 22161 | 90 |        | Setrefs             of { url: PgipTypes.pgipurl option,
 | 
| 91 | thyname: PgipTypes.objname option, | |
| 92 | objtype: PgipTypes.objtype option, | |
| 93 | name: PgipTypes.objname option, | |
| 94 | idtables: PgipTypes.idtable list, | |
| 95 | fileurls : PgipTypes.pgipurl list } | |
| 21867 | 96 |        | Informguise         of { file : PgipTypes.pgipurl option,  
 | 
| 97 | theory: PgipTypes.objname option, | |
| 98 | theorem: PgipTypes.objname option, | |
| 99 | proofpos: int option } | |
| 100 |        | Parseresult         of { attrs: XML.attributes, doc: PgipMarkup.pgipdocument,
 | |
| 26548 | 101 | errs: XML.tree list } (* errs to become PGML *) | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 102 |        | Usespgip            of { version: string, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 103 | pgipelems: (string * bool * string list) list } | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 104 |        | Usespgml            of { version: string }
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 105 |        | Pgip                of { tag: string option, 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 106 | class: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 107 | seq: int, id: string, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 108 | destid: string option, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 109 | refid: string option, | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 110 | refseq: int option, | 
| 26548 | 111 | content: XML.tree list } | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 112 |        | Ready               of { }
 | 
| 21637 | 113 | |
| 114 | ||
| 115 | (* Construct output XML messages *) | |
| 21902 | 116 | |
| 117 | fun normalresponse (Normalresponse vs) = | |
| 21637 | 118 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 119 | val content = #content vs | 
| 21637 | 120 | in | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 121 |         XML.Elem ("normalresponse", 
 | 
| 23749 
ac6d3a8d22b5
Track schema changes: remove cleardisplay, proofstate messages. Simplify attributes on cleardisplay, normalresponse.
 aspinall parents: 
23610diff
changeset | 122 | [], | 
| 
ac6d3a8d22b5
Track schema changes: remove cleardisplay, proofstate messages. Simplify attributes on cleardisplay, normalresponse.
 aspinall parents: 
23610diff
changeset | 123 | content) | 
| 21637 | 124 | end | 
| 21902 | 125 | |
| 126 | fun errorresponse (Errorresponse vs) = | |
| 21637 | 127 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 128 | val fatality = #fatality vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 129 | val location = #location vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 130 | val content = #content vs | 
| 21637 | 131 | in | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 132 |         XML.Elem ("errorresponse",
 | 
| 21940 | 133 | attrs_of_fatality fatality @ | 
| 134 | these (Option.map attrs_of_location location), | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 135 | content) | 
| 21637 | 136 | end | 
| 137 | ||
| 21902 | 138 | fun informfileloaded (Informfileloaded vs) = | 
| 21637 | 139 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 140 | val url = #url vs | 
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 141 | val completed = #completed vs | 
| 21637 | 142 | in | 
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 143 |         XML.Elem ("informfileloaded", 
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 144 | attrs_of_pgipurl url @ | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 145 | (attr "completed" (PgipTypes.bool_to_pgstring completed)), | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 146 | []) | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 147 | end | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 148 | |
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 149 | fun informfileoutdated (Informfileoutdated vs) = | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 150 | let | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 151 | val url = #url vs | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 152 | val completed = #completed vs | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 153 | in | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 154 |         XML.Elem ("informfileoutdated", 
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 155 | attrs_of_pgipurl url @ | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 156 | (attr "completed" (PgipTypes.bool_to_pgstring completed)), | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 157 | []) | 
| 21637 | 158 | end | 
| 159 | ||
| 21902 | 160 | fun informfileretracted (Informfileretracted vs) = | 
| 161 | let | |
| 162 | val url = #url vs | |
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 163 | val completed = #completed vs | 
| 21902 | 164 | in | 
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 165 |         XML.Elem ("informfileretracted", 
 | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 166 | attrs_of_pgipurl url @ | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 167 | (attr "completed" (PgipTypes.bool_to_pgstring completed)), | 
| 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 168 | []) | 
| 21902 | 169 | end | 
| 21637 | 170 | |
| 21902 | 171 | fun metainforesponse (Metainforesponse vs) = | 
| 21637 | 172 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 173 | val attrs = #attrs vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 174 | val content = #content vs | 
| 21637 | 175 | in | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 176 |         XML.Elem ("metainforesponse", attrs, content)
 | 
| 21637 | 177 | end | 
| 178 | ||
| 21902 | 179 | fun lexicalstructure (Lexicalstructure vs) = | 
| 21637 | 180 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 181 | val content = #content vs | 
| 21637 | 182 | in | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 183 |         XML.Elem ("lexicalstructure", [], content)
 | 
| 21637 | 184 | end | 
| 185 | ||
| 21902 | 186 | fun proverinfo (Proverinfo vs) = | 
| 21637 | 187 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 188 | val name = #name vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 189 | val version = #version vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 190 | val instance = #instance vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 191 | val descr = #descr vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 192 | val url = #url vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 193 | val filenameextns = #filenameextns vs | 
| 21637 | 194 | in | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 195 |         XML.Elem ("proverinfo",
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 196 |                  [("name", name),
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 197 |                   ("version", version),
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 198 |                   ("instance", instance), 
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 199 |                   ("descr", descr),
 | 
| 21858 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
21655diff
changeset | 200 |                   ("url", Url.implode url),
 | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 201 |                   ("filenameextns", filenameextns)],
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 202 | []) | 
| 21637 | 203 | end | 
| 204 | ||
| 21902 | 205 | fun setids (Setids vs) = | 
| 21637 | 206 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 207 | val idtables = #idtables vs | 
| 21637 | 208 | in | 
| 21867 | 209 |         XML.Elem ("setids",[],map idtable_to_xml idtables)
 | 
| 21637 | 210 | end | 
| 211 | ||
| 22161 | 212 | fun setrefs (Setrefs vs) = | 
| 213 | let | |
| 214 | val url = #url vs | |
| 215 | val thyname = #thyname vs | |
| 216 | val objtype = #objtype vs | |
| 217 | val name = #name vs | |
| 218 | val idtables = #idtables vs | |
| 219 | val fileurls = #fileurls vs | |
| 220 | 	fun fileurl_to_xml url = XML.Elem ("fileurl", attrs_of_pgipurl url, [])
 | |
| 221 | in | |
| 222 |         XML.Elem ("setrefs",
 | |
| 223 | (Option.getOpt (Option.map attrs_of_pgipurl url,[])) @ | |
| 224 | (Option.getOpt (Option.map attrs_of_objtype objtype,[])) @ | |
| 225 | (opt_attr "thyname" thyname) @ | |
| 226 | (opt_attr "name" name), | |
| 227 | (map idtable_to_xml idtables) @ | |
| 228 | (map fileurl_to_xml fileurls)) | |
| 229 | end | |
| 230 | ||
| 21902 | 231 | fun addids (Addids vs) = | 
| 21637 | 232 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 233 | val idtables = #idtables vs | 
| 21637 | 234 | in | 
| 21867 | 235 |         XML.Elem ("addids",[],map idtable_to_xml idtables)
 | 
| 21637 | 236 | end | 
| 237 | ||
| 21902 | 238 | fun delids (Delids vs) = | 
| 21637 | 239 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 240 | val idtables = #idtables vs | 
| 21637 | 241 | in | 
| 21867 | 242 |         XML.Elem ("delids",[],map idtable_to_xml idtables)
 | 
| 21637 | 243 | end | 
| 244 | ||
| 21902 | 245 | fun hasprefs (Hasprefs vs) = | 
| 21637 | 246 | let | 
| 247 | val prefcategory = #prefcategory vs | |
| 248 | val prefs = #prefs vs | |
| 249 | in | |
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 250 |       XML.Elem("hasprefs",opt_attr "prefcategory" prefcategory, map haspref prefs)
 | 
| 21637 | 251 | end | 
| 252 | ||
| 21902 | 253 | fun prefval (Prefval vs) = | 
| 21637 | 254 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 255 | val name = #name vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 256 | val value = #value vs | 
| 21637 | 257 | in | 
| 21651 | 258 |         XML.Elem("prefval", attr "name" name, [XML.Text value])
 | 
| 21637 | 259 | end | 
| 260 | ||
| 21902 | 261 | fun idvalue (Idvalue vs) = | 
| 21637 | 262 | let | 
| 22336 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 263 | val objtype_attrs = attrs_of_objtype (#objtype vs) | 
| 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 264 | val thyname = #thyname vs | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 265 | val name = #name vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 266 | val text = #text vs | 
| 21637 | 267 | in | 
| 22336 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 268 |         XML.Elem("idvalue", 
 | 
| 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 269 | objtype_attrs @ | 
| 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 270 | (opt_attr "thyname" thyname) @ | 
| 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 271 | (attr "name" name), | 
| 
050ceb649207
<idvalue>: add name attribute to allow unsolicited updates.
 aspinall parents: 
22161diff
changeset | 272 | text) | 
| 21902 | 273 | end | 
| 21637 | 274 | |
| 21902 | 275 | fun informguise (Informguise vs) = | 
| 21637 | 276 | let | 
| 277 | val file = #file vs | |
| 278 | val theory = #theory vs | |
| 279 | val theorem = #theorem vs | |
| 280 | val proofpos = #proofpos vs | |
| 281 | ||
| 282 | fun elto nm attrfn xo = case xo of NONE=>[] | SOME x=>[XML.Elem(nm,attrfn x,[])] | |
| 283 | ||
| 284 | val guisefile = elto "guisefile" attrs_of_pgipurl file | |
| 285 | val guisetheory = elto "guisetheory" (single o (pair "thyname")) theory | |
| 286 | val guiseproof = elto "guiseproof" | |
| 21651 | 287 | (fn thm=>(attr "thmname" thm) @ | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 288 | (opt_attr "proofpos" (Option.map Int.toString proofpos))) theorem | 
| 21637 | 289 | in | 
| 290 |       XML.Elem("informguise", [], guisefile @ guisetheory @ guiseproof)
 | |
| 291 | end | |
| 292 | ||
| 21902 | 293 | fun parseresult (Parseresult vs) = | 
| 21637 | 294 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 295 | val attrs = #attrs vs | 
| 21867 | 296 | val doc = #doc vs | 
| 297 | val errs = #errs vs | |
| 298 | val xmldoc = PgipMarkup.output_doc doc | |
| 21637 | 299 | in | 
| 21940 | 300 |         XML.Elem("parseresult", attrs, errs @ xmldoc)
 | 
| 21637 | 301 | end | 
| 302 | ||
| 21902 | 303 | fun acceptedpgipelems (Usespgip vs) = | 
| 304 | let | |
| 305 | val pgipelems = #pgipelems vs | |
| 306 | fun async_attrs b = if b then attr "async" "true" else [] | |
| 307 | fun attrs_attrs attrs = if attrs=[] then [] else attr "attributes" (space_implode "," attrs) | |
| 308 | fun singlepgipelem (e,async,attrs) = | |
| 309 |             XML.Elem("pgipelem", ((async_attrs async) @ (attrs_attrs attrs)),[XML.Text e])
 | |
| 310 | ||
| 311 | in | |
| 312 |         XML.Elem ("acceptedpgipelems", [],
 | |
| 313 | map singlepgipelem pgipelems) | |
| 314 | end | |
| 315 | ||
| 316 | fun usespgip (Usespgip vs) = | |
| 21637 | 317 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 318 | val version = #version vs | 
| 21902 | 319 | val acceptedelems = acceptedpgipelems (Usespgip vs) | 
| 21637 | 320 | in | 
| 21651 | 321 |         XML.Elem("usespgip", attr "version" version, [acceptedelems])
 | 
| 21637 | 322 | end | 
| 323 | ||
| 21902 | 324 | fun usespgml (Usespgml vs) = | 
| 21637 | 325 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 326 | val version = #version vs | 
| 21637 | 327 | in | 
| 21651 | 328 |         XML.Elem("usespgml", attr "version" version, [])
 | 
| 21637 | 329 | end | 
| 330 | ||
| 21902 | 331 | fun pgip (Pgip vs) = | 
| 21637 | 332 | let | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 333 | val tag = #tag vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 334 | val class = #class vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 335 | val seq = #seq vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 336 | val id = #id vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 337 | val destid = #destid vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 338 | val refid = #refid vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 339 | val refseq = #refseq vs | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 340 | val content = #content vs | 
| 21637 | 341 | in | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 342 |         XML.Elem("pgip",
 | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 343 | opt_attr "tag" tag @ | 
| 21651 | 344 | attr "id" id @ | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 345 | opt_attr "destid" destid @ | 
| 21651 | 346 | attr "class" class @ | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 347 | opt_attr "refid" refid @ | 
| 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 348 | opt_attr_map string_of_int "refseq" refseq @ | 
| 21651 | 349 | attr "seq" (string_of_int seq), | 
| 21649 
40e6fdd26f82
Support PGIP communication for preferences in Emacs mode.
 aspinall parents: 
21637diff
changeset | 350 | content) | 
| 21637 | 351 | end | 
| 352 | ||
| 23834 
ad6ad61332fa
avoid redundant variables in patterns (which made Alice vomit);
 wenzelm parents: 
23749diff
changeset | 353 | fun ready (Ready _) = XML.Elem("ready",[],[])
 | 
| 21637 | 354 | |
| 355 | ||
| 356 | fun output pgipoutput = case pgipoutput of | |
| 23749 
ac6d3a8d22b5
Track schema changes: remove cleardisplay, proofstate messages. Simplify attributes on cleardisplay, normalresponse.
 aspinall parents: 
23610diff
changeset | 357 | Normalresponse _ => normalresponse pgipoutput | 
| 21902 | 358 | | Errorresponse _ => errorresponse pgipoutput | 
| 359 | | Informfileloaded _ => informfileloaded pgipoutput | |
| 22040 
635aaa46b44d
Add informfileoutdated and completed flag.  This makes the PGIP messages match the Broker states.
 aspinall parents: 
21940diff
changeset | 360 | | Informfileoutdated _ => informfileoutdated pgipoutput | 
| 21902 | 361 | | Informfileretracted _ => informfileretracted pgipoutput | 
| 362 | | Metainforesponse _ => metainforesponse pgipoutput | |
| 363 | | Lexicalstructure _ => lexicalstructure pgipoutput | |
| 364 | | Proverinfo _ => proverinfo pgipoutput | |
| 365 | | Setids _ => setids pgipoutput | |
| 22161 | 366 | | Setrefs _ => setrefs pgipoutput | 
| 21902 | 367 | | Addids _ => addids pgipoutput | 
| 368 | | Delids _ => delids pgipoutput | |
| 369 | | Hasprefs _ => hasprefs pgipoutput | |
| 370 | | Prefval _ => prefval pgipoutput | |
| 371 | | Idvalue _ => idvalue pgipoutput | |
| 372 | | Informguise _ => informguise pgipoutput | |
| 373 | | Parseresult _ => parseresult pgipoutput | |
| 374 | | Usespgip _ => usespgip pgipoutput | |
| 375 | | Usespgml _ => usespgml pgipoutput | |
| 376 | | Pgip _ => pgip pgipoutput | |
| 377 | | Ready _ => ready pgipoutput | |
| 21637 | 378 | |
| 379 | end | |
| 380 |