src/Pure/PIDE/markup.ML
author wenzelm
Mon Oct 16 14:32:09 2017 +0200 (20 months ago)
changeset 66873 9953ae603a23
parent 66379 6392766f3c25
child 67000 1698e9ccef2d
permissions -rw-r--r--
provide theory timing information, similar to command timing but always considered relevant;
wenzelm@45670
     1
(*  Title:      Pure/PIDE/markup.ML
wenzelm@23623
     2
    Author:     Makarius
wenzelm@23623
     3
wenzelm@56743
     4
Quasi-abstract markup elements.
wenzelm@23623
     5
*)
wenzelm@23623
     6
wenzelm@23623
     7
signature MARKUP =
wenzelm@23623
     8
sig
wenzelm@28017
     9
  type T = string * Properties.T
wenzelm@38474
    10
  val empty: T
wenzelm@38474
    11
  val is_empty: T -> bool
wenzelm@38229
    12
  val properties: Properties.T -> T -> T
wenzelm@23623
    13
  val nameN: string
wenzelm@27818
    14
  val name: string -> T -> T
wenzelm@38887
    15
  val kindN: string
wenzelm@60744
    16
  val serialN: string
wenzelm@60744
    17
  val serial_properties: int -> Properties.T
wenzelm@52854
    18
  val instanceN: string
wenzelm@55828
    19
  val languageN: string
wenzelm@55615
    20
  val symbolsN: string
wenzelm@55828
    21
  val delimitedN: string
wenzelm@55828
    22
  val is_delimited: Properties.T -> bool
wenzelm@55828
    23
  val language: {name: string, symbols: bool, antiquotes: bool, delimited: bool} -> T
wenzelm@55828
    24
  val language': {name: string, symbols: bool, antiquotes: bool} -> bool -> T
wenzelm@62231
    25
  val language_Isar: bool -> T
wenzelm@55761
    26
  val language_method: T
wenzelm@56033
    27
  val language_attribute: T
wenzelm@55828
    28
  val language_sort: bool -> T
wenzelm@55828
    29
  val language_type: bool -> T
wenzelm@55828
    30
  val language_term: bool -> T
wenzelm@55828
    31
  val language_prop: bool -> T
wenzelm@55828
    32
  val language_ML: bool -> T
wenzelm@56278
    33
  val language_SML: bool -> T
wenzelm@61600
    34
  val language_document: bool -> T
wenzelm@55653
    35
  val language_antiquotation: T
wenzelm@55828
    36
  val language_text: bool -> T
wenzelm@62520
    37
  val language_verbatim: bool -> T
wenzelm@55613
    38
  val language_rail: T
wenzelm@56034
    39
  val language_path: T
wenzelm@62772
    40
  val language_mixfix: T
wenzelm@50201
    41
  val bindingN: string val binding: T
wenzelm@50201
    42
  val entityN: string val entity: string -> string -> T
wenzelm@50201
    43
  val get_entity_kind: T -> string option
wenzelm@50201
    44
  val defN: string
wenzelm@50201
    45
  val refN: string
wenzelm@55694
    46
  val completionN: string val completion: T
wenzelm@55914
    47
  val no_completionN: string val no_completion: T
wenzelm@50201
    48
  val lineN: string
wenzelm@58978
    49
  val end_lineN: string
wenzelm@50201
    50
  val offsetN: string
wenzelm@50201
    51
  val end_offsetN: string
wenzelm@50201
    52
  val fileN: string
wenzelm@50201
    53
  val idN: string
wenzelm@50201
    54
  val position_properties': string list
wenzelm@50201
    55
  val position_properties: string list
wenzelm@50201
    56
  val positionN: string val position: T
wenzelm@62806
    57
  val expressionN: string val expression: string -> T
wenzelm@58545
    58
  val citationN: string val citation: string -> T
wenzelm@50201
    59
  val pathN: string val path: string -> T
wenzelm@54702
    60
  val urlN: string val url: string -> T
wenzelm@61660
    61
  val docN: string val doc: string -> T
wenzelm@62788
    62
  val markupN: string
wenzelm@62788
    63
  val consistentN: string
wenzelm@62789
    64
  val unbreakableN: string
wenzelm@62786
    65
  val block_properties: string list
wenzelm@62788
    66
  val indentN: string
wenzelm@50201
    67
  val widthN: string
wenzelm@61864
    68
  val blockN: string val block: bool -> int -> T
wenzelm@61862
    69
  val breakN: string val break: int -> int -> T
wenzelm@50201
    70
  val fbreakN: string val fbreak: T
wenzelm@51570
    71
  val itemN: string val item: T
wenzelm@56548
    72
  val wordsN: string val words: T
wenzelm@50201
    73
  val hiddenN: string val hidden: T
wenzelm@56465
    74
  val system_optionN: string
wenzelm@50201
    75
  val theoryN: string
wenzelm@50201
    76
  val classN: string
wenzelm@50201
    77
  val type_nameN: string
wenzelm@50201
    78
  val constantN: string
wenzelm@50201
    79
  val fixedN: string val fixed: string -> T
wenzelm@53378
    80
  val caseN: string val case_: string -> T
wenzelm@50201
    81
  val dynamic_factN: string val dynamic_fact: string -> T
wenzelm@63337
    82
  val literal_factN: string val literal_fact: string -> T
wenzelm@58048
    83
  val method_modifierN: string
wenzelm@50201
    84
  val tfreeN: string val tfree: T
