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