src/Pure/PIDE/document.ML
author wenzelm
Sat, 14 Aug 2010 22:45:23 +0200
changeset 38414 49f1f657adc2
parent 38373 e8197eea3cd0
child 38418 9a7af64d71bb
permissions -rw-r--r--
more basic Markup.parse_int/print_int (using signed_string_of_int) (ML); added convenient Markup.Int/Long objects (Scala); simplified "assign" message format -- explicit version id; misc tuning and simplification;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38150
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/PIDE/document.ML
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     3
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     4
Document as collection of named nodes, each consisting of an editable
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     5
list of commands.
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     6
*)
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     7
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     8
signature DOCUMENT =
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
     9
sig
38363
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    10
  type id = int
38373
wenzelm
parents: 38363
diff changeset
    11
  type version_id = id
38363
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    12
  type command_id = id
38373
wenzelm
parents: 38363
diff changeset
    13
  type exec_id = id
38363
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    14
  val no_id: id
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    15
  val parse_id: string -> id
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    16
  val print_id: id -> string
38150
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    17
  type edit = string * ((command_id * command_id option) list) option
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    18
end;
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    19
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    20
structure Document: DOCUMENT =
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    21
struct
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    22
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    23
(* unique identifiers *)
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    24
38363
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    25
type id = int;
38373
wenzelm
parents: 38363
diff changeset
    26
type version_id = id;
38363
af7f41a8a0a8 clarified "state" (accumulated data) vs. "exec" (execution that produces data);
wenzelm
parents: 38355
diff changeset
    27
type command_id = id;
38373
wenzelm
parents: 38363
diff changeset
    28
type exec_id = id;
38355
8cb265fb12fe represent document ids by (long) int, to benefit from the somewhat faster Inttab in ML (LinearSet in Scala is invariably indexed by native object ids);
wenzelm
parents: 38150
diff changeset
    29
8cb265fb12fe represent document ids by (long) int, to benefit from the somewhat faster Inttab in ML (LinearSet in Scala is invariably indexed by native object ids);
wenzelm
parents: 38150
diff changeset
    30
val no_id = 0;
38150
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    31
38414
49f1f657adc2 more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents: 38373
diff changeset
    32
val parse_id = Markup.parse_int;
49f1f657adc2 more basic Markup.parse_int/print_int (using signed_string_of_int) (ML);
wenzelm
parents: 38373
diff changeset
    33
val print_id = Markup.print_int;
38150
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    34
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    35
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    36
(* edits *)
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    37
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    38
type edit =
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    39
  string *  (*node name*)
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    40
  ((command_id * command_id option) list) option;  (*NONE: remove, SOME: insert/remove commands*)
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    41
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    42
end;
67fc24df3721 simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
diff changeset
    43