wenzelm@50201
    85
  val tvarN: string val tvar: T
wenzelm@50201
    86
  val freeN: string val free: T
wenzelm@50201
    87
  val skolemN: string val skolem: T
wenzelm@50201
    88
  val boundN: string val bound: T
wenzelm@50201
    89
  val varN: string val var: T
wenzelm@50201
    90
  val numeralN: string val numeral: T
wenzelm@50201
    91
  val literalN: string val literal: T
wenzelm@50201
    92
  val delimiterN: string val delimiter: T
wenzelm@50201
    93
  val inner_stringN: string val inner_string: T
wenzelm@55033
    94
  val inner_cartoucheN: string val inner_cartouche: T
wenzelm@50201
    95
  val inner_commentN: string val inner_comment: T
wenzelm@50201
    96
  val token_rangeN: string val token_range: T
wenzelm@50201
    97
  val sortingN: string val sorting: T
wenzelm@50201
    98
  val typingN: string val typing: T
wenzelm@63347
    99
  val class_parameterN: string val class_parameter: T
wenzelm@55505
   100
  val ML_keyword1N: string val ML_keyword1: T
wenzelm@55505
   101
  val ML_keyword2N: string val ML_keyword2: T
wenzelm@55505
   102
  val ML_keyword3N: string val ML_keyword3: T
wenzelm@50201
   103
  val ML_delimiterN: string val ML_delimiter: T
wenzelm@50201
   104
  val ML_tvarN: string val ML_tvar: T
wenzelm@50201
   105
  val ML_numeralN: string val ML_numeral: T
wenzelm@50201
   106
  val ML_charN: string val ML_char: T
wenzelm@50201
   107
  val ML_stringN: string val ML_string: T
wenzelm@50201
   108
  val ML_commentN: string val ML_comment: T
wenzelm@56278
   109
  val SML_stringN: string val SML_string: T
wenzelm@56278
   110
  val SML_commentN: string val SML_comment: T
wenzelm@50201
   111
  val ML_defN: string
wenzelm@50201
   112
  val ML_openN: string
wenzelm@55837
   113
  val ML_structureN: string
wenzelm@50201
   114
  val ML_typingN: string val ML_typing: T
wenzelm@60744
   115
  val ML_breakpointN: string val ML_breakpoint: int -> T
wenzelm@55526
   116
  val antiquotedN: string val antiquoted: T
wenzelm@55526
   117
  val antiquoteN: string val antiquote: T
wenzelm@50201
   118
  val ML_antiquotationN: string
wenzelm@50201
   119
  val document_antiquotationN: string
wenzelm@50201
   120
  val document_antiquotation_optionN: string
wenzelm@50201
   121
  val paragraphN: string val paragraph: T
wenzelm@50545
   122
  val text_foldN: string val text_fold: T
wenzelm@61449
   123
  val markdown_paragraphN: string val markdown_paragraph: T
wenzelm@61449
   124
  val markdown_listN: string val markdown_list: string -> T
wenzelm@61449
   125
  val markdown_itemN: string val markdown_item: int -> T
wenzelm@59795
   126
  val inputN: string val input: bool -> Properties.T -> T
wenzelm@59935
   127
  val command_keywordN: string val command_keyword: T
wenzelm@66066
   128
  val commandN: string val command_properties: T -> T
wenzelm@66066
   129
  val keywordN: string val keyword_properties: T -> T
wenzelm@50201
   130
  val stringN: string val string: T
wenzelm@59081
   131
  val alt_stringN: string val alt_string: T
wenzelm@50201
   132
  val verbatimN: string val verbatim: T
wenzelm@55033
   133
  val cartoucheN: string val cartouche: T
wenzelm@50201
   134
  val commentN: string val comment: T
wenzelm@50201
   135
  val keyword1N: string val keyword1: T
wenzelm@50201
   136
  val keyword2N: string val keyword2: T
wenzelm@55763
   137
  val keyword3N: string val keyword3: T
wenzelm@55919
   138
  val quasi_keywordN: string val quasi_keyword: T
wenzelm@56202
   139
  val improperN: string val improper: T
wenzelm@56202
   140
  val operatorN: string val operator: T
wenzelm@50201
   141
  val elapsedN: string
wenzelm@50201
   142
  val cpuN: string
wenzelm@50201
   143
  val gcN: string
wenzelm@51606
   144
  val timing_properties: {elapsed: Time.time, cpu: Time.time, gc: Time.time} -> Properties.T
wenzelm@51606
   145
  val parse_timing_properties: Properties.T -> {elapsed: Time.time, cpu: Time.time, gc: Time.time}
wenzelm@51228
   146
  val command_timingN: string
wenzelm@51228
   147
  val command_timing_properties:
wenzelm@51228
   148
    {file: string, offset: int, name: string} -> Time.time -> Properties.T
wenzelm@51228
   149
  val parse_command_timing_properties:
wenzelm@51228
   150
    Properties.T -> ({file: string, offset: int, name: string} * Time.time) option
wenzelm@51606
   151
  val timingN: string val timing: {elapsed: Time.time, cpu: Time.time, gc: Time.time} -> T
wenzelm@63474
   152
  val command_indentN: string val command_indent: int -> T
wenzelm@50543
   153
  val goalN: string val goal: T
wenzelm@50537
   154
  val subgoalN: string val subgoal: string -> T
wenzelm@50201
   155
  val taskN: string
wenzelm@50201
   156
  val acceptedN: string val accepted: T
