author | wenzelm |
Sun, 09 Jan 2011 20:30:47 +0100 | |
changeset 41484 | 51310e1ccd6f |
parent 41483 | 4a8431c73cf2 |
child 42012 | 2c3fe3cbebae |
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 |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38871
diff
changeset
|
17 |
val kindN: string |
30221 | 18 |
val bindingN: string val binding: string -> T |
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 |
25 |
val end_offsetN: string |
|
23671 | 26 |
val fileN: string |
30221 | 27 |
val idN: string |
27748 | 28 |
val position_properties': string list |
26051 | 29 |
val position_properties: string list |
23671 | 30 |
val positionN: string val position: T |
23644 | 31 |
val indentN: string |
23704 | 32 |
val blockN: string val block: int -> T |
23695 | 33 |
val widthN: string |
23644 | 34 |
val breakN: string val break: int -> T |
35 |
val fbreakN: string val fbreak: T |
|
33985 | 36 |
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
|
37 |
val tclassN: string val tclass: string -> T |
23637 | 38 |
val tyconN: string val tycon: string -> T |
28077 | 39 |
val fixed_declN: string val fixed_decl: string -> T |
26702
a079f8f0080b
added markup for fixed variables (local constants);
wenzelm
parents:
26255
diff
changeset
|
40 |
val fixedN: string val fixed: string -> T |
28113 | 41 |
val const_declN: string val const_decl: string -> T |
23637 | 42 |
val constN: string val const: string -> T |
28077 | 43 |
val fact_declN: string val fact_decl: string -> T |
27740 | 44 |
val factN: string val fact: string -> T |
45 |
val dynamic_factN: string val dynamic_fact: string -> T |
|
28077 | 46 |
val local_fact_declN: string val local_fact_decl: string -> T |
27818 | 47 |
val local_factN: string val local_fact: string -> T |
23719 | 48 |
val tfreeN: string val tfree: T |
49 |
val tvarN: string val tvar: T |
|
50 |
val freeN: string val free: T |
|
51 |
val skolemN: string val skolem: T |
|
52 |
val boundN: string val bound: T |
|
53 |
val varN: string val var: T |
|
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
54 |
val numeralN: string val numeral: T |
27804 | 55 |
val literalN: string val literal: T |
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
56 |
val inner_stringN: string val inner_string: T |
27883 | 57 |
val inner_commentN: string val inner_comment: T |
39168
e3ac771235f7
report token range after inner parse error -- often provides important clues about misunderstanding concerning lexical phase;
wenzelm
parents:
38887
diff
changeset
|
58 |
val token_rangeN: string val token_range: T |
23637 | 59 |
val sortN: string val sort: T |
60 |
val typN: string val typ: T |
|
61 |
val termN: string val term: T |
|
27818 | 62 |
val propN: string val prop: T |
27748 | 63 |
val attributeN: string val attribute: string -> T |
64 |
val methodN: string val method: string -> T |
|
30614 | 65 |
val ML_keywordN: string val ML_keyword: T |
37195 | 66 |
val ML_delimiterN: string val ML_delimiter: T |
30614 | 67 |
val ML_identN: string val ML_ident: T |
68 |
val ML_tvarN: string val ML_tvar: T |
|
69 |
val ML_numeralN: string val ML_numeral: T |
|
70 |
val ML_charN: string val ML_char: T |
|
71 |
val ML_stringN: string val ML_string: T |
|
72 |
val ML_commentN: string val ML_comment: T |
|
73 |
val ML_malformedN: string val ML_malformed: T |
|
30702 | 74 |
val ML_defN: string val ML_def: T |
31472 | 75 |
val ML_openN: string val ML_open: T |
76 |
val ML_structN: string val ML_struct: T |
|
30702 | 77 |
val ML_refN: string val ML_ref: T |
78 |
val ML_typingN: string val ML_typing: T |
|
27875 | 79 |
val ML_sourceN: string val ML_source: T |
80 |
val doc_sourceN: string val doc_source: T |
|
27879 | 81 |
val antiqN: string val antiq: T |
27894 | 82 |
val ML_antiqN: string val ML_antiq: string -> T |
83 |
val doc_antiqN: string val doc_antiq: string -> T |
|
27836 | 84 |
val keyword_declN: string val keyword_decl: string -> T |
85 |
val command_declN: string val command_decl: string -> string -> T |
|
37193 | 86 |
val keywordN: string val keyword: T |
37192 | 87 |
val operatorN: string val operator: T |
37193 | 88 |
val commandN: string val command: T |
27836 | 89 |
val identN: string val ident: T |
23719 | 90 |
val stringN: string val string: T |
91 |
val altstringN: string val altstring: T |
|
92 |
val verbatimN: string val verbatim: T |
|
93 |
val commentN: string val comment: T |
|
94 |
val controlN: string val control: T |
|
95 |
val malformedN: string val malformed: T |
|
38229 | 96 |
val tokenN: string val token: Properties.T -> T |
27660 | 97 |
val command_spanN: string val command_span: string -> T |
98 |
val ignored_spanN: string val ignored_span: T |
|
27836 | 99 |
val malformed_spanN: string val malformed_span: T |
40394
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
100 |
val elapsedN: string |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
101 |
val cpuN: string |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
102 |
val gcN: string |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
103 |
val timingN: string val timing: timing -> T |
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
104 |
val subgoalsN: string |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
105 |
val proof_stateN: string val proof_state: int -> T |
23637 | 106 |
val stateN: string val state: T |
107 |
val subgoalN: string val subgoal: T |
|
24289 | 108 |
val sendbackN: string val sendback: T |
24555 | 109 |
val hiliteN: string val hilite: T |
29417 | 110 |
val taskN: string |
37186
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
111 |
val forkedN: string val forked: T |
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
112 |
val joinedN: string val joined: T |
27615 | 113 |
val failedN: string val failed: T |
27606 | 114 |
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
|
115 |
val versionN: string |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
116 |
val execN: string |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
117 |
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
|
118 |
val editN: string val edit: int -> int -> T |
38871 | 119 |
val serialN: string |
27969 | 120 |
val promptN: string val prompt: T |
31384
ce169bd37fc0
IsabelleProcess: emit status "ready" after initialization and reports;
wenzelm
parents:
30702
diff
changeset
|
121 |
val readyN: string val ready: T |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38871
diff
changeset
|
122 |
val reportN: string val report: T |
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39171
diff
changeset
|
123 |
val no_reportN: string val no_report: T |
39171
525a13b9ac74
highlight bad range of nested error (here from inner parsing);
wenzelm
parents:
39168
diff
changeset
|
124 |
val badN: string val bad: T |
40131
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
39585
diff
changeset
|
125 |
val no_output: Output.output * Output.output |
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
39585
diff
changeset
|
126 |
val default_output: T -> Output.output * Output.output |
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
39585
diff
changeset
|
127 |
val add_mode: string -> (T -> Output.output * Output.output) -> unit |
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
39585
diff
changeset
|
128 |
val output: T -> Output.output * Output.output |
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
39585
diff
changeset
|
129 |
val enclose: T -> Output.output -> Output.output |
25552 | 130 |
val markup: T -> string -> string |
23623 | 131 |
end; |
132 |
||
133 |
structure Markup: MARKUP = |
|
134 |
struct |
|
135 |
||
30221 | 136 |
(** markup elements **) |
137 |
||
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
138 |
(* integers *) |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
139 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
140 |
fun parse_int s = |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
141 |
(case Int.fromString s of |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
142 |
SOME i => i |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
143 |
| 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
|
144 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
145 |
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
|
146 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
147 |
|
23658 | 148 |
(* basic markup *) |
23623 | 149 |
|
28017 | 150 |
type T = string * Properties.T; |
23637 | 151 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
152 |
val empty = ("", []); |
23637 | 153 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
154 |
fun is_empty ("", _) = true |
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
155 |
| is_empty _ = false; |
27883 | 156 |
|
23794 | 157 |
|
23671 | 158 |
fun properties more_props ((elem, props): T) = |
28017 | 159 |
(elem, fold_rev Properties.put more_props props); |
23671 | 160 |
|
25552 | 161 |
fun markup_elem elem = (elem, (elem, []): T); |
23794 | 162 |
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
|
163 |
fun markup_int elem prop = (elem, fn i => (elem, [(prop, print_int i)]): T); |
23794 | 164 |
|
26977 | 165 |
|
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
166 |
(* misc properties *) |
26977 | 167 |
|
23658 | 168 |
val nameN = "name"; |
27818 | 169 |
fun name a = properties [(nameN, a)]; |
170 |
||
23658 | 171 |
val kindN = "kind"; |
23671 | 172 |
|
23658 | 173 |
|
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
174 |
(* formal entities *) |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
175 |
|
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38871
diff
changeset
|
176 |
val (bindingN, binding) = markup_string "binding" nameN; |
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
177 |
val (entityN, entity) = markup_string "entity" nameN; |
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 |
val defN = "def"; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
180 |
val refN = "ref"; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
181 |
|
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
182 |
|
23671 | 183 |
(* position *) |
184 |
||
185 |
val lineN = "line"; |
|
26001 | 186 |
val columnN = "column"; |
27794 | 187 |
val offsetN = "offset"; |
188 |
val end_offsetN = "end_offset"; |
|
23671 | 189 |
val fileN = "file"; |
25816 | 190 |
val idN = "id"; |
23671 | 191 |
|
41484 | 192 |
val position_properties' = [fileN, idN]; |
193 |
val position_properties = [lineN, columnN, offsetN, end_offsetN] @ position_properties'; |
|
27748 | 194 |
|
25552 | 195 |
val (positionN, position) = markup_elem "position"; |
26255 | 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 |
|
39168
e3ac771235f7
report token range after inner parse error -- often provides important clues about misunderstanding concerning lexical phase;
wenzelm
parents:
38887
diff
changeset
|
242 |
val (token_rangeN, token_range) = markup_elem "token_range"; |
e3ac771235f7
report token range after inner parse error -- often provides important clues about misunderstanding concerning lexical phase;
wenzelm
parents:
38887
diff
changeset
|
243 |
|
25552 | 244 |
val (sortN, sort) = markup_elem "sort"; |
245 |
val (typN, typ) = markup_elem "typ"; |
|
246 |
val (termN, term) = markup_elem "term"; |
|
27818 | 247 |
val (propN, prop) = markup_elem "prop"; |
27748 | 248 |
|
249 |
val (attributeN, attribute) = markup_string "attribute" nameN; |
|
250 |
val (methodN, method) = markup_string "method" nameN; |
|
23623 | 251 |
|
252 |
||
30614 | 253 |
(* ML syntax *) |
254 |
||
255 |
val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword"; |
|
37195 | 256 |
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter"; |
30614 | 257 |
val (ML_identN, ML_ident) = markup_elem "ML_ident"; |
258 |
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar"; |
|
259 |
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral"; |
|
260 |
val (ML_charN, ML_char) = markup_elem "ML_char"; |
|
261 |
val (ML_stringN, ML_string) = markup_elem "ML_string"; |
|
262 |
val (ML_commentN, ML_comment) = markup_elem "ML_comment"; |
|
263 |
val (ML_malformedN, ML_malformed) = markup_elem "ML_malformed"; |
|
264 |
||
30702 | 265 |
val (ML_defN, ML_def) = markup_elem "ML_def"; |
31472 | 266 |
val (ML_openN, ML_open) = markup_elem "ML_open"; |
267 |
val (ML_structN, ML_struct) = markup_elem "ML_struct"; |
|
30702 | 268 |
val (ML_refN, ML_ref) = markup_elem "ML_ref"; |
269 |
val (ML_typingN, ML_typing) = markup_elem "ML_typing"; |
|
270 |
||
30614 | 271 |
|
27875 | 272 |
(* embedded source text *) |
273 |
||
274 |
val (ML_sourceN, ML_source) = markup_elem "ML_source"; |
|
275 |
val (doc_sourceN, doc_source) = markup_elem "doc_source"; |
|
276 |
||
27879 | 277 |
val (antiqN, antiq) = markup_elem "antiq"; |
27894 | 278 |
val (ML_antiqN, ML_antiq) = markup_string "ML_antiq" nameN; |
279 |
val (doc_antiqN, doc_antiq) = markup_string "doc_antiq" nameN; |
|
27879 | 280 |
|
27875 | 281 |
|
23623 | 282 |
(* outer syntax *) |
283 |
||
24870 | 284 |
val (keyword_declN, keyword_decl) = markup_string "keyword_decl" nameN; |
285 |
||
286 |
val command_declN = "command_decl"; |
|
287 |
fun command_decl name kind : T = (command_declN, [(nameN, name), (kindN, kind)]); |
|
288 |
||
37193 | 289 |
val (keywordN, keyword) = markup_elem "keyword"; |
37192 | 290 |
val (operatorN, operator) = markup_elem "operator"; |
37193 | 291 |
val (commandN, command) = markup_elem "command"; |
27836 | 292 |
val (identN, ident) = markup_elem "ident"; |
25552 | 293 |
val (stringN, string) = markup_elem "string"; |
294 |
val (altstringN, altstring) = markup_elem "altstring"; |
|
295 |
val (verbatimN, verbatim) = markup_elem "verbatim"; |
|
296 |
val (commentN, comment) = markup_elem "comment"; |
|
297 |
val (controlN, control) = markup_elem "control"; |
|
298 |
val (malformedN, malformed) = markup_elem "malformed"; |
|
23719 | 299 |
|
38229 | 300 |
val tokenN = "token"; |
301 |
fun token props = (tokenN, props); |
|
27851 | 302 |
|
27660 | 303 |
val (command_spanN, command_span) = markup_string "command_span" nameN; |
304 |
val (ignored_spanN, ignored_span) = markup_elem "ignored_span"; |
|
27836 | 305 |
val (malformed_spanN, malformed_span) = markup_elem "malformed_span"; |
23719 | 306 |
|
23623 | 307 |
|
40394
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
308 |
(* timing *) |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
309 |
|
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
310 |
val timingN = "timing"; |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
311 |
val elapsedN = "elapsed"; |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
312 |
val cpuN = "cpu"; |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
313 |
val gcN = "gc"; |
23637 | 314 |
|
40391
b0dafbfc05b7
explicit "timing" status for toplevel transactions;
wenzelm
parents:
40131
diff
changeset
|
315 |
fun timing ({elapsed, cpu, gc, ...}: timing) = |
40394
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
316 |
(timingN, |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
317 |
[(elapsedN, Time.toString elapsed), |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
318 |
(cpuN, Time.toString cpu), |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
319 |
(gcN, Time.toString gc)]); |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
320 |
|
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
321 |
|
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
322 |
(* toplevel *) |
40391
b0dafbfc05b7
explicit "timing" status for toplevel transactions;
wenzelm
parents:
40131
diff
changeset
|
323 |
|
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
324 |
val subgoalsN = "subgoals"; |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
325 |
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
|
326 |
|
25552 | 327 |
val (stateN, state) = markup_elem "state"; |
328 |
val (subgoalN, subgoal) = markup_elem "subgoal"; |
|
329 |
val (sendbackN, sendback) = markup_elem "sendback"; |
|
330 |
val (hiliteN, hilite) = markup_elem "hilite"; |
|
331 |
||
332 |
||
27606 | 333 |
(* command status *) |
334 |
||
29417 | 335 |
val taskN = "task"; |
336 |
||
37186
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
337 |
val (forkedN, forked) = markup_elem "forked"; |
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
338 |
val (joinedN, joined) = markup_elem "joined"; |
38429
9951852fae91
simplified command status: interpret stacked markup on demand;
wenzelm
parents:
38414
diff
changeset
|
339 |
|
27615 | 340 |
val (failedN, failed) = markup_elem "failed"; |
27606 | 341 |
val (finishedN, finished) = markup_elem "finished"; |
342 |
||
29488 | 343 |
|
344 |
(* interactive documents *) |
|
345 |
||
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
346 |
val versionN = "version"; |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
347 |
val execN = "exec"; |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
348 |
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
|
349 |
|
29488 | 350 |
val editN = "edit"; |
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
351 |
fun edit cmd_id exec_id : T = (editN, [(idN, print_int cmd_id), (execN, print_int exec_id)]); |
29482 | 352 |
|
27606 | 353 |
|
27969 | 354 |
(* messages *) |
355 |
||
38871 | 356 |
val serialN = "serial"; |
27969 | 357 |
|
358 |
val (promptN, prompt) = markup_elem "prompt"; |
|
31384
ce169bd37fc0
IsabelleProcess: emit status "ready" after initialization and reports;
wenzelm
parents:
30702
diff
changeset
|
359 |
val (readyN, ready) = markup_elem "ready"; |
27969 | 360 |
|
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38871
diff
changeset
|
361 |
val (reportN, report) = markup_elem "report"; |
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39171
diff
changeset
|
362 |
val (no_reportN, no_report) = markup_elem "no_report"; |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38871
diff
changeset
|
363 |
|
39171
525a13b9ac74
highlight bad range of nested error (here from inner parsing);
wenzelm
parents:
39168
diff
changeset
|
364 |
val (badN, bad) = markup_elem "bad"; |
525a13b9ac74
highlight bad range of nested error (here from inner parsing);
wenzelm
parents:
39168
diff
changeset
|
365 |
|
27969 | 366 |
|
367 |
||
30221 | 368 |
(** print mode operations **) |
23704 | 369 |
|
29325 | 370 |
val no_output = ("", ""); |
371 |
fun default_output (_: T) = no_output; |
|
23704 | 372 |
|
373 |
local |
|
374 |
val default = {output = default_output}; |
|
32738 | 375 |
val modes = Unsynchronized.ref (Symtab.make [("", default)]); |
23704 | 376 |
in |
23922
707639e9497d
marked some CRITICAL sections (for multithreading);
wenzelm
parents:
23794
diff
changeset
|
377 |
fun add_mode name output = CRITICAL (fn () => |
32738 | 378 |
Unsynchronized.change modes (Symtab.update_new (name, {output = output}))); |
23704 | 379 |
fun get_mode () = |
24612 | 380 |
the_default default (Library.get_first (Symtab.lookup (! modes)) (print_mode_value ())); |
23623 | 381 |
end; |
23704 | 382 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
383 |
fun output m = if is_empty m then no_output else #output (get_mode ()) m; |
23704 | 384 |
|
23719 | 385 |
val enclose = output #-> Library.enclose; |
386 |
||
25552 | 387 |
fun markup m = |
388 |
let val (bg, en) = output m |
|
389 |
in Library.enclose (Output.escape bg) (Output.escape en) end; |
|
390 |
||
23704 | 391 |
end; |