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