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