summaryrefslogtreecommitdiff
path: root/stream.sig
blob: 7e0f45b2ca3c0d34cb58b42f93e35a31ff5f2ebb (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
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) a1printer

  val getchar: t -> char option * t
  val getcharEx: t -> char * t (* throws EOF *)

  (* 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 getPosRaw: fileOffset -> t -> pos * t
  val getPos: t -> pos * t
  val getPosAfterChar: t -> pos * t
end