author | wenzelm |
Mon, 30 Aug 2010 11:35:17 +0200 | |
changeset 38871 | 28496da3bec2 |
parent 38721 | ca8b14fa0d0d |
child 38887 | 1261481ef5e5 |
permissions | -rw-r--r-- |
23623 | 1 |
(* Title: Pure/General/markup.ML |
2 |
Author: Makarius |
|
3 |
||
4 |
Common markup elements. |
|
5 |
*) |
|
6 |
||
7 |
signature MARKUP = |
|
8 |
sig |
|
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
9 |
val parse_int: string -> int |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
10 |
val print_int: int -> string |
28017 | 11 |
type T = string * Properties.T |
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
12 |
val empty: T |
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
13 |
val is_empty: T -> bool |
38229 | 14 |
val properties: Properties.T -> T -> T |
23623 | 15 |
val nameN: string |
27818 | 16 |
val name: string -> T -> T |
30221 | 17 |
val bindingN: string val binding: string -> T |
23658 | 18 |
val kindN: string |
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
19 |
val entityN: string val entity: string -> T |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
20 |
val defN: string |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
21 |
val refN: string |
23671 | 22 |
val lineN: string |
26001 | 23 |
val columnN: string |
27794 | 24 |
val offsetN: string |
27735 | 25 |
val end_lineN: string |
26 |
val end_columnN: string |
|
27794 | 27 |
val end_offsetN: string |
23671 | 28 |
val fileN: string |
30221 | 29 |
val idN: string |
27748 | 30 |
val position_properties': string list |
26051 | 31 |
val position_properties: string list |
23671 | 32 |
val positionN: string val position: T |
26255 | 33 |
val locationN: string val location: T |
23644 | 34 |
val indentN: string |
23704 | 35 |
val blockN: string val block: int -> T |
23695 | 36 |
val widthN: string |
23644 | 37 |
val breakN: string val break: int -> T |
38 |
val fbreakN: string val fbreak: T |
|
33985 | 39 |
val hiddenN: string val hidden: T |
27828
edafacb690a3
renamed Markup.class to Markup.tclass, to avoid potential conflicts with spacial meaning in markup languages (e.g. HTML);
wenzelm
parents:
27818
diff
changeset
|
40 |
val tclassN: string val tclass: string -> T |
23637 | 41 |
val tyconN: string val tycon: string -> T |
28077 | 42 |
val fixed_declN: string val fixed_decl: string -> T |
26702
a079f8f0080b
added markup for fixed variables (local constants);
wenzelm
parents:
26255
diff
changeset
|
43 |
val fixedN: string val fixed: string -> T |
28113 | 44 |
val const_declN: string val const_decl: string -> T |
23637 | 45 |
val constN: string val const: string -> T |
28077 | 46 |
val fact_declN: string val fact_decl: string -> T |
27740 | 47 |
val factN: string val fact: string -> T |
48 |
val dynamic_factN: string val dynamic_fact: string -> T |
|
28077 | 49 |
val local_fact_declN: string val local_fact_decl: string -> T |
27818 | 50 |
val local_factN: string val local_fact: string -> T |
23719 | 51 |
val tfreeN: string val tfree: T |
52 |
val tvarN: string val tvar: T |
|
53 |
val freeN: string val free: T |
|
54 |
val skolemN: string val skolem: T |
|
55 |
val boundN: string val bound: T |
|
56 |
val varN: string val var: T |
|
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
57 |
val numeralN: string val numeral: T |
27804 | 58 |
val literalN: string val literal: T |
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
59 |
val inner_stringN: string val inner_string: T |
27883 | 60 |
val inner_commentN: string val inner_comment: T |
23637 | 61 |
val sortN: string val sort: T |
62 |
val typN: string val typ: T |
|
63 |
val termN: string val term: T |
|
27818 | 64 |
val propN: string val prop: T |
27748 | 65 |
val attributeN: string val attribute: string -> T |
66 |
val methodN: string val method: string -> T |
|
30614 | 67 |
val ML_keywordN: string val ML_keyword: T |
37195 | 68 |
val ML_delimiterN: string val ML_delimiter: T |
30614 | 69 |
val ML_identN: string val ML_ident: T |
70 |
val ML_tvarN: string val ML_tvar: T |
|
71 |
val ML_numeralN: string val ML_numeral: T |
|
72 |
val ML_charN: string val ML_char: T |
|
73 |
val ML_stringN: string val ML_string: T |
|
74 |
val ML_commentN: string val ML_comment: T |
|
75 |
val ML_malformedN: string val ML_malformed: T |
|
30702 | 76 |
val ML_defN: string val ML_def: T |
31472 | 77 |
val ML_openN: string val ML_open: T |
78 |
val ML_structN: string val ML_struct: T |
|
30702 | 79 |
val ML_refN: string val ML_ref: T |
80 |
val ML_typingN: string val ML_typing: T |
|
27875 | 81 |
val ML_sourceN: string val ML_source: T |
82 |
val doc_sourceN: string val doc_source: T |
|
27879 | 83 |
val antiqN: string val antiq: T |
27894 | 84 |
val ML_antiqN: string val ML_antiq: string -> T |
85 |
val doc_antiqN: string val doc_antiq: string -> T |
|
27836 | 86 |
val keyword_declN: string val keyword_decl: string -> T |
87 |
val command_declN: string val command_decl: string -> string -> T |
|
37193 | 88 |
val keywordN: string val keyword: T |
37192 | 89 |
val operatorN: string val operator: T |
37193 | 90 |
val commandN: string val command: T |
27836 | 91 |
val identN: string val ident: T |
23719 | 92 |
val stringN: string val string: T |
93 |
val altstringN: string val altstring: T |
|
94 |
val verbatimN: string val verbatim: T |
|
95 |
val commentN: string val comment: T |
|
96 |
val controlN: string val control: T |
|
97 |
val malformedN: string val malformed: T |
|
38229 | 98 |
val tokenN: string val token: Properties.T -> T |
27660 | 99 |
val command_spanN: string val command_span: string -> T |
100 |
val ignored_spanN: string val ignored_span: T |
|
27836 | 101 |
val malformed_spanN: string val malformed_span: T |
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
102 |
val subgoalsN: string |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
103 |
val proof_stateN: string val proof_state: int -> T |
23637 | 104 |
val stateN: string val state: T |
105 |
val subgoalN: string val subgoal: T |
|
24289 | 106 |
val sendbackN: string val sendback: T |
24555 | 107 |
val hiliteN: string val hilite: T |
29417 | 108 |
val taskN: string |
37186
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
109 |
val forkedN: string val forked: T |
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
110 |
val joinedN: string val joined: T |
27615 | 111 |
val failedN: string val failed: T |
27606 | 112 |
val finishedN: string val finished: T |
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
113 |
val versionN: string |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
114 |
val execN: string |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
115 |
val assignN: string val assign: int -> T |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
116 |
val editN: string val edit: int -> int -> T |
27969 | 117 |
val pidN: string |
38871 | 118 |
val serialN: string |
27969 | 119 |
val promptN: string val prompt: T |
31384
ce169bd37fc0
IsabelleProcess: emit status "ready" after initialization and reports;
wenzelm
parents:
30702
diff
changeset
|
120 |
val readyN: string val ready: T |
29325 | 121 |
val no_output: output * output |
23704 | 122 |
val default_output: T -> output * output |
23786 | 123 |
val add_mode: string -> (T -> output * output) -> unit |
23704 | 124 |
val output: T -> output * output |
23719 | 125 |
val enclose: T -> output -> output |
25552 | 126 |
val markup: T -> string -> string |
23623 | 127 |
end; |
128 |
||
129 |
structure Markup: MARKUP = |
|
130 |
struct |
|
131 |
||
30221 | 132 |
(** markup elements **) |
133 |
||
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
134 |
(* integers *) |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
135 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
136 |
fun parse_int s = |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
137 |
(case Int.fromString s of |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
138 |
SOME i => i |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
139 |
| NONE => raise Fail ("Bad integer: " ^ quote s)); |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
140 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
141 |
val print_int = signed_string_of_int; |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
142 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
143 |
|
23658 | 144 |
(* basic markup *) |
23623 | 145 |
|
28017 | 146 |
type T = string * Properties.T; |
23637 | 147 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
148 |
val empty = ("", []); |
23637 | 149 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
150 |
fun is_empty ("", _) = true |
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
151 |
| is_empty _ = false; |
27883 | 152 |
|
23794 | 153 |
|
23671 | 154 |
fun properties more_props ((elem, props): T) = |
28017 | 155 |
(elem, fold_rev Properties.put more_props props); |
23671 | 156 |
|
25552 | 157 |
fun markup_elem elem = (elem, (elem, []): T); |
23794 | 158 |
fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): T); |
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
159 |
fun markup_int elem prop = (elem, fn i => (elem, [(prop, print_int i)]): T); |
23794 | 160 |
|
26977 | 161 |
|
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
162 |
(* misc properties *) |
26977 | 163 |
|
23658 | 164 |
val nameN = "name"; |
27818 | 165 |
fun name a = properties [(nameN, a)]; |
166 |
||
30221 | 167 |
val (bindingN, binding) = markup_string "binding" nameN; |
168 |
||
23658 | 169 |
val kindN = "kind"; |
23671 | 170 |
|
23658 | 171 |
|
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
172 |
(* formal entities *) |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
173 |
|
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
174 |
val (entityN, entity) = markup_string "entity" nameN; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
175 |
|
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
176 |
val defN = "def"; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
177 |
val refN = "ref"; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
178 |
|
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
179 |
|
23671 | 180 |
(* position *) |
181 |
||
182 |
val lineN = "line"; |
|
26001 | 183 |
val columnN = "column"; |
27794 | 184 |
val offsetN = "offset"; |
27735 | 185 |
val end_lineN = "end_line"; |
186 |
val end_columnN = "end_column"; |
|
27794 | 187 |
val end_offsetN = "end_offset"; |
23671 | 188 |
val fileN = "file"; |
25816 | 189 |
val idN = "id"; |
23671 | 190 |
|
27794 | 191 |
val position_properties' = [end_lineN, end_columnN, end_offsetN, fileN, idN]; |
192 |
val position_properties = [lineN, columnN, offsetN] @ position_properties'; |
|
27748 | 193 |
|
25552 | 194 |
val (positionN, position) = markup_elem "position"; |
26255 | 195 |
val (locationN, location) = markup_elem "location"; |
196 |
||
23644 | 197 |
|
198 |
(* pretty printing *) |
|
199 |
||
200 |
val indentN = "indent"; |
|
201 |
val (blockN, block) = markup_int "block" indentN; |
|
202 |
||
203 |
val widthN = "width"; |
|
204 |
val (breakN, break) = markup_int "break" widthN; |
|
205 |
||
25552 | 206 |
val (fbreakN, fbreak) = markup_elem "fbreak"; |
23637 | 207 |
|
208 |
||
33985 | 209 |
(* hidden text *) |
210 |
||
211 |
val (hiddenN, hidden) = markup_elem "hidden"; |
|
212 |
||
213 |
||
23623 | 214 |
(* logical entities *) |
215 |
||
27828
edafacb690a3
renamed Markup.class to Markup.tclass, to avoid potential conflicts with spacial meaning in markup languages (e.g. HTML);
wenzelm
parents:
27818
diff
changeset
|
216 |
val (tclassN, tclass) = markup_string "tclass" nameN; |
23658 | 217 |
val (tyconN, tycon) = markup_string "tycon" nameN; |
28077 | 218 |
val (fixed_declN, fixed_decl) = markup_string "fixed_decl" nameN; |
26702
a079f8f0080b
added markup for fixed variables (local constants);
wenzelm
parents:
26255
diff
changeset
|
219 |
val (fixedN, fixed) = markup_string "fixed" nameN; |
28113 | 220 |
val (const_declN, const_decl) = markup_string "const_decl" nameN; |
23658 | 221 |
val (constN, const) = markup_string "const" nameN; |
28077 | 222 |
val (fact_declN, fact_decl) = markup_string "fact_decl" nameN; |
27740 | 223 |
val (factN, fact) = markup_string "fact" nameN; |
224 |
val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN; |
|
28077 | 225 |
val (local_fact_declN, local_fact_decl) = markup_string "local_fact_decl" nameN; |
27818 | 226 |
val (local_factN, local_fact) = markup_string "local_fact" nameN; |
23623 | 227 |
|
228 |
||
229 |
(* inner syntax *) |
|
230 |
||
25552 | 231 |
val (tfreeN, tfree) = markup_elem "tfree"; |
232 |
val (tvarN, tvar) = markup_elem "tvar"; |
|
233 |
val (freeN, free) = markup_elem "free"; |
|
234 |
val (skolemN, skolem) = markup_elem "skolem"; |
|
235 |
val (boundN, bound) = markup_elem "bound"; |
|
236 |
val (varN, var) = markup_elem "var"; |
|
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
237 |
val (numeralN, numeral) = markup_elem "numeral"; |
27804 | 238 |
val (literalN, literal) = markup_elem "literal"; |
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
239 |
val (inner_stringN, inner_string) = markup_elem "inner_string"; |
27883 | 240 |
val (inner_commentN, inner_comment) = markup_elem "inner_comment"; |
23719 | 241 |
|
25552 | 242 |
val (sortN, sort) = markup_elem "sort"; |
243 |
val (typN, typ) = markup_elem "typ"; |
|
244 |
val (termN, term) = markup_elem "term"; |
|
27818 | 245 |
val (propN, prop) = markup_elem "prop"; |
27748 | 246 |
|
247 |
val (attributeN, attribute) = markup_string "attribute" nameN; |
|
248 |
val (methodN, method) = markup_string "method" nameN; |
|
23623 | 249 |
|
250 |
||
30614 | 251 |
(* ML syntax *) |
252 |
||
253 |
val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword"; |
|
37195 | 254 |
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter"; |
30614 | 255 |
val (ML_identN, ML_ident) = markup_elem "ML_ident"; |
256 |
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar"; |
|
257 |
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral"; |
|
258 |
val (ML_charN, ML_char) = markup_elem "ML_char"; |
|
259 |
val (ML_stringN, ML_string) = markup_elem "ML_string"; |
|
260 |
val (ML_commentN, ML_comment) = markup_elem "ML_comment"; |
|
261 |
val (ML_malformedN, ML_malformed) = markup_elem "ML_malformed"; |
|
262 |
||
30702 | 263 |
val (ML_defN, ML_def) = markup_elem "ML_def"; |
31472 | 264 |
val (ML_openN, ML_open) = markup_elem "ML_open"; |
265 |
val (ML_structN, ML_struct) = markup_elem "ML_struct"; |
|
30702 | 266 |
val (ML_refN, ML_ref) = markup_elem "ML_ref"; |
267 |
val (ML_typingN, ML_typing) = markup_elem "ML_typing"; |
|
268 |
||
30614 | 269 |
|
27875 | 270 |
(* embedded source text *) |
271 |
||
272 |
val (ML_sourceN, ML_source) = markup_elem "ML_source"; |
|
273 |
val (doc_sourceN, doc_source) = markup_elem "doc_source"; |
|
274 |
||
27879 | 275 |
val (antiqN, antiq) = markup_elem "antiq"; |
27894 | 276 |
val (ML_antiqN, ML_antiq) = markup_string "ML_antiq" nameN; |
277 |
val (doc_antiqN, doc_antiq) = markup_string "doc_antiq" nameN; |
|
27879 | 278 |
|
27875 | 279 |
|
23623 | 280 |
(* outer syntax *) |
281 |
||
24870 | 282 |
val (keyword_declN, keyword_decl) = markup_string "keyword_decl" nameN; |
283 |
||
284 |
val command_declN = "command_decl"; |
|
285 |
fun command_decl name kind : T = (command_declN, [(nameN, name), (kindN, kind)]); |
|
286 |
||
37193 | 287 |
val (keywordN, keyword) = markup_elem "keyword"; |
37192 | 288 |
val (operatorN, operator) = markup_elem "operator"; |
37193 | 289 |
val (commandN, command) = markup_elem "command"; |
27836 | 290 |
val (identN, ident) = markup_elem "ident"; |
25552 | 291 |
val (stringN, string) = markup_elem "string"; |
292 |
val (altstringN, altstring) = markup_elem "altstring"; |
|
293 |
val (verbatimN, verbatim) = markup_elem "verbatim"; |
|
294 |
val (commentN, comment) = markup_elem "comment"; |
|
295 |
val (controlN, control) = markup_elem "control"; |
|
296 |
val (malformedN, malformed) = markup_elem "malformed"; |
|
23719 | 297 |
|
38229 | 298 |
val tokenN = "token"; |
299 |
fun token props = (tokenN, props); |
|
27851 | 300 |
|
27660 | 301 |
val (command_spanN, command_span) = markup_string "command_span" nameN; |
302 |
val (ignored_spanN, ignored_span) = markup_elem "ignored_span"; |
|
27836 | 303 |
val (malformed_spanN, malformed_span) = markup_elem "malformed_span"; |
23719 | 304 |
|
23623 | 305 |
|
23637 | 306 |
(* toplevel *) |
307 |
||
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
308 |
val subgoalsN = "subgoals"; |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
309 |
val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN; |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
310 |
|
25552 | 311 |
val (stateN, state) = markup_elem "state"; |
312 |
val (subgoalN, subgoal) = markup_elem "subgoal"; |
|
313 |
val (sendbackN, sendback) = markup_elem "sendback"; |
|
314 |
val (hiliteN, hilite) = markup_elem "hilite"; |
|
315 |
||
316 |
||
27606 | 317 |
(* command status *) |
318 |
||
29417 | 319 |
val taskN = "task"; |
320 |
||
37186
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
321 |
val (forkedN, forked) = markup_elem "forked"; |
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
322 |
val (joinedN, joined) = markup_elem "joined"; |
38429
9951852fae91
simplified command status: interpret stacked markup on demand;
wenzelm
parents:
38414
diff
changeset
|
323 |
|
27615 | 324 |
val (failedN, failed) = markup_elem "failed"; |
27606 | 325 |
val (finishedN, finished) = markup_elem "finished"; |
326 |
||
29488 | 327 |
|
328 |
(* interactive documents *) |
|
329 |
||
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
330 |
val versionN = "version"; |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
331 |
val execN = "exec"; |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
332 |
val (assignN, assign) = markup_int "assign" versionN; |
34242
5ccdc8bf3849
explicit markup of document assigment message (simplified variant of earlier "edits" 8c3e1f73953d);
wenzelm
parents:
34214
diff
changeset
|
333 |
|
29488 | 334 |
val editN = "edit"; |
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
335 |
fun edit cmd_id exec_id : T = (editN, [(idN, print_int cmd_id), (execN, print_int exec_id)]); |
29482 | 336 |
|
27606 | 337 |
|
27969 | 338 |
(* messages *) |
339 |
||
340 |
val pidN = "pid"; |
|
38871 | 341 |
val serialN = "serial"; |
27969 | 342 |
|
343 |
val (promptN, prompt) = markup_elem "prompt"; |
|
31384
ce169bd37fc0
IsabelleProcess: emit status "ready" after initialization and reports;
wenzelm
parents:
30702
diff
changeset
|
344 |
val (readyN, ready) = markup_elem "ready"; |
27969 | 345 |
|
346 |
||
347 |
||
30221 | 348 |
(** print mode operations **) |
23704 | 349 |
|
29325 | 350 |
val no_output = ("", ""); |
351 |
fun default_output (_: T) = no_output; |
|
23704 | 352 |
|
353 |
local |
|
354 |
val default = {output = default_output}; |
|
32738 | 355 |
val modes = Unsynchronized.ref (Symtab.make [("", default)]); |
23704 | 356 |
in |
23922
707639e9497d
marked some CRITICAL sections (for multithreading);
wenzelm
parents:
23794
diff
changeset
|
357 |
fun add_mode name output = CRITICAL (fn () => |
32738 | 358 |
Unsynchronized.change modes (Symtab.update_new (name, {output = output}))); |
23704 | 359 |
fun get_mode () = |
24612 | 360 |
the_default default (Library.get_first (Symtab.lookup (! modes)) (print_mode_value ())); |
23623 | 361 |
end; |
23704 | 362 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
363 |
fun output m = if is_empty m then no_output else #output (get_mode ()) m; |
23704 | 364 |
|
23719 | 365 |
val enclose = output #-> Library.enclose; |
366 |
||
25552 | 367 |
fun markup m = |
368 |
let val (bg, en) = output m |
|
369 |
in Library.enclose (Output.escape bg) (Output.escape en) end; |
|
370 |
||
23704 | 371 |
end; |