wenzelm@50201
   157
  val forkedN: string val forked: T
wenzelm@50201
   158
  val joinedN: string val joined: T
wenzelm@50201
   159
  val runningN: string val running: T
wenzelm@50201
   160
  val finishedN: string val finished: T
wenzelm@50201
   161
  val failedN: string val failed: T
wenzelm@66379
   162
  val consolidatedN: string val consolidated: T
wenzelm@50914
   163
  val exec_idN: string
wenzelm@50201
   164
  val initN: string
wenzelm@61209
   165
  val statusN: string val status: T
wenzelm@61209
   166
  val resultN: string val result: T
wenzelm@61209
   167
  val writelnN: string val writeln: T
wenzelm@61209
   168
  val stateN: string val state: T
wenzelm@61209
   169
  val informationN: string val information: T
wenzelm@61209
   170
  val tracingN: string val tracing: T
wenzelm@61209
   171
  val warningN: string val warning: T
wenzelm@61209
   172
  val legacyN: string val legacy: T
wenzelm@61209
   173
  val errorN: string val error: T
wenzelm@61209
   174
  val systemN: string val system: T
wenzelm@50201
   175
  val protocolN: string
wenzelm@50201
   176
  val reportN: string val report: T
wenzelm@50201
   177
  val no_reportN: string val no_report: T
wenzelm@64677
   178
  val badN: string val bad: unit -> T
wenzelm@50500
   179
  val intensifyN: string val intensify: T
wenzelm@50715
   180
  val browserN: string
wenzelm@50500
   181
  val graphviewN: string
wenzelm@50500
   182
  val sendbackN: string
wenzelm@50500
   183
  val paddingN: string
wenzelm@50842
   184
  val padding_line: Properties.entry
wenzelm@52697
   185
  val padding_command: Properties.entry
wenzelm@50500
   186
  val dialogN: string val dialog: serial -> string -> T
wenzelm@63681
   187
  val jedit_actionN: string
wenzelm@50201
   188
  val functionN: string
wenzelm@52563
   189
  val assign_update: Properties.T
wenzelm@50201
   190
  val removed_versions: Properties.T
wenzelm@52111
   191
  val protocol_handler: string -> Properties.T
wenzelm@50201
   192
  val invoke_scala: string -> string -> Properties.T
wenzelm@50201
   193
  val cancel_scala: string -> Properties.T
wenzelm@50842
   194
  val ML_statistics: Properties.entry
wenzelm@50975
   195
  val task_statistics: Properties.entry
wenzelm@51216
   196
  val command_timing: Properties.entry
wenzelm@66873
   197
  val theory_timing: Properties.entry
wenzelm@50845
   198
  val loading_theory: string -> Properties.T
wenzelm@50845
   199
  val dest_loading_theory: Properties.T -> string option
wenzelm@65313
   200
  val build_session_finished: Properties.T
wenzelm@56864
   201
  val print_operationsN: string
wenzelm@56864
   202
  val print_operations: Properties.T
wenzelm@60842
   203
  val debugger_state: string -> Properties.T
wenzelm@60834
   204
  val debugger_output: string -> Properties.T
wenzelm@57594
   205
  val simp_trace_panelN: string
wenzelm@55553
   206
  val simp_trace_logN: string
wenzelm@55553
   207
  val simp_trace_stepN: string
wenzelm@55553
   208
  val simp_trace_recurseN: string
wenzelm@55553
   209
  val simp_trace_hintN: string
wenzelm@55553
   210
  val simp_trace_ignoreN: string
wenzelm@55553
   211
  val simp_trace_cancel: serial -> Properties.T
wenzelm@40131
   212
  val no_output: Output.output * Output.output
wenzelm@40131
   213
  val add_mode: string -> (T -> Output.output * Output.output) -> unit
wenzelm@40131
   214
  val output: T -> Output.output * Output.output
wenzelm@40131
   215
  val enclose: T -> Output.output -> Output.output
wenzelm@25552
   216
  val markup: T -> string -> string
wenzelm@59125
   217
  val markups: T list -> string -> string
wenzelm@43665
   218
  val markup_only: T -> string
wenzelm@55956
   219
  val markup_report: string -> string
wenzelm@23623
   220
end;
wenzelm@23623
   221
wenzelm@23623
   222
structure Markup: MARKUP =
wenzelm@23623
   223
struct
wenzelm@23623
   224
wenzelm@30221
   225
(** markup elements **)
wenzelm@30221
   226
wenzelm@23658
   227
(* basic markup *)
wenzelm@23623
   228
wenzelm@28017
   229
type T = string * Properties.T;
wenzelm@23637
   230
wenzelm@38474
   231
val empty = ("", []);
wenzelm@23637
   232
wenzelm@38474
   233
fun is_empty ("", _) = true
wenzelm@38474
   234
  | is_empty _ = false;
wenzelm@27883
   235
wenzelm@23794
   236
wenzelm@23671
   237
fun properties more_props ((elem, props): T) =
wenzelm@28017
   238
  (elem, fold_rev Properties.put more_props props);
wenzelm@23671
   239
wenzelm@55551
   240
fun markup_elem name = (name, (name, []): T);
wenzelm@55551
   241
fun markup_string name prop = (name, fn s => (name, [(prop, s)]): T);
wenzelm@63806
   242
fun markup_int name prop = (name, fn i => (name, [(prop, Value.print_int i)]): T);
wenzelm@50201
   243
wenzelm@26977
   244
