author | wenzelm |
Tue, 10 Jul 2007 23:29:49 +0200 | |
changeset 23723 | 4fff46d5faaa |
parent 23610 | 5ade06703b07 |
child 23748 | 1ff6b562076f |
permissions | -rw-r--r-- |
23571 | 1 |
(* Title: Pure/ProofGeneral/pgip_types.ML |
2 |
ID: $Id$ |
|
3 |
Author: David Aspinall |
|
4 |
||
5 |
PGIP abstraction: PGML |
|
6 |
*) |
|
7 |
||
8 |
signature PGML = |
|
9 |
sig |
|
10 |
type pgmlsym = { name: string, content: string } |
|
11 |
||
12 |
datatype pgmlatom = Sym of pgmlsym | Str of string |
|
13 |
||
14 |
datatype pgmlorient = HOVOrient | HOrient | VOrient | HVOrient |
|
15 |
||
16 |
datatype pgmlplace = Subscript | Superscript | Above | Below |
|
17 |
||
18 |
datatype pgmldec = Bold | Italic | Error | Warning | Info | Other of string |
|
19 |
||
20 |
datatype pgmlaction = Toggle | Button | Menu |
|
21 |
||
22 |
datatype pgmlterm = |
|
23 |
Atoms of { kind: string option, content: pgmlatom list } |
|
24 |
| Box of { orient: pgmlorient option, indent: int option, content: pgmlterm list } |
|
25 |
| Break of { mandatory: bool option, indent: int option } |
|
26 |
| Subterm of { kind: string option, |
|
27 |
param: string option, |
|
28 |
place: pgmlplace option, |
|
29 |
name: string option, |
|
30 |
decoration: pgmldec option, |
|
31 |
action: pgmlaction option, |
|
32 |
pos: string option, |
|
33 |
xref: PgipTypes.pgipurl option, |
|
34 |
content: pgmlterm list } |
|
35 |
| Alt of { kind: string option, content: pgmlterm list } |
|
36 |
| Embed of XML.tree list |
|
37 |
||
38 |
datatype pgmldoc = |
|
39 |
Pgml of { version: string option, systemid: string option, |
|
23589
aaba731fce86
Revert body of pgml to match schema for now [change bad for Broker]
aspinall
parents:
23571
diff
changeset
|
40 |
content: pgmlterm } |
23571 | 41 |
|
42 |
val pgmlterm_to_xml : pgmlterm -> XML.tree |
|
43 |
||
44 |
val pgmldoc_to_xml : pgmldoc -> XML.tree |
|
45 |
end |
|
46 |
||
47 |
||
48 |
structure Pgml : PGML = |
|
49 |
struct |
|
50 |
open PgipTypes |
|
51 |
||
52 |
type pgmlsym = { name: string, content: string } |
|
53 |
datatype pgmlatom = Sym of pgmlsym | Str of string |
|
54 |
||
55 |
datatype pgmlorient = HOVOrient | HOrient | VOrient | HVOrient |
|
56 |
||
57 |
datatype pgmlplace = Subscript | Superscript | Above | Below |
|
58 |
||
59 |
datatype pgmldec = Bold | Italic | Error | Warning | Info | Other of string |
|
60 |
||
61 |
datatype pgmlaction = Toggle | Button | Menu |
|
62 |
||
63 |
datatype pgmlterm = |
|
64 |
Atoms of { kind: string option, content: pgmlatom list } |
|
65 |
| Box of { orient: pgmlorient option, indent: int option, content: pgmlterm list } |
|
66 |
| Break of { mandatory: bool option, indent: int option } |
|
67 |
| Subterm of { kind: string option, |
|
68 |
param: string option, |
|
69 |
place: pgmlplace option, |
|
70 |
name: string option, |
|
71 |
decoration: pgmldec option, |
|
72 |
action: pgmlaction option, |
|
73 |
pos: string option, |
|
74 |
xref: PgipTypes.pgipurl option, |
|
75 |
content: pgmlterm list } |
|
76 |
| Alt of { kind: string option, content: pgmlterm list } |
|
77 |
| Embed of XML.tree list |
|
78 |
||
79 |
datatype pgmldoc = |
|
80 |
Pgml of { version: string option, systemid: string option, |
|
23589
aaba731fce86
Revert body of pgml to match schema for now [change bad for Broker]
aspinall
parents:
23571
diff
changeset
|
81 |
content: pgmlterm } |
23571 | 82 |
|
83 |
fun pgmlorient_to_string HOVOrient = "hov" |
|
84 |
| pgmlorient_to_string HOrient = "h" |
|
85 |
| pgmlorient_to_string VOrient = "v" |
|
86 |
| pgmlorient_to_string HVOrient = "hv" |
|
87 |
||
88 |
fun pgmlplace_to_string Subscript = "sub" |
|
89 |
| pgmlplace_to_string Superscript = "sup" |
|
90 |
| pgmlplace_to_string Above = "above" |
|
91 |
| pgmlplace_to_string Below = "below" |
|
92 |
||
93 |
fun pgmldec_to_string Bold = "bold" |
|
94 |
| pgmldec_to_string Italic = "italic" |
|
95 |
| pgmldec_to_string Error = "error" |
|
96 |
| pgmldec_to_string Warning = "warning" |
|
97 |
| pgmldec_to_string Info = "info" |
|
98 |
| pgmldec_to_string (Other s) = "other" |
|
99 |
||
100 |
fun pgmlaction_to_string Toggle = "toggle" |
|
101 |
| pgmlaction_to_string Button = "button" |
|
102 |
| pgmlaction_to_string Menu = "menu" |
|
103 |
||
23610 | 104 |
(* NOTE: we assume strings are already XML escaped here, for convenience in Isabelle; |
105 |
would be better not to *) |
|
23723 | 106 |
fun atom_to_xml (Sym {name,content}) = XML.Elem("sym",attr name name,[XML.Output content]) |
107 |
| atom_to_xml (Str str) = XML.Output str |
|
23571 | 108 |
|
109 |
fun pgmlterm_to_xml (Atoms {kind, content}) = |
|
110 |
XML.Elem("atom",opt_attr "kind" kind, map atom_to_xml content) |
|
111 |
||
112 |
| pgmlterm_to_xml (Box {orient, indent, content}) = |
|
113 |
XML.Elem("box", |
|
114 |
opt_attr_map pgmlorient_to_string "orient" orient @ |
|
115 |
opt_attr_map int_to_pgstring "indent" indent, |
|
116 |
map pgmlterm_to_xml content) |
|
117 |
||
118 |
| pgmlterm_to_xml (Break {mandatory, indent}) = |
|
119 |
XML.Elem("break", |
|
120 |
opt_attr_map bool_to_pgstring "mandatory" mandatory @ |
|
121 |
opt_attr_map int_to_pgstring "indent" indent, []) |
|
122 |
||
123 |
| pgmlterm_to_xml (Subterm {kind, param, place, name, decoration, action, pos, xref, content}) = |
|
124 |
XML.Elem("subterm", |
|
125 |
opt_attr "kind" kind @ |
|
126 |
opt_attr "param" param @ |
|
127 |
opt_attr_map pgmlplace_to_string "place" place @ |
|
128 |
opt_attr "name" name @ |
|
129 |
opt_attr_map pgmldec_to_string "decoration" decoration @ |
|
130 |
opt_attr_map pgmlaction_to_string "action" action @ |
|
131 |
opt_attr "pos" pos @ |
|
132 |
opt_attr_map string_of_pgipurl "xref" xref, |
|
133 |
map pgmlterm_to_xml content) |
|
134 |
||
135 |
| pgmlterm_to_xml (Alt {kind, content}) = |
|
136 |
XML.Elem("alt", opt_attr "kind" kind, map pgmlterm_to_xml content) |
|
137 |
||
138 |
| pgmlterm_to_xml (Embed xmls) = XML.Elem("embed", [], xmls) |
|
139 |
||
140 |
||
141 |
fun pgmldoc_to_xml (Pgml {version,systemid,content}) = |
|
142 |
XML.Elem("pgml",opt_attr "version" version @ opt_attr "systemid" systemid, |
|
23589
aaba731fce86
Revert body of pgml to match schema for now [change bad for Broker]
aspinall
parents:
23571
diff
changeset
|
143 |
[pgmlterm_to_xml content]) |
23571 | 144 |
end |