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