wenzelm@38721
   245
(* misc properties *)
wenzelm@26977
   246
wenzelm@23658
   247
val nameN = "name";
wenzelm@27818
   248
fun name a = properties [(nameN, a)];
wenzelm@27818
   249
wenzelm@23658
   250
val kindN = "kind";
wenzelm@23671
   251
wenzelm@60744
   252
val serialN = "serial";
wenzelm@63806
   253
fun serial_properties i = [(serialN, Value.print_int i)];
wenzelm@60744
   254
wenzelm@52854
   255
val instanceN = "instance";
wenzelm@52854
   256
wenzelm@23658
   257
wenzelm@55550
   258
(* embedded languages *)
wenzelm@55550
   259
wenzelm@55828
   260
val languageN = "language";
wenzelm@55615
   261
val symbolsN = "symbols";
wenzelm@55666
   262
val antiquotesN = "antiquotes";
wenzelm@55828
   263
val delimitedN = "delimited"
wenzelm@55828
   264
wenzelm@55828
   265
fun is_delimited props =
wenzelm@55828
   266
  Properties.get props delimitedN = SOME "true";
wenzelm@55666
   267
wenzelm@55828
   268
fun language {name, symbols, antiquotes, delimited} =
wenzelm@55666
   269
  (languageN,
wenzelm@55828
   270
   [(nameN, name),
wenzelm@63806
   271
    (symbolsN, Value.print_bool symbols),
wenzelm@63806
   272
    (antiquotesN, Value.print_bool antiquotes),
wenzelm@63806
   273
    (delimitedN, Value.print_bool delimited)]);
wenzelm@55550
   274
wenzelm@55828
   275
fun language' {name, symbols, antiquotes} delimited =
wenzelm@55828
   276
  language {name = name, symbols = symbols, antiquotes = antiquotes, delimited = delimited};
wenzelm@55828
   277
wenzelm@62231
   278
val language_Isar = language' {name = "Isar", symbols = true, antiquotes = false};
wenzelm@55828
   279
val language_method =
wenzelm@55828
   280
  language {name = "method", symbols = true, antiquotes = false, delimited = false};
wenzelm@56033
   281
val language_attribute =
wenzelm@56033
   282
  language {name = "attribute", symbols = true, antiquotes = false, delimited = false};
wenzelm@55828
   283
val language_sort = language' {name = "sort", symbols = true, antiquotes = false};
wenzelm@55828
   284
val language_type = language' {name = "type", symbols = true, antiquotes = false};
wenzelm@55828
   285
val language_term = language' {name = "term", symbols = true, antiquotes = false};
wenzelm@55828
   286
val language_prop = language' {name = "prop", symbols = true, antiquotes = false};
wenzelm@55828
   287
val language_ML = language' {name = "ML", symbols = false, antiquotes = true};
wenzelm@56278
   288
val language_SML = language' {name = "SML", symbols = false, antiquotes = false};
wenzelm@61600
   289
val language_document = language' {name = "document", symbols = false, antiquotes = true};
wenzelm@55828
   290
val language_antiquotation =
wenzelm@55828
   291
  language {name = "antiquotation", symbols = true, antiquotes = false, delimited = true};
wenzelm@55828
   292
val language_text = language' {name = "text", symbols = true, antiquotes = false};
wenzelm@62772
   293
val language_verbatim = language' {name = "verbatim_text", symbols = true, antiquotes = false};
wenzelm@55828
   294
val language_rail = language {name = "rail", symbols = true, antiquotes = true, delimited = true};
wenzelm@56034
   295
val language_path = language {name = "path", symbols = false, antiquotes = false, delimited = true};
wenzelm@62772
   296
val language_mixfix =
wenzelm@62772
   297
  language {name = "mixfix_annotation", symbols = true, antiquotes = false, delimited = true};
wenzelm@55550
   298
wenzelm@55550
   299
wenzelm@50201
   300
(* formal entities *)
wenzelm@50201
   301
wenzelm@50201
   302
val (bindingN, binding) = markup_elem "binding";
wenzelm@50201
   303
wenzelm@50201
   304
val entityN = "entity";
wenzelm@63337
   305
fun entity kind name =
wenzelm@63337
   306
  (entityN,
wenzelm@63337
   307
    (if name = "" then [] else [(nameN, name)]) @ (if kind = "" then [] else [(kindN, kind)]));
wenzelm@50201
   308
wenzelm@50201
   309
fun get_entity_kind (name, props) =
wenzelm@66044
   310
  if name = entityN then Properties.get props kindN
wenzelm@50201
   311
  else NONE;
wenzelm@50201
   312
wenzelm@50201
   313
val defN = "def";
wenzelm@50201
   314
val refN = "ref";
wenzelm@50201
   315
wenzelm@50201
   316
wenzelm@55672
   317
(* completion *)
wenzelm@55672
   318
wenzelm@55694
   319
val (completionN, completion) = markup_elem "completion";
wenzelm@55914
   320
val (no_completionN, no_completion) = markup_elem "no_completion";
wenzelm@55672
   321
wenzelm@55672
   322
wenzelm@50201
   323
(* position *)
wenzelm@50201
   324
wenzelm@50201
   325
val lineN = "line";
wenzelm@58978
   326
val end_lineN = "end_line";
wenzelm@58978
   327
wenzelm@50201
   328
val offsetN = "offset";
wenzelm@50201
   329
val end_offsetN = "end_offset";
wenzelm@58978
   330
