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