src/Pure/PIDE/document.ML
changeset 70663 4a358f8c7cb7
parent 70662 0f9a4e8ee1ab
child 70665 94442fce40a5
equal deleted inserted replaced
70662:0f9a4e8ee1ab 70663:4a358f8c7cb7
    17   type edit = string * node_edit
    17   type edit = string * node_edit
    18   type state
    18   type state
    19   val init_state: state
    19   val init_state: state
    20   val define_blob: string -> string -> state -> state
    20   val define_blob: string -> string -> state -> state
    21   type blob_digest = (string * string option) Exn.result
    21   type blob_digest = (string * string option) Exn.result
    22   val define_command: Document_ID.command -> string -> blob_digest list -> int ->
    22   type command =
    23     ((int * int) * string) list -> state -> state
    23    {command_id: Document_ID.command,
       
    24     name: string,
       
    25     blobs_digests: blob_digest list,
       
    26     blobs_index: int,
       
    27     tokens: ((int * int) * string) list}
       
    28   val define_command: command -> state -> state
    24   val command_exec: state -> string -> Document_ID.command -> Command.exec option
    29   val command_exec: state -> string -> Document_ID.command -> Command.exec option
    25   val remove_versions: Document_ID.version list -> state -> state
    30   val remove_versions: Document_ID.version list -> state -> state
    26   val start_execution: state -> state
    31   val start_execution: state -> state
    27   val update: Document_ID.version -> Document_ID.version -> edit list -> string list -> state ->
    32   val update: Document_ID.version -> Document_ID.version -> edit list -> string list -> state ->
    28     string list * Document_ID.exec list * (Document_ID.command * Document_ID.exec list) list * state
    33     string list * Document_ID.exec list * (Document_ID.command * Document_ID.exec list) list * state
   402   (case blob_digest of Exn.Res (file_node, _) => [(pos, Markup.path file_node)] | _ => []);
   407   (case blob_digest of Exn.Res (file_node, _) => [(pos, Markup.path file_node)] | _ => []);
   403 
   408 
   404 
   409 
   405 (* commands *)
   410 (* commands *)
   406 
   411 
   407 fun define_command command_id name blobs_digests blobs_index toks =
   412 type command =
       
   413   {command_id: Document_ID.command,
       
   414    name: string,
       
   415    blobs_digests: blob_digest list,
       
   416    blobs_index: int,
       
   417    tokens: ((int * int) * string) list};
       
   418 
       
   419 fun define_command {command_id, name, blobs_digests, blobs_index, tokens} =
   408   map_state (fn (versions, blobs, commands, execution) =>
   420   map_state (fn (versions, blobs, commands, execution) =>
   409     let
   421     let
   410       val id = Document_ID.print command_id;
   422       val id = Document_ID.print command_id;
   411       val span =
   423       val span =
   412         Lazy.lazy_name "Document.define_command" (fn () =>
   424         Lazy.lazy_name "Document.define_command" (fn () =>
   413           Position.setmp_thread_data (Position.id_only id)
   425           Position.setmp_thread_data (Position.id_only id)
   414             (fn () =>
   426             (fn () =>
   415               let
   427               let
   416                 val (tokens, _) = fold_map Token.make toks (Position.id id);
   428                 val (tokens, _) = fold_map Token.make tokens (Position.id id);
   417                 val _ =
   429                 val _ =
   418                   if blobs_index < 0
   430                   if blobs_index < 0
   419                   then (*inlined errors*)
   431                   then (*inlined errors*)
   420                     map_filter Exn.get_exn blobs_digests
   432                     map_filter Exn.get_exn blobs_digests
   421                     |> List.app (Output.error_message o Runtime.exn_message)
   433                     |> List.app (Output.error_message o Runtime.exn_message)