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