src/Pure/General/input.ML
author wenzelm
Sun, 30 Nov 2014 13:15:04 +0100
changeset 59066 45ab32a542fe
parent 59064 a8bcb5a446c8
child 59117 caddfa6ca534
permissions -rw-r--r--
tuned signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59064
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/General/input.ML
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     3
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     4
Generic input with position information.
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     5
*)
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     6
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     7
signature INPUT =
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     8
sig
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
     9
  type source
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    10
  val is_delimited: source -> bool
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    11
  val text_of: source -> Symbol_Pos.text
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    12
  val pos_of: source -> Position.T
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    13
  val range_of: source -> Position.range
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    14
  val source: bool -> Symbol_Pos.text -> Position.range -> source
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    15
  val source_explode: source -> Symbol_Pos.T list
59066
45ab32a542fe tuned signature;
wenzelm
parents: 59064
diff changeset
    16
  val source_content: source -> string
59064
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    17
end;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    18
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    19
structure Input: INPUT =
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    20
struct
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    21
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    22
abstype source = Source of {delimited: bool, text: Symbol_Pos.text, range: Position.range}
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    23
with
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    24
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    25
fun is_delimited (Source {delimited, ...}) = delimited;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    26
fun text_of (Source {text, ...}) = text;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    27
fun pos_of (Source {range = (pos, _), ...}) = pos;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    28
fun range_of (Source {range, ...}) = range;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    29
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    30
fun source delimited text range =
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    31
  Source {delimited = delimited, text = text, range = range};
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    32
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    33
fun source_explode (Source {text, range = (pos, _), ...}) =
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    34
  Symbol_Pos.explode (text, pos);
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    35
59066
45ab32a542fe tuned signature;
wenzelm
parents: 59064
diff changeset
    36
val source_content = source_explode #> Symbol_Pos.content;
59064
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    37
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    38
end;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    39
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    40
end;
a8bcb5a446c8 more abstract type Input.source;
wenzelm
parents:
diff changeset
    41