wenzelm@50201
   331
val fileN = "file";
wenzelm@50201
   332
val idN = "id";
wenzelm@50201
   333
wenzelm@50201
   334
val position_properties' = [fileN, idN];
wenzelm@50201
   335
val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
wenzelm@50201
   336
wenzelm@50201
   337
val (positionN, position) = markup_elem "position";
wenzelm@50201
   338
wenzelm@50201
   339
wenzelm@58464
   340
(* expression *)
wenzelm@58464
   341
wenzelm@62806
   342
val expressionN = "expression";
wenzelm@62806
   343
fun expression kind = (expressionN, if kind = "" then [] else [(kindN, kind)]);
wenzelm@58464
   344
wenzelm@58464
   345
wenzelm@58544
   346
(* citation *)
wenzelm@58544
   347
wenzelm@58545
   348
val (citationN, citation) = markup_string "citation" nameN;
wenzelm@58544
   349
wenzelm@58544
   350
wenzelm@54702
   351
(* external resources *)
wenzelm@50201
   352
wenzelm@50201
   353
val (pathN, path) = markup_string "path" nameN;
wenzelm@54702
   354
val (urlN, url) = markup_string "url" nameN;
wenzelm@61660
   355
val (docN, doc) = markup_string "doc" nameN;
wenzelm@50201
   356
wenzelm@50201
   357
wenzelm@50201
   358
(* pretty printing *)
wenzelm@50201
   359
wenzelm@62783
   360
val markupN = "markup";
wenzelm@62786
   361
val consistentN = "consistent";
wenzelm@62789
   362
val unbreakableN = "unbreakable";
wenzelm@62786
   363
val indentN = "indent";
wenzelm@62786
   364
wenzelm@62789
   365
val block_properties = [markupN, consistentN, unbreakableN, indentN];
wenzelm@62786
   366
wenzelm@61864
   367
val widthN = "width";
wenzelm@50201
   368
wenzelm@61864
   369
val blockN = "block";
wenzelm@61864
   370
fun block c i =
wenzelm@61864
   371
  (blockN,
wenzelm@63806
   372
    (if c then [(consistentN, Value.print_bool c)] else []) @
wenzelm@63806
   373
    (if i <> 0 then [(indentN, Value.print_int i)] else []));
wenzelm@61864
   374
wenzelm@61862
   375
val breakN = "break";
wenzelm@61864
   376
fun break w i =
wenzelm@61864
   377
  (breakN,
wenzelm@63806
   378
    (if w <> 0 then [(widthN, Value.print_int w)] else []) @
wenzelm@63806
   379
    (if i <> 0 then [(indentN, Value.print_int i)] else []));
wenzelm@50201
   380
wenzelm@50201
   381
val (fbreakN, fbreak) = markup_elem "fbreak";
wenzelm@50201
   382
wenzelm@51570
   383
val (itemN, item) = markup_elem "item";
wenzelm@51570
   384
wenzelm@50201
   385
wenzelm@56548
   386
(* text properties *)
wenzelm@56548
   387
wenzelm@56548
   388
val (wordsN, words) = markup_elem "words";
wenzelm@50201
   389
wenzelm@50201
   390
val (hiddenN, hidden) = markup_elem "hidden";
wenzelm@50201
   391
wenzelm@50201
   392
wenzelm@58048
   393
(* misc entities *)
wenzelm@56465
   394
wenzelm@56465
   395
val system_optionN = "system_option";
wenzelm@50201
   396
wenzelm@50201
   397
val theoryN = "theory";
wenzelm@50201
   398
val classN = "class";
wenzelm@50201
   399
val type_nameN = "type_name";
wenzelm@50201
   400
val constantN = "constant";
wenzelm@50201
   401
wenzelm@50201
   402
val (fixedN, fixed) = markup_string "fixed" nameN;
wenzelm@53378
   403
val (caseN, case_) = markup_string "case" nameN;
wenzelm@50201
   404
val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN;
wenzelm@63337
   405
val (literal_factN, literal_fact) = markup_string "literal_fact" nameN;
wenzelm@50201
   406
wenzelm@58048
   407
val method_modifierN = "method_modifier";
wenzelm@58048
   408
wenzelm@50201
   409
wenzelm@50201
   410
(* inner syntax *)
wenzelm@50201
   411
wenzelm@50201
   412
val (tfreeN, tfree) = markup_elem "tfree";
wenzelm@50201
   413
val (tvarN, tvar) = markup_elem "tvar";
wenzelm@50201
   414
val (freeN, free) = markup_elem "free";
wenzelm@50201
   415
val (skolemN, skolem) = markup_elem "skolem";
wenzelm@50201
   416
val (boundN, bound) = markup_elem "bound";
wenzelm@50201
   417
val (varN, var) = markup_elem "var";
wenzelm@50201
   418
val (numeralN, numeral) = markup_elem "numeral";
wenzelm@50201
   419
val (literalN, literal) = markup_elem "literal";
wenzelm@50201
   420
val (delimiterN, delimiter) = markup_elem "delimiter";
wenzelm@50201
   421
val (inner_stringN, inner_string) = markup_elem "inner_string";
wenzelm@55033
   422
val (inner_cartoucheN, inner_cartouche) = markup_elem "inner_cartouche";
wenzelm@50201
   423
val (inner_commentN, inner_comment) = markup_elem "inner_comment";
wenzelm@50201
   424
wenzelm@50201
   425
