author | wenzelm |
Thu, 25 Aug 2011 16:44:06 +0200 | |
changeset 44476 | e8a87398f35d |
parent 44298 | b8f8488704e2 |
child 44549 | 5e5e6ad3922c |
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 |
43547
f3a8476285c6
clarified Binding.pretty/print: no quotes, only markup -- Binding.str_of is rendered obsolete;
wenzelm
parents:
43432
diff
changeset
|
18 |
val bindingN: string val binding: T |
42135 | 19 |
val entityN: string val entity: string -> string -> T |
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
20 |
val get_entity_kind: T -> string option |
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
21 |
val defN: string |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
22 |
val refN: string |
23671 | 23 |
val lineN: 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 |
43593 | 31 |
val pathN: string val path: string -> T |
23644 | 32 |
val indentN: string |
23704 | 33 |
val blockN: string val block: int -> T |
23695 | 34 |
val widthN: string |
23644 | 35 |
val breakN: string val break: int -> T |
36 |
val fbreakN: string val fbreak: T |
|
33985 | 37 |
val hiddenN: string val hidden: T |
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
38 |
val classN: string |
43552 | 39 |
val typeN: string |
40 |
val constantN: string |
|
26702
a079f8f0080b
added markup for fixed variables (local constants);
wenzelm
parents:
26255
diff
changeset
|
41 |
val fixedN: string val fixed: string -> T |
27740 | 42 |
val dynamic_factN: string val dynamic_fact: string -> T |
23719 | 43 |
val tfreeN: string val tfree: T |
44 |
val tvarN: string val tvar: T |
|
45 |
val freeN: string val free: T |
|
46 |
val skolemN: string val skolem: T |
|
47 |
val boundN: string val bound: T |
|
48 |
val varN: string val var: T |
|
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
49 |
val numeralN: string val numeral: T |
27804 | 50 |
val literalN: string val literal: T |
43432
224006e5ac46
inner literal/delimiter corresponds to outer keyword/operator;
wenzelm
parents:
42492
diff
changeset
|
51 |
val delimiterN: string val delimiter: T |
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
52 |
val inner_stringN: string val inner_string: T |
27883 | 53 |
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
|
54 |
val token_rangeN: string val token_range: T |
23637 | 55 |
val sortN: string val sort: T |
56 |
val typN: string val typ: T |
|
57 |
val termN: string val term: T |
|
27818 | 58 |
val propN: string val prop: T |
30614 | 59 |
val ML_keywordN: string val ML_keyword: T |
37195 | 60 |
val ML_delimiterN: string val ML_delimiter: T |
30614 | 61 |
val ML_identN: string val ML_ident: T |
62 |
val ML_tvarN: string val ML_tvar: T |
|
63 |
val ML_numeralN: string val ML_numeral: T |
|
64 |
val ML_charN: string val ML_char: T |
|
65 |
val ML_stringN: string val ML_string: T |
|
66 |
val ML_commentN: string val ML_comment: T |
|
67 |
val ML_malformedN: string val ML_malformed: T |
|
42327
7c7cc7590eb3
Name_Space.entry_markup: keep def position as separate properties;
wenzelm
parents:
42135
diff
changeset
|
68 |
val ML_defN: string |
7c7cc7590eb3
Name_Space.entry_markup: keep def position as separate properties;
wenzelm
parents:
42135
diff
changeset
|
69 |
val ML_openN: string |
7c7cc7590eb3
Name_Space.entry_markup: keep def position as separate properties;
wenzelm
parents:
42135
diff
changeset
|
70 |
val ML_structN: string |
30702 | 71 |
val ML_typingN: string val ML_typing: T |
27875 | 72 |
val ML_sourceN: string val ML_source: T |
73 |
val doc_sourceN: string val doc_source: T |
|
27879 | 74 |
val antiqN: string val antiq: T |
43560
d1650e3720fd
ML antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
43552
diff
changeset
|
75 |
val ML_antiquotationN: string |
43564
9864182c6bad
document antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
43560
diff
changeset
|
76 |
val doc_antiquotationN: string |
9864182c6bad
document antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
43560
diff
changeset
|
77 |
val doc_antiquotation_optionN: string |
27836 | 78 |
val keyword_declN: string val keyword_decl: string -> T |
79 |
val command_declN: string val command_decl: string -> string -> T |
|
37193 | 80 |
val keywordN: string val keyword: T |
37192 | 81 |
val operatorN: string val operator: T |
37193 | 82 |
val commandN: string val command: T |
27836 | 83 |
val identN: string val ident: T |
23719 | 84 |
val stringN: string val string: T |
85 |
val altstringN: string val altstring: T |
|
86 |
val verbatimN: string val verbatim: T |
|
87 |
val commentN: string val comment: T |
|
88 |
val controlN: string val control: T |
|
89 |
val malformedN: string val malformed: T |
|
38229 | 90 |
val tokenN: string val token: Properties.T -> T |
27660 | 91 |
val command_spanN: string val command_span: string -> T |
92 |
val ignored_spanN: string val ignored_span: T |
|
27836 | 93 |
val malformed_spanN: string val malformed_span: T |
43673
29eb1cd29961
Thy_Info.dependencies: ignore already loaded theories, according to initial prover session status;
wenzelm
parents:
43665
diff
changeset
|
94 |
val loaded_theoryN: string val loaded_theory: string -> T |
40394
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
95 |
val elapsedN: string |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
96 |
val cpuN: string |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
97 |
val gcN: string |
42012
2c3fe3cbebae
structure Timing: covers former start_timing/end_timing and Output.timeit etc;
wenzelm
parents:
41484
diff
changeset
|
98 |
val timingN: string val timing: Timing.timing -> T |
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
99 |
val subgoalsN: string |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
100 |
val proof_stateN: string val proof_state: int -> T |
23637 | 101 |
val stateN: string val state: T |
102 |
val subgoalN: string val subgoal: T |
|
24289 | 103 |
val sendbackN: string val sendback: T |
24555 | 104 |
val hiliteN: string val hilite: T |
29417 | 105 |
val taskN: string |
37186
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
106 |
val forkedN: string val forked: T |
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
107 |
val joinedN: string val joined: T |
27615 | 108 |
val failedN: string val failed: T |
27606 | 109 |
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
|
110 |
val versionN: string |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
111 |
val assignN: string val assign: int -> T |
38871 | 112 |
val serialN: string |
27969 | 113 |
val promptN: string val prompt: T |
31384
ce169bd37fc0
IsabelleProcess: emit status "ready" after initialization and reports;
wenzelm
parents:
30702
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
val badN: string val bad: T |
43748 | 118 |
val functionN: string |
119 |
val invoke_scala: string -> string -> Properties.T |
|
44298
b8f8488704e2
Future.promise: explicit abort operation (like uninterruptible future job);
wenzelm
parents:
43797
diff
changeset
|
120 |
val cancel_scala: string -> Properties.T |
40131
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
39585
diff
changeset
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
val enclose: T -> Output.output -> Output.output |
25552 | 126 |
val markup: T -> string -> string |
43665 | 127 |
val markup_only: T -> string |
23623 | 128 |
end; |
129 |
||
130 |
structure Markup: MARKUP = |
|
131 |
struct |
|
132 |
||
30221 | 133 |
(** markup elements **) |
134 |
||
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
135 |
(* integers *) |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
136 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
137 |
fun parse_int s = |
43797
fad7758421bf
more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
wenzelm
parents:
43748
diff
changeset
|
138 |
let val i = Int.fromString s in |
fad7758421bf
more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
wenzelm
parents:
43748
diff
changeset
|
139 |
if is_none i orelse String.isPrefix "~" s |
fad7758421bf
more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
wenzelm
parents:
43748
diff
changeset
|
140 |
then raise Fail ("Bad integer: " ^ quote s) |
fad7758421bf
more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
wenzelm
parents:
43748
diff
changeset
|
141 |
else the i |
fad7758421bf
more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
wenzelm
parents:
43748
diff
changeset
|
142 |
end; |
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
143 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
144 |
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
|
145 |
|
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
146 |
|
23658 | 147 |
(* basic markup *) |
23623 | 148 |
|
28017 | 149 |
type T = string * Properties.T; |
23637 | 150 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
151 |
val empty = ("", []); |
23637 | 152 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
153 |
fun is_empty ("", _) = true |
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
154 |
| is_empty _ = false; |
27883 | 155 |
|
23794 | 156 |
|
23671 | 157 |
fun properties more_props ((elem, props): T) = |
28017 | 158 |
(elem, fold_rev Properties.put more_props props); |
23671 | 159 |
|
25552 | 160 |
fun markup_elem elem = (elem, (elem, []): T); |
23794 | 161 |
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
|
162 |
fun markup_int elem prop = (elem, fn i => (elem, [(prop, print_int i)]): T); |
23794 | 163 |
|
26977 | 164 |
|
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
165 |
(* misc properties *) |
26977 | 166 |
|
23658 | 167 |
val nameN = "name"; |
27818 | 168 |
fun name a = properties [(nameN, a)]; |
169 |
||
23658 | 170 |
val kindN = "kind"; |
23671 | 171 |
|
23658 | 172 |
|
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
173 |
(* formal entities *) |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
174 |
|
43547
f3a8476285c6
clarified Binding.pretty/print: no quotes, only markup -- Binding.str_of is rendered obsolete;
wenzelm
parents:
43432
diff
changeset
|
175 |
val (bindingN, binding) = markup_elem "binding"; |
42135 | 176 |
|
177 |
val entityN = "entity"; |
|
42377 | 178 |
fun entity kind name = (entityN, [(nameN, name), (kindN, kind)]); |
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
179 |
|
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
180 |
fun get_entity_kind (name, props) = |
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
181 |
if name = entityN then AList.lookup (op =) props kindN |
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
182 |
else NONE; |
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
183 |
|
33088
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
184 |
val defN = "def"; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
185 |
val refN = "ref"; |
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
186 |
|
757d7787b10c
markup for formal entities, with "def" or "ref" occurrences;
wenzelm
parents:
32738
diff
changeset
|
187 |
|
23671 | 188 |
(* position *) |
189 |
||
190 |
val lineN = "line"; |
|
27794 | 191 |
val offsetN = "offset"; |
192 |
val end_offsetN = "end_offset"; |
|
23671 | 193 |
val fileN = "file"; |
25816 | 194 |
val idN = "id"; |
23671 | 195 |
|
41484 | 196 |
val position_properties' = [fileN, idN]; |
43710
7270ae921cf2
discontinued odd Position.column -- left-over from attempts at PGIP implementation;
wenzelm
parents:
43684
diff
changeset
|
197 |
val position_properties = [lineN, offsetN, end_offsetN] @ position_properties'; |
27748 | 198 |
|
25552 | 199 |
val (positionN, position) = markup_elem "position"; |
26255 | 200 |
|
23644 | 201 |
|
43593 | 202 |
(* path *) |
203 |
||
204 |
val (pathN, path) = markup_string "path" nameN; |
|
205 |
||
206 |
||
23644 | 207 |
(* pretty printing *) |
208 |
||
209 |
val indentN = "indent"; |
|
210 |
val (blockN, block) = markup_int "block" indentN; |
|
211 |
||
212 |
val widthN = "width"; |
|
213 |
val (breakN, break) = markup_int "break" widthN; |
|
214 |
||
25552 | 215 |
val (fbreakN, fbreak) = markup_elem "fbreak"; |
23637 | 216 |
|
217 |
||
33985 | 218 |
(* hidden text *) |
219 |
||
220 |
val (hiddenN, hidden) = markup_elem "hidden"; |
|
221 |
||
222 |
||
23623 | 223 |
(* logical entities *) |
224 |
||
43548
f231a7594e54
type classes: entity markup instead of old-style token markup;
wenzelm
parents:
43547
diff
changeset
|
225 |
val classN = "class"; |
43552 | 226 |
val typeN = "type"; |
227 |
val constantN = "constant"; |
|
228 |
||
26702
a079f8f0080b
added markup for fixed variables (local constants);
wenzelm
parents:
26255
diff
changeset
|
229 |
val (fixedN, fixed) = markup_string "fixed" nameN; |
27740 | 230 |
val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN; |
23623 | 231 |
|
232 |
||
233 |
(* inner syntax *) |
|
234 |
||
25552 | 235 |
val (tfreeN, tfree) = markup_elem "tfree"; |
236 |
val (tvarN, tvar) = markup_elem "tvar"; |
|
237 |
val (freeN, free) = markup_elem "free"; |
|
238 |
val (skolemN, skolem) = markup_elem "skolem"; |
|
239 |
val (boundN, bound) = markup_elem "bound"; |
|
240 |
val (varN, var) = markup_elem "var"; |
|
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
241 |
val (numeralN, numeral) = markup_elem "numeral"; |
27804 | 242 |
val (literalN, literal) = markup_elem "literal"; |
43432
224006e5ac46
inner literal/delimiter corresponds to outer keyword/operator;
wenzelm
parents:
42492
diff
changeset
|
243 |
val (delimiterN, delimiter) = markup_elem "delimiter"; |
29318
6337d1cb2ba0
added numeral, which supercedes num, xnum, float;
wenzelm
parents:
28904
diff
changeset
|
244 |
val (inner_stringN, inner_string) = markup_elem "inner_string"; |
27883 | 245 |
val (inner_commentN, inner_comment) = markup_elem "inner_comment"; |
23719 | 246 |
|
39168
e3ac771235f7
report token range after inner parse error -- often provides important clues about misunderstanding concerning lexical phase;
wenzelm
parents:
38887
diff
changeset
|
247 |
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
|
248 |
|
25552 | 249 |
val (sortN, sort) = markup_elem "sort"; |
250 |
val (typN, typ) = markup_elem "typ"; |
|
251 |
val (termN, term) = markup_elem "term"; |
|
27818 | 252 |
val (propN, prop) = markup_elem "prop"; |
27748 | 253 |
|
23623 | 254 |
|
30614 | 255 |
(* ML syntax *) |
256 |
||
257 |
val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword"; |
|
37195 | 258 |
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter"; |
30614 | 259 |
val (ML_identN, ML_ident) = markup_elem "ML_ident"; |
260 |
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar"; |
|
261 |
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral"; |
|
262 |
val (ML_charN, ML_char) = markup_elem "ML_char"; |
|
263 |
val (ML_stringN, ML_string) = markup_elem "ML_string"; |
|
264 |
val (ML_commentN, ML_comment) = markup_elem "ML_comment"; |
|
265 |
val (ML_malformedN, ML_malformed) = markup_elem "ML_malformed"; |
|
266 |
||
42327
7c7cc7590eb3
Name_Space.entry_markup: keep def position as separate properties;
wenzelm
parents:
42135
diff
changeset
|
267 |
val ML_defN = "ML_def"; |
7c7cc7590eb3
Name_Space.entry_markup: keep def position as separate properties;
wenzelm
parents:
42135
diff
changeset
|
268 |
val ML_openN = "ML_open"; |
7c7cc7590eb3
Name_Space.entry_markup: keep def position as separate properties;
wenzelm
parents:
42135
diff
changeset
|
269 |
val ML_structN = "ML_struct"; |
30702 | 270 |
val (ML_typingN, ML_typing) = markup_elem "ML_typing"; |
271 |
||
30614 | 272 |
|
27875 | 273 |
(* embedded source text *) |
274 |
||
275 |
val (ML_sourceN, ML_source) = markup_elem "ML_source"; |
|
276 |
val (doc_sourceN, doc_source) = markup_elem "doc_source"; |
|
277 |
||
27879 | 278 |
val (antiqN, antiq) = markup_elem "antiq"; |
43560
d1650e3720fd
ML antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
43552
diff
changeset
|
279 |
val ML_antiquotationN = "ML antiquotation"; |
43564
9864182c6bad
document antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
43560
diff
changeset
|
280 |
val doc_antiquotationN = "document antiquotation"; |
9864182c6bad
document antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
43560
diff
changeset
|
281 |
val doc_antiquotation_optionN = "document antiquotation option"; |
27879 | 282 |
|
27875 | 283 |
|
23623 | 284 |
(* outer syntax *) |
285 |
||
24870 | 286 |
val (keyword_declN, keyword_decl) = markup_string "keyword_decl" nameN; |
287 |
||
288 |
val command_declN = "command_decl"; |
|
289 |
fun command_decl name kind : T = (command_declN, [(nameN, name), (kindN, kind)]); |
|
290 |
||
37193 | 291 |
val (keywordN, keyword) = markup_elem "keyword"; |
37192 | 292 |
val (operatorN, operator) = markup_elem "operator"; |
37193 | 293 |
val (commandN, command) = markup_elem "command"; |
27836 | 294 |
val (identN, ident) = markup_elem "ident"; |
25552 | 295 |
val (stringN, string) = markup_elem "string"; |
296 |
val (altstringN, altstring) = markup_elem "altstring"; |
|
297 |
val (verbatimN, verbatim) = markup_elem "verbatim"; |
|
298 |
val (commentN, comment) = markup_elem "comment"; |
|
299 |
val (controlN, control) = markup_elem "control"; |
|
300 |
val (malformedN, malformed) = markup_elem "malformed"; |
|
23719 | 301 |
|
38229 | 302 |
val tokenN = "token"; |
303 |
fun token props = (tokenN, props); |
|
27851 | 304 |
|
27660 | 305 |
val (command_spanN, command_span) = markup_string "command_span" nameN; |
306 |
val (ignored_spanN, ignored_span) = markup_elem "ignored_span"; |
|
27836 | 307 |
val (malformed_spanN, malformed_span) = markup_elem "malformed_span"; |
23719 | 308 |
|
23623 | 309 |
|
43673
29eb1cd29961
Thy_Info.dependencies: ignore already loaded theories, according to initial prover session status;
wenzelm
parents:
43665
diff
changeset
|
310 |
(* theory loader *) |
29eb1cd29961
Thy_Info.dependencies: ignore already loaded theories, according to initial prover session status;
wenzelm
parents:
43665
diff
changeset
|
311 |
|
29eb1cd29961
Thy_Info.dependencies: ignore already loaded theories, according to initial prover session status;
wenzelm
parents:
43665
diff
changeset
|
312 |
val (loaded_theoryN, loaded_theory) = markup_string "loaded_theory" nameN; |
29eb1cd29961
Thy_Info.dependencies: ignore already loaded theories, according to initial prover session status;
wenzelm
parents:
43665
diff
changeset
|
313 |
|
29eb1cd29961
Thy_Info.dependencies: ignore already loaded theories, according to initial prover session status;
wenzelm
parents:
43665
diff
changeset
|
314 |
|
40394
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
315 |
(* timing *) |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
316 |
|
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
317 |
val timingN = "timing"; |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
318 |
val elapsedN = "elapsed"; |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
319 |
val cpuN = "cpu"; |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
320 |
val gcN = "gc"; |
23637 | 321 |
|
42012
2c3fe3cbebae
structure Timing: covers former start_timing/end_timing and Output.timeit etc;
wenzelm
parents:
41484
diff
changeset
|
322 |
fun timing {elapsed, cpu, gc} = |
40394
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
323 |
(timingN, |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
324 |
[(elapsedN, Time.toString elapsed), |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
325 |
(cpuN, Time.toString cpu), |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
326 |
(gcN, Time.toString gc)]); |
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
327 |
|
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
328 |
|
6dcb6cbf0719
somewhat more uniform timing markup in ML vs. Scala;
wenzelm
parents:
40391
diff
changeset
|
329 |
(* toplevel *) |
40391
b0dafbfc05b7
explicit "timing" status for toplevel transactions;
wenzelm
parents:
40131
diff
changeset
|
330 |
|
38721
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
331 |
val subgoalsN = "subgoals"; |
ca8b14fa0d0d
added some proof state markup, notably number of subgoals (e.g. for indentation);
wenzelm
parents:
38474
diff
changeset
|
332 |
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
|
333 |
|
25552 | 334 |
val (stateN, state) = markup_elem "state"; |
335 |
val (subgoalN, subgoal) = markup_elem "subgoal"; |
|
336 |
val (sendbackN, sendback) = markup_elem "sendback"; |
|
337 |
val (hiliteN, hilite) = markup_elem "hilite"; |
|
338 |
||
339 |
||
27606 | 340 |
(* command status *) |
341 |
||
29417 | 342 |
val taskN = "task"; |
343 |
||
37186
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
344 |
val (forkedN, forked) = markup_elem "forked"; |
349e9223c685
explicit markup for forked goals, as indicated by Goal.fork;
wenzelm
parents:
34242
diff
changeset
|
345 |
val (joinedN, joined) = markup_elem "joined"; |
38429
9951852fae91
simplified command status: interpret stacked markup on demand;
wenzelm
parents:
38414
diff
changeset
|
346 |
|
27615 | 347 |
val (failedN, failed) = markup_elem "failed"; |
27606 | 348 |
val (finishedN, finished) = markup_elem "finished"; |
349 |
||
29488 | 350 |
|
351 |
(* interactive documents *) |
|
352 |
||
38414
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
353 |
val versionN = "version"; |
49f1f657adc2
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents:
38229
diff
changeset
|
354 |
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
|
355 |
|
27606 | 356 |
|
27969 | 357 |
(* messages *) |
358 |
||
38871 | 359 |
val serialN = "serial"; |
27969 | 360 |
|
361 |
val (promptN, prompt) = markup_elem "prompt"; |
|
31384
ce169bd37fc0
IsabelleProcess: emit status "ready" after initialization and reports;
wenzelm
parents:
30702
diff
changeset
|
362 |
val (readyN, ready) = markup_elem "ready"; |
27969 | 363 |
|
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
|
364 |
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
|
365 |
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
|
366 |
|
39171
525a13b9ac74
highlight bad range of nested error (here from inner parsing);
wenzelm
parents:
39168
diff
changeset
|
367 |
val (badN, bad) = markup_elem "bad"; |
525a13b9ac74
highlight bad range of nested error (here from inner parsing);
wenzelm
parents:
39168
diff
changeset
|
368 |
|
27969 | 369 |
|
43748 | 370 |
(* raw message functions *) |
371 |
||
372 |
val functionN = "function" |
|
373 |
||
374 |
fun invoke_scala name id = [(functionN, "invoke_scala"), (nameN, name), (idN, id)]; |
|
44298
b8f8488704e2
Future.promise: explicit abort operation (like uninterruptible future job);
wenzelm
parents:
43797
diff
changeset
|
375 |
fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)]; |
43748 | 376 |
|
377 |
||
27969 | 378 |
|
30221 | 379 |
(** print mode operations **) |
23704 | 380 |
|
29325 | 381 |
val no_output = ("", ""); |
382 |
fun default_output (_: T) = no_output; |
|
23704 | 383 |
|
384 |
local |
|
385 |
val default = {output = default_output}; |
|
43684 | 386 |
val modes = Synchronized.var "Markup.modes" (Symtab.make [("", default)]); |
23704 | 387 |
in |
43684 | 388 |
fun add_mode name output = |
389 |
Synchronized.change modes (Symtab.update_new (name, {output = output})); |
|
23704 | 390 |
fun get_mode () = |
43684 | 391 |
the_default default |
392 |
(Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ())); |
|
23623 | 393 |
end; |
23704 | 394 |
|
38474
e498dc2eb576
uniform Markup.empty/Markup.Empty in ML and Scala;
wenzelm
parents:
38429
diff
changeset
|
395 |
fun output m = if is_empty m then no_output else #output (get_mode ()) m; |
23704 | 396 |
|
23719 | 397 |
val enclose = output #-> Library.enclose; |
398 |
||
25552 | 399 |
fun markup m = |
400 |
let val (bg, en) = output m |
|
401 |
in Library.enclose (Output.escape bg) (Output.escape en) end; |
|
402 |
||
43665 | 403 |
fun markup_only m = markup m ""; |
404 |
||
23704 | 405 |
end; |