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