val (token_rangeN, token_range) = markup_elem "token_range";
wenzelm@50201
   426
wenzelm@50201
   427
val (sortingN, sorting) = markup_elem "sorting";
wenzelm@50201
   428
val (typingN, typing) = markup_elem "typing";
wenzelm@63347
   429
val (class_parameterN, class_parameter) = markup_elem "class_parameter";
wenzelm@50201
   430
wenzelm@50201
   431
wenzelm@60744
   432
(* ML *)
wenzelm@50201
   433
wenzelm@55505
   434
val (ML_keyword1N, ML_keyword1) = markup_elem "ML_keyword1";
wenzelm@55505
   435
val (ML_keyword2N, ML_keyword2) = markup_elem "ML_keyword2";
wenzelm@55505
   436
val (ML_keyword3N, ML_keyword3) = markup_elem "ML_keyword3";
wenzelm@50201
   437
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
wenzelm@50201
   438
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
wenzelm@50201
   439
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
wenzelm@50201
   440
val (ML_charN, ML_char) = markup_elem "ML_char";
wenzelm@50201
   441
val (ML_stringN, ML_string) = markup_elem "ML_string";
wenzelm@50201
   442
val (ML_commentN, ML_comment) = markup_elem "ML_comment";
wenzelm@56278
   443
val (SML_stringN, SML_string) = markup_elem "SML_string";
wenzelm@56278
   444
val (SML_commentN, SML_comment) = markup_elem "SML_comment";
wenzelm@50201
   445
wenzelm@50201
   446
val ML_defN = "ML_def";
wenzelm@50201
   447
val ML_openN = "ML_open";
wenzelm@55837
   448
val ML_structureN = "ML_structure";
wenzelm@50201
   449
val (ML_typingN, ML_typing) = markup_elem "ML_typing";
wenzelm@50201
   450
wenzelm@60744
   451
val (ML_breakpointN, ML_breakpoint) = markup_int "ML_breakpoint" serialN;
wenzelm@60744
   452
wenzelm@50201
   453
wenzelm@55550
   454
(* antiquotations *)
wenzelm@50201
   455
wenzelm@55526
   456
val (antiquotedN, antiquoted) = markup_elem "antiquoted";
wenzelm@55526
   457
val (antiquoteN, antiquote) = markup_elem "antiquote";
wenzelm@55526
   458
wenzelm@50201
   459
val ML_antiquotationN = "ML_antiquotation";
wenzelm@50201
   460
val document_antiquotationN = "document_antiquotation";
wenzelm@50201
   461
val document_antiquotation_optionN = "document_antiquotation_option";
wenzelm@50201
   462
wenzelm@50201
   463
wenzelm@50201
   464
(* text structure *)
wenzelm@50201
   465
wenzelm@50201
   466
val (paragraphN, paragraph) = markup_elem "paragraph";
wenzelm@50545
   467
val (text_foldN, text_fold) = markup_elem "text_fold";
wenzelm@50201
   468
wenzelm@50201
   469
wenzelm@61449
   470
(* Markdown document structure *)
wenzelm@61449
   471
wenzelm@61449
   472
val (markdown_paragraphN, markdown_paragraph) = markup_elem "markdown_paragraph";
wenzelm@61449
   473
val (markdown_listN, markdown_list) = markup_string "markdown_list" kindN;
wenzelm@61449
   474
val (markdown_itemN, markdown_item) = markup_int "markdown_item" "depth";
wenzelm@61449
   475
wenzelm@61449
   476
wenzelm@59795
   477
(* formal input *)
wenzelm@59795
   478
wenzelm@59795
   479
val inputN = "input";
wenzelm@63806
   480
fun input delimited props = (inputN, (delimitedN, Value.print_bool delimited) :: props);
wenzelm@59795
   481
wenzelm@59795
   482
wenzelm@50201
   483
(* outer syntax *)
wenzelm@50201
   484
wenzelm@59935
   485
val (command_keywordN, command_keyword) = markup_elem "command_keyword";
wenzelm@66044
   486
wenzelm@66066
   487
val commandN = "command"; val command_properties = properties [(kindN, commandN)];
wenzelm@66066
   488
val keywordN = "keyword"; val keyword_properties = properties [(kindN, keywordN)];
wenzelm@66066
   489
wenzelm@55744
   490
val (keyword1N, keyword1) = markup_elem "keyword1";
wenzelm@55744
   491
val (keyword2N, keyword2) = markup_elem "keyword2";
wenzelm@55763
   492
val (keyword3N, keyword3) = markup_elem "keyword3";
wenzelm@55919
   493
val (quasi_keywordN, quasi_keyword) = markup_elem "quasi_keyword";
wenzelm@56202
   494
val (improperN, improper) = markup_elem "improper";
wenzelm@50201
   495
val (operatorN, operator) = markup_elem "operator";
wenzelm@50201
   496
val (stringN, string) = markup_elem "string";
wenzelm@59081
   497
val (alt_stringN, alt_string) = markup_elem "alt_string";
wenzelm@50201
   498
val (verbatimN, verbatim) = markup_elem "verbatim";
wenzelm@55033
   499
val (cartoucheN, cartouche) = markup_elem "cartouche";
wenzelm@50201
   500
val (commentN, comment) = markup_elem "comment";
wenzelm@50201
   501
wenzelm@50201
   502
wenzelm@50201
   503
(* timing *)
wenzelm@50201
   504
wenzelm@50201
   505
val elapsedN = "elapsed";
wenzelm@50201
   506
