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