src/Pure/PIDE/isar_document.ML
author wenzelm
Sun Jul 10 00:21:19 2011 +0200 (2011-07-10 ago)
changeset 43722 9b5dadb0c28d
parent 43713 1ba5331b4623
child 43724 4e58485fa320
permissions -rw-r--r--
propagate header changes to prover process;
simplified Document case classes;
Document.State.assignments: indexed by Version_ID;
wenzelm@38483
     1
(*  Title:      Pure/PIDE/isar_document.ML
wenzelm@38412
     2
    Author:     Makarius
wenzelm@38412
     3
wenzelm@38567
     4
Protocol message formats for interactive Isar documents.
wenzelm@38412
     5
*)
wenzelm@38412
     6
wenzelm@43713
     7
structure Isar_Document: sig end =
wenzelm@38412
     8
struct
wenzelm@38412
     9
wenzelm@38418
    10
val _ =
wenzelm@38418
    11
  Isabelle_Process.add_command "Isar_Document.define_command"
wenzelm@43713
    12
    (fn [id, text] => Document.change_state (Document.define_command (Document.parse_id id) text));
wenzelm@38412
    13
wenzelm@38418
    14
val _ =
wenzelm@38418
    15
  Isabelle_Process.add_command "Isar_Document.edit_version"
wenzelm@43722
    16
    (fn [old_id_string, new_id_string, edits_yxml, headers_yxml] => Document.change_state (fn state =>
wenzelm@38418
    17
      let
wenzelm@38418
    18
        val old_id = Document.parse_id old_id_string;
wenzelm@38418
    19
        val new_id = Document.parse_id new_id_string;
wenzelm@38418
    20
        val edits =
wenzelm@38448
    21
          XML_Data.dest_list
wenzelm@38448
    22
            (XML_Data.dest_pair
wenzelm@38448
    23
              XML_Data.dest_string
wenzelm@38448
    24
              (XML_Data.dest_option
wenzelm@38448
    25
                (XML_Data.dest_list
wenzelm@38448
    26
                  (XML_Data.dest_pair
wenzelm@38448
    27
                    (XML_Data.dest_option XML_Data.dest_int)
wenzelm@38448
    28
                    (XML_Data.dest_option XML_Data.dest_int))))) (YXML.parse_body edits_yxml);
wenzelm@43722
    29
        val headers =
wenzelm@43722
    30
          XML_Data.dest_list
wenzelm@43722
    31
            (XML_Data.dest_pair XML_Data.dest_string
wenzelm@43722
    32
              (XML_Data.dest_triple XML_Data.dest_string
wenzelm@43722
    33
                (XML_Data.dest_list XML_Data.dest_string)
wenzelm@43722
    34
                (XML_Data.dest_list XML_Data.dest_string))) (YXML.parse_body headers_yxml);
wenzelm@38412
    35
wenzelm@43666
    36
      val await_cancellation = Document.cancel_execution state;
wenzelm@43722
    37
      val (updates, state') = Document.edit old_id new_id edits headers state;
wenzelm@43666
    38
      val _ = await_cancellation ();
wenzelm@38418
    39
      val _ =
wenzelm@43665
    40
        Output.status (Markup.markup (Markup.assign new_id)
wenzelm@43665
    41
          (implode (map (Markup.markup_only o Markup.edit) updates)));
wenzelm@38418
    42
      val state'' = Document.execute new_id state';
wenzelm@38418
    43
    in state'' end));
wenzelm@38412
    44
wenzelm@38412
    45
end;
wenzelm@38412
    46