val cpuN = "cpu";
wenzelm@50201
   507
val gcN = "gc";
wenzelm@50201
   508
wenzelm@50781
   509
fun timing_properties {elapsed, cpu, gc} =
wenzelm@50781
   510
 [(elapsedN, Time.toString elapsed),
wenzelm@50781
   511
  (cpuN, Time.toString cpu),
wenzelm@50781
   512
  (gcN, Time.toString gc)];
wenzelm@50781
   513
wenzelm@51665
   514
fun parse_timing_properties props =
wenzelm@51665
   515
 {elapsed = Properties.seconds props elapsedN,
wenzelm@51665
   516
  cpu = Properties.seconds props cpuN,
wenzelm@51665
   517
  gc = Properties.seconds props gcN};
wenzelm@51218
   518
wenzelm@51665
   519
val timingN = "timing";
wenzelm@51665
   520
fun timing t = (timingN, timing_properties t);
wenzelm@51218
   521
wenzelm@51228
   522
wenzelm@51228
   523
(* command timing *)
wenzelm@51228
   524
wenzelm@51228
   525
val command_timingN = "command_timing";
wenzelm@51228
   526
wenzelm@51228
   527
fun command_timing_properties {file, offset, name} elapsed =
wenzelm@63806
   528
 [(fileN, file), (offsetN, Value.print_int offset),
wenzelm@51228
   529
  (nameN, name), (elapsedN, Time.toString elapsed)];
wenzelm@51228
   530
wenzelm@51228
   531
fun parse_command_timing_properties props =
wenzelm@51228
   532
  (case (Properties.get props fileN, Properties.get props offsetN, Properties.get props nameN) of
wenzelm@51228
   533
    (SOME file, SOME offset, SOME name) =>
wenzelm@63806
   534
      SOME ({file = file, offset = Value.parse_int offset, name = name},
wenzelm@51665
   535
        Properties.seconds props elapsedN)
wenzelm@51228
   536
  | _ => NONE);
wenzelm@51228
   537
wenzelm@51228
   538
wenzelm@63474
   539
(* indentation *)
wenzelm@63474
   540
wenzelm@63474
   541
val (command_indentN, command_indent) = markup_int "command_indent" indentN;
wenzelm@63474
   542
wenzelm@63474
   543
wenzelm@63474
   544
(* goals *)
wenzelm@50201
   545
wenzelm@50543
   546
val (goalN, goal) = markup_elem "goal";
wenzelm@50537
   547
val (subgoalN, subgoal) = markup_string "subgoal" nameN;
wenzelm@50215
   548
wenzelm@50450
   549
wenzelm@50201
   550
(* command status *)
wenzelm@50201
   551
wenzelm@50201
   552
val taskN = "task";
wenzelm@50201
   553
wenzelm@50201
   554
val (acceptedN, accepted) = markup_elem "accepted";
wenzelm@50201
   555
val (forkedN, forked) = markup_elem "forked";
wenzelm@50201
   556
val (joinedN, joined) = markup_elem "joined";
wenzelm@50201
   557
val (runningN, running) = markup_elem "running";
wenzelm@50201
   558
val (finishedN, finished) = markup_elem "finished";
wenzelm@50201
   559
val (failedN, failed) = markup_elem "failed";
wenzelm@66379
   560
val (consolidatedN, consolidated) = markup_elem "consolidated";
wenzelm@50201
   561
wenzelm@50201
   562
wenzelm@50201
   563
(* messages *)
wenzelm@50201
   564
wenzelm@50914
   565
val exec_idN = "exec_id";
wenzelm@50201
   566
wenzelm@50201
   567
val initN = "init";
wenzelm@61209
   568
val (statusN, status) = markup_elem "status";
wenzelm@61209
   569
val (resultN, result) = markup_elem "result";
wenzelm@61209
   570
val (writelnN, writeln) = markup_elem "writeln";
wenzelm@61209
   571
val (stateN, state) = markup_elem "state"
wenzelm@61209
   572
val (informationN, information) = markup_elem "information";
wenzelm@61209
   573
val (tracingN, tracing) = markup_elem "tracing";
wenzelm@61209
   574
val (warningN, warning) = markup_elem "warning";
wenzelm@61209
   575
val (legacyN, legacy) = markup_elem "legacy";
wenzelm@61209
   576
val (errorN, error) = markup_elem "error";
wenzelm@61209
   577
val (systemN, system) = markup_elem "system";
wenzelm@50201
   578
val protocolN = "protocol";
wenzelm@50201
   579
wenzelm@50201
   580
val (reportN, report) = markup_elem "report";
wenzelm@50201
   581
val (no_reportN, no_report) = markup_elem "no_report";
wenzelm@50201
   582
wenzelm@64677
   583
val badN = "bad";
wenzelm@64677
   584
fun bad () = (badN, serial_properties (serial ()));
wenzelm@50201
   585
wenzelm@50500
   586
val (intensifyN, intensify) = markup_elem "intensify";
wenzelm@50500
   587
wenzelm@50500
   588
wenzelm@50500
   589
(* active areas *)
wenzelm@50500
   590
wenzelm@50715
   591
val browserN = "browser"
wenzelm@50500
   592
val graphviewN = "graphview";
wenzelm@50500
   593
wenzelm@50500
   594
val sendbackN = "sendback";
wenzelm@50500
   595
val paddingN = "padding";
wenzelm@52697
   596
val padding_line = (paddingN, "line");
wenzelm@52697
   597
