summaryrefslogtreecommitdiff
path: root/stream.sig
blob: 22d7a3188b65d1d1a3e11ac6171b5d66e580c5aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
signature STREAM = sig
  type fileId = int
  type fileOffset = int

  datatype pos = Pos of string * int * int

  type t

  exception EOF

  val Ppos: (pos, 'a, 'b, 'c) a1printer

  val getchar: t -> char * t

  (* Will throw UngetcError, if applied at the beginning of the stream.
   * Can be always avoided, so is not provided in sig file *)
  val ungetc: t -> t

  val EOFpos: t -> pos * t

  val getSubstr: fileOffset -> fileOffset -> t -> string
  val getLine: t -> string option * t
  val getFname: t -> string

  (* both throw IO.Io *)
  val create: string -> t
  val createFromInstream: string -> TextIO.instream -> t

  val getOffset: t -> fileOffset
  val isFirstOnLine: t -> fileOffset -> bool
  val getPosRaw: fileOffset -> t -> pos * t
  val getPos: t -> pos * t
  val getPosDisc: t -> pos
  val getPosAfterChar: t -> pos * t
end