src/Pure/PIDE/document.ML
changeset 44182 ecb51b457064
parent 44180 a6dc270d3edb
child 44185 05641edb5d30
equal deleted inserted replaced
44181:bbce0417236d 44182:ecb51b457064
    13   type exec_id = id
    13   type exec_id = id
    14   val no_id: id
    14   val no_id: id
    15   val new_id: unit -> id
    15   val new_id: unit -> id
    16   val parse_id: string -> id
    16   val parse_id: string -> id
    17   val print_id: id -> string
    17   val print_id: id -> string
    18   type node_header = string * string list * string list
    18   type node_header = (string * string list * string list) Exn.result
    19   datatype node_edit =
    19   datatype node_edit =
    20     Remove |
    20     Remove |
    21     Edits of (command_id option * command_id option) list |
    21     Edits of (command_id option * command_id option) list |
    22     Update_Header of node_header Exn.result
    22     Header of node_header
    23   type edit = string * node_edit
    23   type edit = string * node_edit
    24   type state
    24   type state
    25   val init_state: state
    25   val init_state: state
    26   val get_theory: state -> version_id -> Position.T -> string -> theory
    26   val get_theory: state -> version_id -> Position.T -> string -> theory
    27   val cancel_execution: state -> unit -> unit
    27   val cancel_execution: state -> unit -> unit
    53 
    53 
    54 
    54 
    55 
    55 
    56 (** document structure **)
    56 (** document structure **)
    57 
    57 
    58 type node_header = string * string list * string list;
    58 type node_header = (string * string list * string list) Exn.result;
    59 structure Entries = Linear_Set(type key = command_id val ord = int_ord);
    59 structure Entries = Linear_Set(type key = command_id val ord = int_ord);
    60 
    60 
    61 abstype node = Node of
    61 abstype node = Node of
    62  {header: node_header Exn.result,
    62  {header: node_header,
    63   entries: exec_id option Entries.T,  (*command entries with excecutions*)
    63   entries: exec_id option Entries.T,  (*command entries with excecutions*)
    64   last: exec_id}  (*last entry with main result*)
    64   last: exec_id}  (*last entry with main result*)
    65 and version = Version of node Graph.T  (*development graph wrt. static imports*)
    65 and version = Version of node Graph.T  (*development graph wrt. static imports*)
    66 with
    66 with
    67 
    67 
    88 (* node edits and associated executions *)
    88 (* node edits and associated executions *)
    89 
    89 
    90 datatype node_edit =
    90 datatype node_edit =
    91   Remove |
    91   Remove |
    92   Edits of (command_id option * command_id option) list |
    92   Edits of (command_id option * command_id option) list |
    93   Update_Header of node_header Exn.result;
    93   Header of node_header;
    94 
    94 
    95 type edit = string * node_edit;
    95 type edit = string * node_edit;
    96 
    96 
    97 fun the_entry (Node {entries, ...}) id =
    97 fun the_entry (Node {entries, ...}) id =
    98   (case Entries.lookup entries id of
    98   (case Entries.lookup entries id of
   127   Version
   127   Version
   128     (case node_edit of
   128     (case node_edit of
   129       Remove => perhaps (try (Graph.del_node name)) nodes
   129       Remove => perhaps (try (Graph.del_node name)) nodes
   130     | Edits edits => update_node name (edit_node edits) nodes
   130     | Edits edits => update_node name (edit_node edits) nodes
   131     (* FIXME maintain deps; cycles!? *)
   131     (* FIXME maintain deps; cycles!? *)
   132     | Update_Header header => update_node name (set_header header) nodes);
   132     | Header header => update_node name (set_header header) nodes);
   133 
   133 
   134 fun put_node name node (Version nodes) =
   134 fun put_node name node (Version nodes) =
   135   Version (nodes
   135   Version (nodes
   136     |> Graph.default_node (name, empty_node)
   136     |> Graph.default_node (name, empty_node)
   137     |> Graph.map_node name (K node));
   137     |> Graph.map_node name (K node));