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