val padding_command = (paddingN, "command");
wenzelm@50500
   598
wenzelm@50500
   599
val dialogN = "dialog";
wenzelm@63806
   600
fun dialog i result = (dialogN, [(serialN, Value.print_int i), (resultN, result)]);
wenzelm@50500
   601
wenzelm@63681
   602
val jedit_actionN = "jedit_action";
wenzelm@63681
   603
wenzelm@50201
   604
wenzelm@50201
   605
(* protocol message functions *)
wenzelm@50201
   606
wenzelm@50201
   607
val functionN = "function"
wenzelm@50201
   608
wenzelm@52563
   609
val assign_update = [(functionN, "assign_update")];
wenzelm@50201
   610
val removed_versions = [(functionN, "removed_versions")];
wenzelm@50201
   611
wenzelm@52111
   612
fun protocol_handler name = [(functionN, "protocol_handler"), (nameN, name)];
wenzelm@52111
   613
wenzelm@50201
   614
fun invoke_scala name id = [(functionN, "invoke_scala"), (nameN, name), (idN, id)];
wenzelm@50201
   615
fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
wenzelm@50201
   616
wenzelm@50683
   617
val ML_statistics = (functionN, "ML_statistics");
wenzelm@50255
   618
wenzelm@50975
   619
val task_statistics = (functionN, "task_statistics");
wenzelm@50975
   620
wenzelm@51216
   621
val command_timing = (functionN, "command_timing");
wenzelm@51216
   622
wenzelm@66873
   623
val theory_timing = (functionN, "theory_timing");
wenzelm@66873
   624
wenzelm@50845
   625
fun loading_theory name = [("function", "loading_theory"), ("name", name)];
wenzelm@50845
   626
wenzelm@50845
   627
fun dest_loading_theory [("function", "loading_theory"), ("name", name)] = SOME name
wenzelm@50845
   628
  | dest_loading_theory _ = NONE;
wenzelm@50845
   629
wenzelm@65313
   630
val build_session_finished = [("function", "build_session_finished")];
wenzelm@56616
   631
wenzelm@56864
   632
val print_operationsN = "print_operations";
wenzelm@56864
   633
val print_operations = [(functionN, print_operationsN)];
wenzelm@56864
   634
wenzelm@50201
   635
wenzelm@60830
   636
(* debugger *)
wenzelm@60830
   637
wenzelm@60842
   638
fun debugger_state name = [(functionN, "debugger_state"), (nameN, name)];
wenzelm@60834
   639
fun debugger_output name = [(functionN, "debugger_output"), (nameN, name)];
wenzelm@60830
   640
wenzelm@60830
   641
wenzelm@55553
   642
(* simplifier trace *)
wenzelm@55553
   643
wenzelm@57594
   644
val simp_trace_panelN = "simp_trace_panel";
wenzelm@57594
   645
wenzelm@55553
   646
val simp_trace_logN = "simp_trace_log";
wenzelm@55553
   647
val simp_trace_stepN = "simp_trace_step";
wenzelm@55553
   648
val simp_trace_recurseN = "simp_trace_recurse";
wenzelm@55553
   649
val simp_trace_hintN = "simp_trace_hint";
wenzelm@55553
   650
val simp_trace_ignoreN = "simp_trace_ignore";
wenzelm@55553
   651
wenzelm@63806
   652
fun simp_trace_cancel i = [(functionN, "simp_trace_cancel"), (serialN, Value.print_int i)];
wenzelm@55553
   653
wenzelm@27969
   654
wenzelm@55672
   655
wenzelm@30221
   656
(** print mode operations **)
wenzelm@23704
   657
wenzelm@29325
   658
val no_output = ("", "");
wenzelm@23704
   659
wenzelm@23704
   660
local
wenzelm@62933
   661
  val default = {output = Output_Primitives.markup_fn};
wenzelm@43684
   662
  val modes = Synchronized.var "Markup.modes" (Symtab.make [("", default)]);
wenzelm@23704
   663
in
wenzelm@43684
   664
  fun add_mode name output =
wenzelm@46894
   665
    Synchronized.change modes (fn tab =>
wenzelm@46894
   666
      (if not (Symtab.defined tab name) then ()
wenzelm@61209
   667
       else Output.warning ("Redefining markup mode " ^ quote name);
wenzelm@46894
   668
       Symtab.update (name, {output = output}) tab));
wenzelm@23704
   669
  fun get_mode () =
wenzelm@43684
   670
    the_default default
wenzelm@43684
   671
      (Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ()));
wenzelm@23623
   672
end;
wenzelm@23704
   673
wenzelm@38474
   674
fun output m = if is_empty m then no_output else #output (get_mode ()) m;
wenzelm@23704
   675
wenzelm@23719
   676
val enclose = output #-> Library.enclose;
wenzelm@23719
   677
wenzelm@25552
   678
fun markup m =
wenzelm@25552
   679
  let val (bg, en) = output m
wenzelm@25552
   680
  in Library.enclose (Output.escape bg) (Output.escape en) end;
wenzelm@25552
   681
wenzelm@59125
   682
val markups = fold_rev markup;
wenzelm@59125
   683
wenzelm@43665
   684
fun markup_only m = markup m "";
wenzelm@43665
   685
wenzelm@55956
   686
fun markup_report "" = ""
wenzelm@55956
   687
  | markup_report txt = markup report txt;
wenzelm@55956
   688
wenzelm@23704
   689
end;